Added Billing Address success message

This commit is contained in:
Levi 2016-10-14 01:17:10 -05:00
parent 86583993cd
commit fe01c0baf3
2 changed files with 17 additions and 1 deletions

View file

@ -36,13 +36,20 @@
{% endfor %}
{% bootstrap_form_errors form type='non_fields'%}
<br>
<div class="row">
<div class="col-xs-12">
<button id="payment_button" class="btn btn-primary btn-lg btn-blck " type="submit">Save</button>
{% if messages %}
{% for message in messages %}
<h2 class="signup-lead text-center">{{ message }}</h2>
{% endfor %}
{% endif %}
<button id="payment_button" class="btn btn-primary btn-lg btn-blck " type="submit">Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>

View file

@ -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()