Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ PURCHASE_MEMBERSHIP_URL=[Replace with your group\'s purchase=membership URL]
# One of: DEBUG, INFO, WARNING, ERROR, CRITICAL
CONSOLE_LOG_LEVEL=INFO

# !!REQUIRED!!
# The base URL for your organization's membership system
# Must be a valid URL base (without trailing slash). For example, if your members-list is found on the UoB Guild of Students website, the base URL is https://guildofstudents.com
MEMBERS_LIST_BASE_URL=[Replace with your organization\'s membership system base URL]

# !!REQUIRED!!
# The URL to retrieve the list of IDs of people that have purchased a membership to your community group
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ Error logs will **always** be sent to the [console](https://wikipedia.org/wiki/T

* `ORGANISATION_ID`: Your Guild society ID. This is used to dynamically create the members list among other needed URLs.

* `MEMBERS_LIST_BASE_URL`: The base URL for your organization's membership system (without trailing slash). For example, if your members-list is found on the UoB Guild of Students website, the base URL is https://guildofstudents.com

* `MEMBERS_LIST_URL_SESSION_COOKIE`: The members-list [URL](https://wikipedia.org/wiki/URL) [session cookie](https://wikipedia.org/wiki/HTTP_cookie#Session_cookie).
(If your group's members-list is stored at a [URL](https://wikipedia.org/wiki/URL) that requires [authentication](https://wikipedia.org/wiki/Authentication), this [session cookie](https://wikipedia.org/wiki/HTTP_cookie#Session_cookie) should [authenticate](https://wikipedia.org/wiki/Authentication) TeX-Bot to view your group's members-list, as if it were [logged in to the website](https://wikipedia.org/wiki/Login_session) as a Committee member.
This can be [extracted from your web-browser](https://wikihow.com/View-Cookies), after logging in to view your members-list yourself.
Expand Down
5 changes: 3 additions & 2 deletions cogs/make_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@

ORGANISATION_ID: "Final[str]" = settings["ORGANISATION_ID"]
GROUP_NAME: "Final[str]" = settings["_GROUP_FULL_NAME"]
MEMBERS_LIST_BASE_URL: "Final[str]" = settings["MEMBERS_LIST_BASE_URL"]
GROUPED_MEMBRS_URL: "Final[str]" = (
f"https://guildofstudents.com/organisation/memberlist/{ORGANISATION_ID}/?sort=groups"
f"{MEMBERS_LIST_BASE_URL}/organisation/memberlist/{ORGANISATION_ID}/?sort=groups"
)
BASE_MEMBERS_URL: "Final[str]" = (
f"https://guildofstudents.com/organisation/memberlist/{ORGANISATION_ID}"
f"{MEMBERS_LIST_BASE_URL}/organisation/memberlist/{ORGANISATION_ID}"
)


Expand Down
20 changes: 20 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,25 @@
raw_auto_add_committee_to_threads in TRUE_VALUES
)

@classmethod
def _setup_members_list_base_url(cls) -> None:
raw_members_list_base_url: str | None = os.getenv("MEMBERS_LIST_BASE_URL")

MEMBERS_LIST_BASE_URL_IS_VALID: Final[bool] = bool(
raw_members_list_base_url and validators.url(raw_members_list_base_url)
)
if not MEMBERS_LIST_BASE_URL_IS_VALID:
INVALID_MEMBERS_LIST_BASE_URL_MESSAGE: Final[str] = (
"MEMBERS_LIST_BASE_URL must be a valid URL base (without trailing slash)."
)
raise ImproperlyConfiguredError(INVALID_MEMBERS_LIST_BASE_URL_MESSAGE)

# Remove trailing slash if present
if raw_members_list_base_url.endswith("/"):
raw_members_list_base_url = raw_members_list_base_url[:-1]

Check failure on line 727 in config.py

View workflow job for this annotation

GitHub Actions / ruff-lint

Ruff (FURB188)

config.py:726:9: FURB188 Prefer `str.removesuffix()` over conditionally replacing with slice.

cls._settings["MEMBERS_LIST_BASE_URL"] = raw_members_list_base_url

@classmethod
def _setup_env_variables(cls) -> None:
"""
Expand Down Expand Up @@ -749,6 +768,7 @@
cls._setup_moderation_document_url()
cls._setup_strike_performed_manually_warning_location()
cls._setup_auto_add_committee_to_threads()
cls._setup_members_list_base_url()
except ImproperlyConfiguredError as improper_config_error:
webhook_config_logger.error(improper_config_error.message) # noqa: TRY400
raise improper_config_error from improper_config_error
Expand Down
Loading