From 65248105fb9847b238121ac7ceb6c86c7c171d71 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Sat, 1 Oct 2022 11:16:46 -0400 Subject: [PATCH 1/2] Automatically add 2 housing points when passing Spring Evals --- conditional/blueprints/slideshow.py | 3 ++- conditional/util/ldap.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conditional/blueprints/slideshow.py b/conditional/blueprints/slideshow.py index c745e24c..6d21b76c 100644 --- a/conditional/blueprints/slideshow.py +++ b/conditional/blueprints/slideshow.py @@ -12,7 +12,7 @@ from conditional.util.auth import get_user from conditional.util.flask import render_template from conditional.util.ldap import ldap_is_eval_director, ldap_is_intromember, ldap_set_failed, ldap_set_bad_standing, \ - ldap_set_inactive, ldap_get_member, ldap_set_not_intro_member + ldap_set_inactive, ldap_get_member, ldap_set_not_intro_member, ldap_get_housingpoints, ldap_set_housingpoints logger = structlog.get_logger() @@ -136,6 +136,7 @@ def slideshow_spring_review(user_dict=None): if status == "Passed": if ldap_is_intromember(account): ldap_set_not_intro_member(account) + ldap_set_housingpoints(account, ldap_get_housingpoints(account) + 2) elif status == "Failed": if ldap_is_intromember(account): ldap_set_failed(account) diff --git a/conditional/util/ldap.py b/conditional/util/ldap.py index 98cb8531..6f1ce211 100644 --- a/conditional/util/ldap.py +++ b/conditional/util/ldap.py @@ -117,6 +117,12 @@ def ldap_is_current_student(account): return _ldap_is_member_of_group(account, 'current_student') +def ldap_get_housingpoints(account): + try: + return account.housingPoints + except AttributeError: + return 0 + def ldap_set_housingpoints(account, housing_points): account.housingPoints = housing_points ldap_get_current_students.cache_clear() From de9731d9545cbed3c2fd45e59cf66f1aaec91683 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Mon, 3 Oct 2022 12:06:30 -0400 Subject: [PATCH 2/2] Clear member cache when getting housing points If housing points are edited manually the cache may be out of date so we should make sure it isn't, as these are important to have correct before reading --- conditional/util/ldap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conditional/util/ldap.py b/conditional/util/ldap.py index 6f1ce211..6bd1ecd6 100644 --- a/conditional/util/ldap.py +++ b/conditional/util/ldap.py @@ -118,6 +118,8 @@ def ldap_is_current_student(account): def ldap_get_housingpoints(account): + ldap_get_current_students.cache_clear() + ldap_get_member.cache_clear() try: return account.housingPoints except AttributeError: