From fe01c0baf3d06ab253603a49febe972507274f22 Mon Sep 17 00:00:00 2001 From: Levi Date: Fri, 14 Oct 2016 01:17:10 -0500 Subject: [PATCH] Added Billing Address success message --- .../templates/digitalglarus/user_billing_address.html | 9 ++++++++- digitalglarus/views.py | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/digitalglarus/templates/digitalglarus/user_billing_address.html b/digitalglarus/templates/digitalglarus/user_billing_address.html index b38acf0e..138dc8ab 100644 --- a/digitalglarus/templates/digitalglarus/user_billing_address.html +++ b/digitalglarus/templates/digitalglarus/user_billing_address.html @@ -36,13 +36,20 @@ {% endfor %} {% bootstrap_form_errors form type='non_fields'%}
+
- + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} +
+ diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 2b11e65a..192e4fc0 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -473,6 +473,15 @@ class UserBillingAddressView(LoginRequiredMixin, UpdateView): form_class = UserBillingAddressForm template_name = "digitalglarus/user_billing_address.html" success_url = reverse_lazy('digitalglarus:user_billing_address') + success_message = "Billing Address Updated" + + def form_valid(self, form): + """ + If the form is valid, save the associated model. + """ + messages.add_message(self.request, messages.SUCCESS, self.success_message) + self.object = form.save() + return super(UserBillingAddressView, self).form_valid(form) def get_form_kwargs(self): current_billing_address = self.request.user.billing_addresses.first()