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:
parent
bad053e4de
commit
ab5a7462ad
3 changed files with 18 additions and 4 deletions
|
@ -21,6 +21,10 @@ class DonatorStatus(models.Model):
|
||||||
def create(cls, user):
|
def create(cls, user):
|
||||||
cls.objects.get_or_create(user=user)
|
cls.objects.get_or_create(user=user)
|
||||||
|
|
||||||
|
def set_active(self):
|
||||||
|
self.status = DonatorStatus.ACTIVE
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
class Donation(models.Model):
|
class Donation(models.Model):
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ form{
|
||||||
|
|
||||||
.donations-container {
|
.donations-container {
|
||||||
|
|
||||||
top:30% !important;
|
top:40% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,9 +116,9 @@ class DonationView(LoginRequiredMixin, FormView):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
|
||||||
if DonatorStatus.objects.filter(user=self.request.user).exists():
|
# if DonatorStatus.objects.filter(user=self.request.user).exists():
|
||||||
messages.success(self.request, 'Your already are a monthly contributor')
|
# messages.success(self.request, 'Your already are a monthly contributor')
|
||||||
return HttpResponseRedirect(reverse_lazy('nosystemd:donations'))
|
# return HttpResponseRedirect(reverse_lazy('nosystemd:donations'))
|
||||||
|
|
||||||
return self.render_to_response(self.get_context_data())
|
return self.render_to_response(self.get_context_data())
|
||||||
|
|
||||||
|
@ -168,6 +168,16 @@ class DonationView(LoginRequiredMixin, FormView):
|
||||||
})
|
})
|
||||||
donation_form = DonationForm(donation_data)
|
donation_form = DonationForm(donation_data)
|
||||||
if donation_form.is_valid():
|
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()
|
donation = donation_form.save()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
|
Loading…
Reference in a new issue