Commit 0cb5f718 authored by frekk's avatar frekk
Browse files

make approval form respect already-paid memberships

parent 81cc295d
...@@ -32,6 +32,7 @@ class MembershipApprovalForm(MyModelForm): ...@@ -32,6 +32,7 @@ class MembershipApprovalForm(MyModelForm):
# override the model membership_type field so we display all the options with prices # override the model membership_type field so we display all the options with prices
self.fields['membership_type'].choices = get_membership_choices() self.fields['membership_type'].choices = get_membership_choices()
self.fields['payment_confirm'].initial = (self.instance.date_paid is not None)
def clean(self): def clean(self):
""" """
...@@ -50,9 +51,13 @@ class MembershipApprovalForm(MyModelForm): ...@@ -50,9 +51,13 @@ class MembershipApprovalForm(MyModelForm):
data['date_approved'] = now data['date_approved'] = now
if (data['payment_confirm'] == True): if (data['payment_confirm'] == True):
if (data['payment_method'] == ''): if data['payment_method'] == self.instance.payment_method and data['payment_confirm'] == (self.instance.date_paid is not None):
self.add_error('payment_method', 'Please select a payment method') # check if the payment was already made, preserve the date_paid
data['date_paid'] = now data['date_paid'] = self.instance.date_paid
else:
if (data['payment_method'] == ''):
self.add_error('payment_method', 'Please select a payment method')
data['date_paid'] = now
else: else:
data['date_paid'] = None data['date_paid'] = None
......
...@@ -109,6 +109,7 @@ def make_pending_membership(member): ...@@ -109,6 +109,7 @@ def make_pending_membership(member):
# otherwise update the existing membership and mark as pending # otherwise update the existing membership and mark as pending
latest.approved = False latest.approved = False
latest.date_approved = None
latest.date_submitted = timezone.now() latest.date_submitted = timezone.now()
return latest return latest
......
Markdown is supported
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