Merge pull request #111 from levivm/feature/nosystemd

Now if an user after cancel his donation, he make it again, we reacti…
This commit is contained in:
Levi Velázquez 2016-08-05 01:05:12 -05:00 committed by GitHub
commit 0e99639330
3 changed files with 18 additions and 4 deletions

View file

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

View file

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

View file

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