Distinguish between Paused and Expired members

This commit is contained in:
Tanner Collin 2022-12-16 19:18:45 +00:00
parent 1de7706216
commit db9bd91f97
4 changed files with 45 additions and 4 deletions

View File

@ -70,7 +70,7 @@ def calc_member_status(expire_date, fake_date=None):
if today + timedelta(days=29) < expire_date:
return 'Prepaid'
elif difference <= -3:
return 'Former Member'
return 'Expired Member'
elif today - timedelta(days=29) >= expire_date:
return 'Overdue'
elif today < expire_date:
@ -107,8 +107,11 @@ def tally_membership_months(member, fake_date=None):
member.expire_date = expire_date
member.status = status
if status == 'Former Member':
member.paused_date = expire_date
if status == 'Expired Member':
member.paused_date = today_alberta_tz()
msg = 'Member has expired: {} {}'.format(member.preferred_name, member.last_name)
alert_tanner(msg)
logger.info(msg)
member.save()
logging.debug('Tallied %s membership months: updated.', member)

View File

@ -183,9 +183,13 @@ class MemberViewSet(Base, Retrieve, Update):
if not is_admin_director(self.request.user):
raise exceptions.PermissionDenied()
member = self.get_object()
member.status = 'Former Member'
member.status = 'Paused Member'
member.paused_date = utils.today_alberta_tz()
member.save()
msg = 'Member has been paused: {} {}'.format(member.preferred_name, member.last_name)
utils.alert_tanner(msg)
logger.info(msg)
return Response(200)
@action(detail=True, methods=['post'])

View File

@ -0,0 +1,32 @@
# will not work after expired date change
# =======================================
import django, sys, os
os.environ['DJANGO_SETTINGS_MODULE'] = 'apiserver.settings'
django.setup()
from dateutil import relativedelta
from apiserver.api import models
members = models.Member.objects.all()
count = 0
for m in members:
if m.paused_date and m.status == 'Former Member':
print('Former member', m.preferred_name, m.last_name)
if m.paused_date == m.expire_date:
new_status = 'Expired Member'
new_paused_date = m.paused_date + relativedelta.relativedelta(months=3)
print(' Moving paused date', m.paused_date, '-->', new_paused_date)
m.paused_date = new_paused_date
else:
new_status = 'Paused Member'
print(' Setting status to', new_status)
m.status = new_status
count += 1
m.save()
print('Processed', count)

View File

@ -30,6 +30,8 @@ export const statusColor = {
'Due': 'yellow',
'Overdue': 'red',
'Former Member': 'black',
'Paused Member': 'black',
'Expired Member': 'black',
};
export const BasicTable = (props) => (