Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions discourseUpdateGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,24 @@ def updateTypes(neonAccounts: dict):
instructorsMembers = set()
wikiAdmins = set()

for account in neonAccounts:
if neonAccounts[account].get("DiscourseID") is None or neonAccounts[account].get("DiscourseID") == "":
if neonUtil.accountIsAnyType(neonAccounts[account]):
logging.warning(f'''{neonAccounts[account]["First Name"]} {neonAccounts[account]["Last Name"]} ({neonAccounts[account]["Account ID"]}) is interesting but has no Discourse ID''')
for account in neonAccounts.values():
dID = account.get("DiscourseID")
if not dID:
if neonUtil.accountIsAnyType(account):
logging.warning(f'{account["First Name"]} {account["Last Name"]} ({account["Account ID"]}) has type {account.get("Individual Type")} but no Discourse ID')
continue

if neonUtil.accountIsType(neonAccounts[account], neonUtil.LEAD_TYPE) or neonUtil.accountIsType(neonAccounts[account], neonUtil.DIRECTOR_TYPE):
leadershipMembers.add(neonAccounts[account].get("DiscourseID"))
if neonUtil.accountIsType(account, neonUtil.LEAD_TYPE) or neonUtil.accountIsType(account, neonUtil.DIRECTOR_TYPE):
leadershipMembers.add(dID)

if neonUtil.accountIsType(neonAccounts[account], neonUtil.STEWARD_TYPE) or neonUtil.accountIsType(neonAccounts[account], neonUtil.SUPER_TYPE):
stewardsMembers.add(neonAccounts[account].get("DiscourseID"))
if neonUtil.accountIsType(account, neonUtil.STEWARD_TYPE) or neonUtil.accountIsType(account, neonUtil.SUPER_TYPE):
stewardsMembers.add(dID)

if neonUtil.accountIsType(neonAccounts[account], neonUtil.INSTRUCTOR_TYPE):
instructorsMembers.add(neonAccounts[account].get("DiscourseID"))
if neonUtil.accountIsType(account, neonUtil.INSTRUCTOR_TYPE):
instructorsMembers.add(dID)

if neonUtil.accountIsType(neonAccounts[account], neonUtil.WIKI_ADMIN_TYPE):
wikiAdmins.add(neonAccounts[account].get("DiscourseID"))
if neonUtil.accountIsType(account, neonUtil.WIKI_ADMIN_TYPE):
wikiAdmins.add(dID)

#Discourse is annoying about primary groups - there's no way to set a heirarchy; it's last-one-sticks
#Update the "highest rank" group last so users new to multiple groups wind up with the highest title
Expand Down
14 changes: 8 additions & 6 deletions openPathUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
GROUP_DOMINO = 96643
GROUP_ONDUTY = 507223
GROUP_CERAMICS_ONDUTY = 730657
GROUP_SPECIAL_EVENT = 119566

def isManagedGroup(group: int):
if (
Expand Down Expand Up @@ -307,12 +308,13 @@ def updateGroups(neonAccount, openPathGroups=None, email=False):

# prevent specialty groups from being clobbered
if not isManagedGroup(id):
logging.info(
"%s (%s) has unmanaged OpenPath Group ID %s",
neonAccount.get("fullName"),
neonAccount.get("Email 1"),
id,
)
if id != GROUP_SPECIAL_EVENT:
logging.info(
"%s (%s) has unmanaged OpenPath Group ID %s",
neonAccount.get("fullName"),
neonAccount.get("Email 1"),
id,
)
neonOpGroups.append(id)

logging.debug(
Expand Down
Loading