diff --git a/musician/api.py b/musician/api.py index 8e38e7c..178012e 100644 --- a/musician/api.py +++ b/musician/api.py @@ -178,6 +178,11 @@ class Orchestra(object): return addresses + def delete_mail_address(self, pk): + path = API_PATHS.get('address-detail').format_map({'pk': pk}) + url = urllib.parse.urljoin(self.base_url, path) + return self.request("DELETE", url=url, render_as=None) + def retrieve_mailbox_list(self): mailboxes = self.retrieve_service_list(Mailbox.api_name) return [Mailbox.new_from_json(mailbox_data) for mailbox_data in mailboxes] diff --git a/musician/forms.py b/musician/forms.py index 076898d..3f90a74 100644 --- a/musician/forms.py +++ b/musician/forms.py @@ -31,9 +31,9 @@ class MailForm(forms.Form): forward = forms.EmailField(required=False) def __init__(self, *args, **kwargs): - instance = kwargs.pop('instance', None) - if instance is not None: - kwargs['initial'] = instance.deserialize() + self.instance = kwargs.pop('instance', None) + if self.instance is not None: + kwargs['initial'] = self.instance.deserialize() domains = kwargs.pop('domains') mailboxes = kwargs.pop('mailboxes') diff --git a/musician/models.py b/musician/models.py index 9742f8c..9e9a31e 100644 --- a/musician/models.py +++ b/musician/models.py @@ -233,6 +233,7 @@ class Address(OrchestraModel): fields = ('mail_address', 'aliases', 'type', 'type_detail') param_defaults = { "id": None, + "name": None, "domain": None, "mailboxes": [], "forward": None, @@ -260,6 +261,10 @@ class Address(OrchestraModel): name + '@' + self.data['domain']['name'] for name in self.data['names'][1:] ] + @property + def full_address_name(self): + return "{}@{}".format(self.name, self.domain['name']) + @property def mail_address(self): return self.data['names'][0] + '@' + self.data['domain']['name'] diff --git a/musician/templates/musician/address_check_delete.html b/musician/templates/musician/address_check_delete.html new file mode 100644 index 0000000..651b365 --- /dev/null +++ b/musician/templates/musician/address_check_delete.html @@ -0,0 +1,12 @@ +{% extends "musician/base.html" %} +{% load i18n %} + +{% block content %} +
+{% endblock %} diff --git a/musician/templates/musician/mail_form.html b/musician/templates/musician/address_form.html similarity index 70% rename from musician/templates/musician/mail_form.html rename to musician/templates/musician/address_form.html index 2f0aa07..de21067 100644 --- a/musician/templates/musician/mail_form.html +++ b/musician/templates/musician/address_form.html @@ -10,6 +10,11 @@ {% buttons %} {% trans "Cancel" %} + {% if form.instance %} + + {% endif %} {% endbuttons %} {% endblock %} diff --git a/musician/urls.py b/musician/urls.py index 308bf06..caa6799 100644 --- a/musician/urls.py +++ b/musician/urls.py @@ -22,6 +22,7 @@ urlpatterns = [ path('address/', views.MailView.as_view(), name='address-list'), path('address/new/', views.MailCreateView.as_view(), name='address-create'), path('address/