diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-24 02:33:42 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-24 02:33:42 +0000 |
commit | fedcc6d201df8a474105ee1032430e9fbd401b11 (patch) | |
tree | 153e881731cdba88ba1f935a8989adb53212ff3f /parsers | |
parent | 61722fd6c065f491770568eb0aad57194ce13d61 (diff) | |
download | troggle-fedcc6d201df8a474105ee1032430e9fbd401b11.tar.gz troggle-fedcc6d201df8a474105ee1032430e9fbd401b11.tar.bz2 troggle-fedcc6d201df8a474105ee1032430e9fbd401b11.zip |
whack a mole
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/people.py | 10 | ||||
-rw-r--r-- | parsers/users.py | 10 |
2 files changed, 17 insertions, 3 deletions
diff --git a/parsers/people.py b/parsers/people.py index 4a4512c..18b73f9 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -175,8 +175,18 @@ def load_people_expos(): # otherAttribs = {"is_guest": (personline[header["Guest"]] == "1")} pe = PersonExpedition.objects.create(**coUniqueAttribs) print("", flush=True) + ensure_users_are_persons() +def ensure_users_are_persons(): + # Just ensure this is up to date. + users = User.objects.all() + for u in users: + ps = Person.objects.filter(slug=u.username) + if len(ps) >= 1: + p = ps[0] + p.user = u + def who_is_this(year, possibleid): expo = Expedition.objects.filter(year=year) personexpedition = GetPersonExpeditionNameLookup(expo)[possibleid.lower()] diff --git a/parsers/users.py b/parsers/users.py index cf721ba..0501525 100644 --- a/parsers/users.py +++ b/parsers/users.py @@ -25,11 +25,12 @@ todo = """ USERS_FILE = "users.json" ENCRYPTED_DIR = "encrypted" -def register_user(u, email, password=None, pwhash=None, fullname=None): +def register_user(u, email, password=None, pwhash=None, fullname=""): """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 """ + print(f" - {u} {fullname=}") try: if existing_user := User.objects.filter(username=u): # WALRUS print(f" - deleting existing user '{existing_user[0]}' before importing") @@ -49,7 +50,8 @@ def register_user(u, email, password=None, pwhash=None, fullname=None): user.save() print(f" - receated and reset user '{user}'") except Exception as e: - print(f"Exception <{e}>\n{len(User.objects.all())} users now in db:\n{User.objects.all()}") + print(f"Exception <{e}>") + print(f"{len(User.objects.all())} users now in db:\n{User.objects.all()}") raise expoers = Person.objects.filter(slug=u) @@ -98,6 +100,7 @@ def load_users(): users_list = registered_users_dict["registered_users"] print(f" - {len(users_list)} users read from JSON") + print(f"-- Registering users in database") for userdata in users_list: if not userdata["username"]: message = f"! user: BAD username for {userdata} in {jsonfile}" @@ -105,6 +108,7 @@ def load_users(): DataIssue.objects.update_or_create(parser=PARSER_USERS, message=message, url=jsonurl) continue else: + print(f" - {userdata["username"]=}") if userdata["username"] in [ "expo", "expoadmin" ]: continue if "encrypted" not in userdata: @@ -114,7 +118,7 @@ def load_users(): email = userdata["email"] if userdata["encrypted"]: email = f.decrypt(email).decode() - print(f" - user: '{u} <{email}>' ") + print(f" - user: '{u} <{email}>' (decrypted)") except Exception as e: print(f"Exception <{e}>\n") formatted_json = json.dumps(userdata, indent=4) |