From d77b876a54b7b412f005010b1521ab71b8cd0b4e Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 14 Oct 2021 12:05:42 +0200 Subject: [PATCH] Show success & error messages --- musician/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/musician/views.py b/musician/views.py index bf5319c..2daab06 100644 --- a/musician/views.py +++ b/musician/views.py @@ -279,8 +279,9 @@ class AddressDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView): self.object = self.get_object() try: self.orchestra.delete_mail_address(self.object.id) + messages.success(self.request, _('Address deleted!')) except HTTPError as e: - # TODO(@slamora): show error message to user + messages.error(self.request, _('Cannot process your request, please try again later.')) logger.error(e) return HttpResponseRedirect(self.success_url) @@ -415,8 +416,9 @@ class MailboxDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView): self.object = self.get_object() try: self.orchestra.delete_mailbox(self.object.id) + messages.success(self.request, _('Mailbox deleted!')) except HTTPError as e: - # TODO(@slamora): show error message to user + messages.error(self.request, _('Cannot process your request, please try again later.')) logger.error(e) self.notify_managers(self.object) @@ -461,10 +463,9 @@ class MailboxChangePasswordView(CustomContextMixin, UserTokenRequiredMixin, Form status, response = self.orchestra.set_password_mailbox(self.kwargs['pk'], data) if status < 400: - messages.add_message(self.request, messages.SUCCESS, _('Password updated!')) + messages.success(self.request, _('Password updated!')) else: - messages.add_message(self.request, messages.ERROR, _( - 'Cannot process your request, please try again later.')) + messages.error(self.request, _('Cannot process your request, please try again later.')) logger.error("{}: {}".format(status, str(response)[:100])) return super().form_valid(form)