Commit 426417dc authored by frekk's avatar frekk
Browse files

check whether pending membership exists when renewing

parent d4c5bcaa
......@@ -28,7 +28,10 @@ def get_membership_type(member):
return best['dispense']
def make_pending_membership(member):
ms = Membership(member=member, approved=False)
# check if this member already has a pending membership
ms = Membership.objects.filter(member=member, approved__exact=False).first()
if (ms is None):
ms = Membership(member=member, approved=False)
ms.date_submitted = timezone.now()
ms.membership_type = get_membership_type(member)
return ms
......@@ -41,7 +44,6 @@ and have a look at .admin.MembershipAdmin
class MembershipApprovalForm(MyModelForm):
payment_confirm = forms.BooleanField(label='Confirm payment', required=False)
class Meta:
model = Membership
fields = ['membership_type', 'payment_method']
......@@ -105,7 +107,6 @@ class MembershipApprovalAdminView(MyUpdateView):
pk_url_kwarg = 'object_id'
# override with the instance of ModelAdmin
admin = None
object = None
def get_context_data(self, **kwargs):
ms = self.get_object()
......@@ -119,7 +120,6 @@ class MembershipApprovalAdminView(MyUpdateView):
})
return context
"""
called when the approval form is submitted and valid data (according to the form's field types and defined validators) is given
"""
......
......@@ -2,10 +2,9 @@
This file implements the member-facing registration workflow. See ../../README.md
"""
from django.http import HttpResponse, HttpResponseRedirect
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.views.generic.edit import CreateView, UpdateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.safestring import mark_safe
from django import forms
......@@ -74,9 +73,6 @@ class RenewForm(RegisterForm):
ms.save()
return m, ms
"""
simple FormView which displays registration form and handles template rendering & form submission
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment