forked from CMS/memberPlumbing
Merge branch 'master' of https://git.claremontmakerspace.org/adam.goldsmith/memberPlumbing
This commit is contained in:
commit
2732c788c4
@ -22,6 +22,12 @@ def do_import(config):
|
|||||||
]
|
]
|
||||||
).on_conflict(action="update", preserve=[Flag.name, Flag.type]).execute()
|
).on_conflict(action="update", preserve=[Flag.name, Flag.type]).execute()
|
||||||
|
|
||||||
|
print("Getting folder membership...")
|
||||||
|
folders = {
|
||||||
|
folder_id: membershipworks.get_member_ids([folder_name])
|
||||||
|
for folder_name, folder_id in membershipworks._parse_flags()["folders"].items()
|
||||||
|
}
|
||||||
|
|
||||||
print("Getting/Updating members...")
|
print("Getting/Updating members...")
|
||||||
members = membershipworks.get_all_members()
|
members = membershipworks.get_all_members()
|
||||||
for m in members:
|
for m in members:
|
||||||
@ -44,13 +50,14 @@ def do_import(config):
|
|||||||
|
|
||||||
# update member's flags
|
# update member's flags
|
||||||
for type, flags in membershipworks._parse_flags().items():
|
for type, flags in membershipworks._parse_flags().items():
|
||||||
if type != "folders": # currently no way to retrieve this info
|
for flag, id in flags.items():
|
||||||
for flag, id in flags.items():
|
ml = MemberFlag(uid=member["Account ID"], flag_id=id)
|
||||||
ml = MemberFlag(uid=member["Account ID"], flag_id=id)
|
if (type == "folders" and member["Account ID"] in folders[id]) or (
|
||||||
if member[flag]:
|
type != "folders" and member[flag]
|
||||||
ml.magic_save()
|
):
|
||||||
else:
|
ml.magic_save()
|
||||||
ml.delete_instance()
|
else:
|
||||||
|
ml.delete_instance()
|
||||||
|
|
||||||
print("Getting/Updating transactions...")
|
print("Getting/Updating transactions...")
|
||||||
# Deduping these is hard, so just recreate the data every time
|
# Deduping these is hard, so just recreate the data every time
|
||||||
|
@ -29,7 +29,7 @@ def sanitize_group_name(name):
|
|||||||
|
|
||||||
# From an API error message: "Username must only contain numbers, letters and dots!"
|
# From an API error message: "Username must only contain numbers, letters and dots!"
|
||||||
def sanitize_user_name(name):
|
def sanitize_user_name(name):
|
||||||
return re.sub(r"[^0-9a-z.]", ".", name.lower())
|
return re.sub(r"[^0-9a-z.]", ".", name.lower()).strip(".")
|
||||||
|
|
||||||
|
|
||||||
async def make_groups(group_mod, members):
|
async def make_groups(group_mod, members):
|
||||||
|
Loading…
Reference in New Issue
Block a user