From 26cd4ecf3fdb718bd879c66c346c2f5fe87e3c09 Mon Sep 17 00:00:00 2001 From: Zack Wong <coffee@ucc.gu.uwa.edu.au> Date: Sun, 3 Feb 2019 13:30:22 +0800 Subject: [PATCH] more changes to account creation --- src/account/actions.py | 18 +++++++++++++++++- src/gms/settings.py | 3 +++ src/memberdb/models.py | 7 +++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/account/actions.py b/src/account/actions.py index eb0dda4..c4a7382 100644 --- a/src/account/actions.py +++ b/src/account/actions.py @@ -5,6 +5,7 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured import ldap +import re import memberdb.models from datetime import date from squarepay import dispense @@ -100,10 +101,25 @@ def unlock_account(username): reason = "account unlocked by uccportal on %s" % str(today) dispense.set_dispense_flag(username, '!disabled', reason) - +# Account creation steps: +# def create_account(member): + username = + log.info("I: creating new account for %s (%s %s)") + + # prepend student numbers with 'sn' + if re.fullmatch(r"^2\d{7}$", username): + log.info("I: username is a student number, adding sn prefix") + username = sn + username + + # usernames can't begin with a numeric + if re.match(r"^\d", username): + log.error("E: The username %s cannot start with a digit." % username) + return; + + return None; diff --git a/src/gms/settings.py b/src/gms/settings.py index 63a7f9d..935e805 100644 --- a/src/gms/settings.py +++ b/src/gms/settings.py @@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ # import local settings from gms.settings_local import * +# DEBUG ALLOW +ALLOWED_HOSTS = ['127.0.0.1', 'localhost', "130.95.13.36"] + # Application definition INSTALLED_APPS = ( diff --git a/src/memberdb/models.py b/src/memberdb/models.py index cfb8f33..d5ba6f1 100644 --- a/src/memberdb/models.py +++ b/src/memberdb/models.py @@ -110,6 +110,11 @@ PAYMENT_METHODS = [ ('', 'No payment') ] +ACCOUNT_STATUS = [ + 'enabled', + 'disabled', + 'no account' + ] @@ -157,8 +162,6 @@ class Member (IncAssocMember): # account info def get_account_status(self): - - return; def __str__ (self): -- GitLab