unsubscribe from csc general when shadow expiring member, and resubscribe when renewed

Rio Liu 11 months ago
parent 19496b4568
commit b939eab1e1
  1. 15
      ceod/api/members.py

@ -92,14 +92,22 @@ def renew_user(username: str):
g.need_admin_creds = True
ldap_srv = component.getUtility(ILDAPService)
cfg = component.getUtility(IConfig)
user = ldap_srv.get_user(username)
member_list = cfg.get('mailman3_new_member_list')
def unexpire(user):
if user.shadowExpire:
user.set_expired(False)
user.subscribe_to_mailing_list(member_list)
if body.get('terms'):
user.add_terms(body['terms'])
user.set_expired(False)
unexpire(user)
return {'terms_added': body['terms']}
elif body.get('non_member_terms'):
user.add_non_member_terms(body['non_member_terms'])
user.set_expired(False)
unexpire(user)
return {'non_member_terms_added': body['non_member_terms']}
else:
raise BadRequest('Must specify either terms or non-member terms')
@ -129,10 +137,13 @@ def expire_users():
dry_run = is_truthy(request.args.get('dry_run', 'false'))
ldap_srv = component.getUtility(ILDAPService)
cfg = component.getUtility(IConfig)
members = ldap_srv.get_expiring_users()
member_list = cfg.get('mailman3_new_member_list')
if not dry_run:
for member in members:
member.set_expired(True)
member.unsubscribe_from_mailing_list(member_list)
return json.jsonify([member.uid for member in members])

Loading…
Cancel
Save