diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-23 23:38:06 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-23 23:38:06 +0000 |
commit | a5d0ad3e4f92147ea07a13e236389914ab4a57b7 (patch) | |
tree | 6b6cb4e23aecdd90da9c2f09b8ab730dab6de380 /parsers | |
parent | f842dab12a8bd807a0bb61a6eb35600b789564b0 (diff) | |
download | troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.tar.gz troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.tar.bz2 troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.zip |
New User registration form
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/people.py | 7 | ||||
-rw-r--r-- | parsers/users.py | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/parsers/people.py b/parsers/people.py index 96bda41..4a4512c 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -79,7 +79,8 @@ def troggle_slugify(longname): slug = slug.replace('ä', 'a') slug = slug.replace('&', '') # otherwise just remove the & slug = slug.replace(';', '') # otherwise just remove the ; - slug = re.sub(r'<[^>]*>','',slug) # remove <span-lang = "hu"> + slug = slug.replace("'", "") # otherwise just remove the ', no O'Reilly problem # NEW + slug = re.sub(r'<[^>]*>','',slug) # remove <span-lang = "hu"> and any HTML tags slug=slug.strip("-") # remove spare hyphens if len(slug) > 40: # slugfield is 50 chars @@ -120,9 +121,11 @@ def load_people_expos(): e = Expedition.objects.create(**otherAttribs, **coUniqueAttribs) print(" - Loading personexpeditions") - + for personline in personreader: # This is all horrible: refactor it. + # CSV: Name,Lastname,Guest,VfHO member,Mugshot,.. + # e.g: Olly Betts (Ol),Betts,,,l/ollybetts.htm, name = personline[header["Name"]] plainname = re.sub(r"<.*?>", "", name) # now in slugify diff --git a/parsers/users.py b/parsers/users.py index fe11bdf..cf721ba 100644 --- a/parsers/users.py +++ b/parsers/users.py @@ -25,20 +25,25 @@ todo = """ USERS_FILE = "users.json" ENCRYPTED_DIR = "encrypted" -def register_user(u, email, password=None, pwhash=None): +def register_user(u, email, password=None, pwhash=None, fullname=None): + """Create User and we may not have a Person to tie it to if it is a future caver. + Do not use the lastname field, put the whole free text identification into firstname + as this saves hassle and works with Wookey too + """ try: if existing_user := User.objects.filter(username=u): # WALRUS print(f" - deleting existing user '{existing_user[0]}' before importing") existing_user[0].delete() - user = User.objects.create_user(u, email) + user = User.objects.create_user(u, email, first_name=fullname) if pwhash: user.password = pwhash elif password: user.set_password(password) # function creates hash and stores hash print(f" # hashing provided clear-text password {password} to make pwhash for user {u}") else: - user.set_password('secret') # function creates hash and stores hash - print(f" # hashing 'secret' password to make pwhash for user {u}") + # user.set_password(None) # use Django special setting for invalid password, but then FAILS to send password reset email + user.set_password("secret") # Why is the Django logic broken. Hmph. + print(f" # setting INVALID password for user {u}, must be reset by password_reset") user.is_staff = False user.is_superuser = False user.save() |