Skip to content

Commit

Permalink
Merge pull request #716 from uw-it-aca/bug/office-eligibility-test
Browse files Browse the repository at this point in the history
positive active subscription test, add 0365 student to set of office …
  • Loading branch information
mikeseibel authored Nov 14, 2024
2 parents fbcdc32 + 0bdf3bd commit 4a21cd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
17 changes: 13 additions & 4 deletions endorsement/dao/office.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@
def is_office_permitted(netid):
"""
test for office mailbox availability
NOTE: test both o365 and o365student services
"""
o365 = get_endorsement_service('o365')
endorsee = get_endorsee_model(netid)
for er in EndorsementRecord.objects.get_endorsements_for_endorsee(
endorsee, o365.category_code):
o365 = get_endorsement_service('o365')
o365_student = get_endorsement_service('o365student')

records = EndorsementRecord.objects.get_endorsements_for_endorsee(
endorsee, o365.category_code) |\
EndorsementRecord.objects.get_endorsements_for_endorsee(
endorsee, o365_student.category_code)

for er in records:
if er.datetime_endorsed and not er.datetime_expired:
return True

# if no endorsement record, check subscription_codes
try:
return active_subscriptions_for_netid(netid, o365.subscription_codes)
subscription_codes = list(set(
o365.subscription_codes + o365_student.subscription_codes))
return active_subscriptions_for_netid(netid, subscription_codes)
except Exception as ex:
logger.error("is_office_permitted: {}: {}".format(netid, ex))
pass
Expand Down
9 changes: 6 additions & 3 deletions endorsement/dao/uwnetid_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ def active_subscriptions_for_netid(netid, subscription_codes):
response = get_netid_subscriptions(netid, subscription_codes)
for sub in response:
if (sub.subscription_code in subscription_codes and
sub.status_code != Subscription.STATUS_UNPERMITTED):
subscription_codes.remove(sub.subscription_code)
return len(subscription_codes) == 0
sub.status_code in [
Subscription.STATUS_ACTIVE,
Subscription.STATUS_PENDING]):
return True

return False


def activate_subscriptions(endorsee_netid, endorser_netid, subscriptions):
Expand Down

0 comments on commit 4a21cd9

Please sign in to comment.