From ab5a7462ad53f2eb1714cd7b81e705fcac72156a Mon Sep 17 00:00:00 2001 From: Levi Date: Fri, 5 Aug 2016 01:00:44 -0500 Subject: [PATCH] Now if an user after cancel his donation, he make it again, we reactivate his donator status. Fixed css on donations.html --- nosystemd/models.py | 4 ++++ nosystemd/static/nosystemd/css/nosystemd.css | 2 +- nosystemd/views.py | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/nosystemd/models.py b/nosystemd/models.py index 786eb8d7..76d8ca40 100644 --- a/nosystemd/models.py +++ b/nosystemd/models.py @@ -21,6 +21,10 @@ class DonatorStatus(models.Model): def create(cls, user): cls.objects.get_or_create(user=user) + def set_active(self): + self.status = DonatorStatus.ACTIVE + self.save() + class Donation(models.Model): diff --git a/nosystemd/static/nosystemd/css/nosystemd.css b/nosystemd/static/nosystemd/css/nosystemd.css index 120508bc..28b7b7e6 100644 --- a/nosystemd/static/nosystemd/css/nosystemd.css +++ b/nosystemd/static/nosystemd/css/nosystemd.css @@ -13,7 +13,7 @@ form{ .donations-container { - top:30% !important; + top:40% !important; } diff --git a/nosystemd/views.py b/nosystemd/views.py index 7feca11b..50560639 100644 --- a/nosystemd/views.py +++ b/nosystemd/views.py @@ -116,9 +116,9 @@ class DonationView(LoginRequiredMixin, FormView): def get(self, request, *args, **kwargs): - if DonatorStatus.objects.filter(user=self.request.user).exists(): - messages.success(self.request, 'Your already are a monthly contributor') - return HttpResponseRedirect(reverse_lazy('nosystemd:donations')) + # if DonatorStatus.objects.filter(user=self.request.user).exists(): + # messages.success(self.request, 'Your already are a monthly contributor') + # return HttpResponseRedirect(reverse_lazy('nosystemd:donations')) return self.render_to_response(self.get_context_data()) @@ -168,6 +168,16 @@ class DonationView(LoginRequiredMixin, FormView): }) donation_form = DonationForm(donation_data) if donation_form.is_valid(): + + # reactivate donation status + donation = donation_form.save() + + try: + donator_status = DonatorStatus.objects.get(user=self.request.user) + donator_status.set_active() + except DonatorStatus.DoesNotExist: + pass + donation = donation_form.save() context = {