From 597e54c0c302bebc92fcf05927515f0e5c514dba Mon Sep 17 00:00:00 2001 From: Cole Stowell Date: Sun, 12 Oct 2025 14:58:13 -0400 Subject: [PATCH 01/12] Revert "packet glue (#407)" This reverts commit 2b4bc44bdb35b70601ef23a85ecdc880e3a4efb8. --- conditional/blueprints/packet.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/conditional/blueprints/packet.py b/conditional/blueprints/packet.py index 3a2a533..2b40f78 100644 --- a/conditional/blueprints/packet.py +++ b/conditional/blueprints/packet.py @@ -435,9 +435,3 @@ def csh_login(): def frosh_login(): session["provider"] = "frosh" return redirect("/packet", code=301) - - -@packet_bp.route("/logout") -@auth.oidc_logout -def logout(): - return redirect("/", 302) From 77f7d0ea2d9d29e2fff644f1e5d4314599738582 Mon Sep 17 00:00:00 2001 From: Cole Stowell Date: Sun, 12 Oct 2025 14:58:13 -0400 Subject: [PATCH 02/12] Revert "chom (#406)" This reverts commit 8a6b501de722381664ae2fa2dd21a16930a05192. --- conditional/util/context_processors.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/conditional/util/context_processors.py b/conditional/util/context_processors.py index 58adfda..b26492f 100644 --- a/conditional/util/context_processors.py +++ b/conditional/util/context_processors.py @@ -1,8 +1,5 @@ # pylint: disable=bare-except -import hashlib -import urllib - from conditional import app from conditional.models.models import FreshmanAccount from conditional.util.cache import service_cache @@ -34,31 +31,11 @@ def check_current_student(username): return ldap_is_current_student(member) -@service_cache(maxsize=256) -def get_rit_image(username: str) -> str: - if username: - addresses = [username + "@rit.edu", username + "@g.rit.edu"] - for addr in addresses: - url = ( - "https://gravatar.com/avatar/" - + hashlib.md5(addr.encode("utf8")).hexdigest() - + ".jpg?d=404&s=250" - ) - try: - with urllib.request.urlopen(url) as gravatar: - if gravatar.getcode() == 200: - return url - except: - continue - return "https://www.gravatar.com/avatar/freshmen?d=mp&f=y" - - @app.context_processor def utility_processor(): return { "get_csh_name": get_csh_name, "get_freshman_name": get_freshman_name, - "get_rit_image": get_rit_image, "get_member_name": get_member_name, "check_current_student": check_current_student, } From 446106a99ac8e2f98573814bb88285ab769f40b6 Mon Sep 17 00:00:00 2001 From: Cole Stowell Date: Sun, 12 Oct 2025 14:58:13 -0400 Subject: [PATCH 03/12] Revert "chom (#405)" This reverts commit a904044400cf5afc3a13944f99311b53a08a7681. --- conditional/util/context_processors.py | 91 +++++++++++++++++- conditional/util/packet_context_processors.py | 92 ------------------- 2 files changed, 89 insertions(+), 94 deletions(-) delete mode 100644 conditional/util/packet_context_processors.py diff --git a/conditional/util/context_processors.py b/conditional/util/context_processors.py index b26492f..28971a2 100644 --- a/conditional/util/context_processors.py +++ b/conditional/util/context_processors.py @@ -1,7 +1,13 @@ # pylint: disable=bare-except -from conditional import app -from conditional.models.models import FreshmanAccount +import hashlib +import urllib +from functools import lru_cache +from datetime import datetime +from typing import Callable + +from conditional import app, packet_bp +from conditional.models.models import FreshmanAccount, Freshman, UpperSignature from conditional.util.cache import service_cache from conditional.util.ldap import ldap_get_member, ldap_is_current_student @@ -39,3 +45,84 @@ def utility_processor(): "get_member_name": get_member_name, "check_current_student": check_current_student, } + + +# pylint: disable=bare-except +@lru_cache(maxsize=128) +def packet_get_csh_name(username: str) -> str: + try: + member = ldap_get_member(username) + return member.cn + " (" + member.uid + ")" + except: + return username + + +def get_roles(sig: UpperSignature) -> dict[str, str]: + """ + Converts a signature's role fields to a dict for ease of access. + :return: A dictionary of role short names to role long names + """ + out = {} + if sig.eboard: + out["eboard"] = sig.eboard + if sig.active_rtp: + out["rtp"] = "RTP" + if sig.three_da: + out["three_da"] = "3DA" + if sig.w_m: + out["wm"] = "Wiki Maintainer" + if sig.webmaster: + out["webmaster"] = "Webmaster" + if sig.c_m: + out["cm"] = "Constitutional Maintainer" + if sig.drink_admin: + out["drink"] = "Drink Admin" + return out + + +# pylint: disable=bare-except +@lru_cache(maxsize=256) +def get_rit_name(username: str) -> str: + try: + freshman = Freshman.query.filter_by(rit_username=username).first() + return freshman.name + " (" + username + ")" + except: + return username + + +# pylint: disable=bare-except +@lru_cache(maxsize=256) +def get_rit_image(username: str) -> str: + if username: + addresses = [username + "@rit.edu", username + "@g.rit.edu"] + for addr in addresses: + url = ( + "https://gravatar.com/avatar/" + + hashlib.md5(addr.encode("utf8")).hexdigest() + + ".jpg?d=404&s=250" + ) + try: + with urllib.request.urlopen(url) as gravatar: + if gravatar.getcode() == 200: + return url + except: + continue + return "https://www.gravatar.com/avatar/freshmen?d=mp&f=y" + + +def log_time(label: str) -> None: + """ + Used during debugging to log timestamps while rendering templates + """ + print(label, datetime.now()) + + +@packet_bp.context_processor +def packet_utility_processor() -> dict[str, Callable]: + return { + "get_csh_name": packet_get_csh_name, + "get_rit_name": get_rit_name, + "get_rit_image": get_rit_image, + "log_time": log_time, + "get_roles": get_roles, + } diff --git a/conditional/util/packet_context_processors.py b/conditional/util/packet_context_processors.py deleted file mode 100644 index 7c8d235..0000000 --- a/conditional/util/packet_context_processors.py +++ /dev/null @@ -1,92 +0,0 @@ -# pylint: disable=bare-except - -import hashlib -import urllib -from functools import lru_cache -from datetime import datetime -from typing import Callable - -from conditional import packet_bp -from conditional.models.models import Freshman, UpperSignature -from conditional.util.ldap import ldap_get_member - - -# pylint: disable=bare-except -@lru_cache(maxsize=128) -def packet_get_csh_name(username: str) -> str: - try: - member = ldap_get_member(username) - return member.cn + " (" + member.uid + ")" - except: - return username - - -def get_roles(sig: UpperSignature) -> dict[str, str]: - """ - Converts a signature's role fields to a dict for ease of access. - :return: A dictionary of role short names to role long names - """ - out = {} - if sig.eboard: - out["eboard"] = sig.eboard - if sig.active_rtp: - out["rtp"] = "RTP" - if sig.three_da: - out["three_da"] = "3DA" - if sig.w_m: - out["wm"] = "Wiki Maintainer" - if sig.webmaster: - out["webmaster"] = "Webmaster" - if sig.c_m: - out["cm"] = "Constitutional Maintainer" - if sig.drink_admin: - out["drink"] = "Drink Admin" - return out - - -# pylint: disable=bare-except -@lru_cache(maxsize=256) -def get_rit_name(username: str) -> str: - try: - freshman = Freshman.query.filter_by(rit_username=username).first() - return freshman.name + " (" + username + ")" - except: - return username - - -# pylint: disable=bare-except -@lru_cache(maxsize=256) -def get_rit_image(username: str) -> str: - if username: - addresses = [username + "@rit.edu", username + "@g.rit.edu"] - for addr in addresses: - url = ( - "https://gravatar.com/avatar/" - + hashlib.md5(addr.encode("utf8")).hexdigest() - + ".jpg?d=404&s=250" - ) - try: - with urllib.request.urlopen(url) as gravatar: - if gravatar.getcode() == 200: - return url - except: - continue - return "https://www.gravatar.com/avatar/freshmen?d=mp&f=y" - - -def log_time(label: str) -> None: - """ - Used during debugging to log timestamps while rendering templates - """ - print(label, datetime.now()) - - -@packet_bp.context_processor -def packet_utility_processor() -> dict[str, Callable]: - return { - "get_csh_name": packet_get_csh_name, - "get_rit_name": get_rit_name, - "get_rit_image": get_rit_image, - "log_time": log_time, - "get_roles": get_roles, - } From de35e725c2e072ffd4c3d89674112149d5e2ee3f Mon Sep 17 00:00:00 2001 From: Cole Stowell Date: Sun, 12 Oct 2025 14:58:13 -0400 Subject: [PATCH 04/12] Revert "packet glue (#404)" This reverts commit ee6fc4113ff316e33778122d44db7156e85552ef. --- conditional/util/context_processors.py | 101 ++----------------------- 1 file changed, 7 insertions(+), 94 deletions(-) diff --git a/conditional/util/context_processors.py b/conditional/util/context_processors.py index 28971a2..766e4d8 100644 --- a/conditional/util/context_processors.py +++ b/conditional/util/context_processors.py @@ -1,13 +1,7 @@ # pylint: disable=bare-except -import hashlib -import urllib -from functools import lru_cache -from datetime import datetime -from typing import Callable - -from conditional import app, packet_bp -from conditional.models.models import FreshmanAccount, Freshman, UpperSignature +from conditional import app +from conditional.models.models import FreshmanAccount from conditional.util.cache import service_cache from conditional.util.ldap import ldap_get_member, ldap_is_current_student @@ -40,89 +34,8 @@ def check_current_student(username): @app.context_processor def utility_processor(): return { - "get_csh_name": get_csh_name, - "get_freshman_name": get_freshman_name, - "get_member_name": get_member_name, - "check_current_student": check_current_student, - } - - -# pylint: disable=bare-except -@lru_cache(maxsize=128) -def packet_get_csh_name(username: str) -> str: - try: - member = ldap_get_member(username) - return member.cn + " (" + member.uid + ")" - except: - return username - - -def get_roles(sig: UpperSignature) -> dict[str, str]: - """ - Converts a signature's role fields to a dict for ease of access. - :return: A dictionary of role short names to role long names - """ - out = {} - if sig.eboard: - out["eboard"] = sig.eboard - if sig.active_rtp: - out["rtp"] = "RTP" - if sig.three_da: - out["three_da"] = "3DA" - if sig.w_m: - out["wm"] = "Wiki Maintainer" - if sig.webmaster: - out["webmaster"] = "Webmaster" - if sig.c_m: - out["cm"] = "Constitutional Maintainer" - if sig.drink_admin: - out["drink"] = "Drink Admin" - return out - - -# pylint: disable=bare-except -@lru_cache(maxsize=256) -def get_rit_name(username: str) -> str: - try: - freshman = Freshman.query.filter_by(rit_username=username).first() - return freshman.name + " (" + username + ")" - except: - return username - - -# pylint: disable=bare-except -@lru_cache(maxsize=256) -def get_rit_image(username: str) -> str: - if username: - addresses = [username + "@rit.edu", username + "@g.rit.edu"] - for addr in addresses: - url = ( - "https://gravatar.com/avatar/" - + hashlib.md5(addr.encode("utf8")).hexdigest() - + ".jpg?d=404&s=250" - ) - try: - with urllib.request.urlopen(url) as gravatar: - if gravatar.getcode() == 200: - return url - except: - continue - return "https://www.gravatar.com/avatar/freshmen?d=mp&f=y" - - -def log_time(label: str) -> None: - """ - Used during debugging to log timestamps while rendering templates - """ - print(label, datetime.now()) - - -@packet_bp.context_processor -def packet_utility_processor() -> dict[str, Callable]: - return { - "get_csh_name": packet_get_csh_name, - "get_rit_name": get_rit_name, - "get_rit_image": get_rit_image, - "log_time": log_time, - "get_roles": get_roles, - } + "get_csh_name": get_csh_name, + "get_freshman_name": get_freshman_name, + "get_member_name": get_member_name, + "check_current_student": check_current_student + } From b7139a7a813b6f0ceb6a04fed34f1f544cd2e944 Mon Sep 17 00:00:00 2001 From: Cole Stowell Date: Sun, 12 Oct 2025 14:58:13 -0400 Subject: [PATCH 05/12] Revert "migration, url fixes (#403)" This reverts commit 736d203a2646928ed3ee0e9ced395526cfaeaf72. --- conditional/templates/include/nav.html | 12 +-- .../versions/27b8305621f5_add_packet.py | 94 ------------------- 2 files changed, 6 insertions(+), 100 deletions(-) delete mode 100644 migrations/versions/27b8305621f5_add_packet.py diff --git a/conditional/templates/include/nav.html b/conditional/templates/include/nav.html index 6c03562..6573b8b 100644 --- a/conditional/templates/include/nav.html +++ b/conditional/templates/include/nav.html @@ -1,6 +1,6 @@