Commit 9e9387fb authored by frekk's avatar frekk
Browse files

moved make_pending_membership to register.py

parent 05920eef
...@@ -12,15 +12,6 @@ from memberdb.models import Member, Membership, get_membership_type ...@@ -12,15 +12,6 @@ from memberdb.models import Member, Membership, get_membership_type
from memberdb.forms import MyModelForm from memberdb.forms import MyModelForm
from memberdb.views import MyUpdateView from memberdb.views import MyUpdateView
def make_pending_membership(member):
# 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
""" """
inline admin change list action buttons inline admin change list action buttons
see https://medium.com/@hakibenita/how-to-add-custom-action-buttons-to-django-admin-8d266f5b0d41 see https://medium.com/@hakibenita/how-to-add-custom-action-buttons-to-django-admin-8d266f5b0d41
......
...@@ -3,6 +3,7 @@ from django.db.models import F ...@@ -3,6 +3,7 @@ from django.db.models import F
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.core.management.utils import get_random_string from django.core.management.utils import get_random_string
from django.urls import reverse from django.urls import reverse
from django.utils import timezone
from squarepay.dispense import get_item_price from squarepay.dispense import get_item_price
import subprocess import subprocess
...@@ -98,6 +99,14 @@ def get_membership_type(member): ...@@ -98,6 +99,14 @@ def get_membership_type(member):
break break
return best return best
def make_pending_membership(member):
# 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
def make_token(): def make_token():
return get_random_string(128) return get_random_string(128)
......
...@@ -13,10 +13,9 @@ from django import forms ...@@ -13,10 +13,9 @@ from django import forms
from squarepay.models import MembershipPayment from squarepay.models import MembershipPayment
from squarepay.dispense import get_item_price from squarepay.dispense import get_item_price
from .models import Member, Membership, get_membership_choices, MEMBERSHIP_TYPES from .models import Member, Membership, get_membership_choices, make_pending_membership, MEMBERSHIP_TYPES
from .forms import MyModelForm from .forms import MyModelForm
from .views import MyUpdateView from .views import MyUpdateView
from .approve import make_pending_membership
""" """
First step: enter an email address and some details (to fill at least a Member model) to create a pending membership. First step: enter an email address and some details (to fill at least a Member model) to create a pending membership.
......
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