Now if an user after cancel his donation, he make it again, we reactivate his donator status. Fixed css on donations.html

This commit is contained in:
Levi 2016-08-05 01:00:44 -05:00
parent bad053e4de
commit ab5a7462ad
3 changed files with 18 additions and 4 deletions

View file

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

View file

@ -13,7 +13,7 @@ form{
.donations-container {
top:30% !important;
top:40% !important;
}

View file

@ -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 = {