Skip to content

Change language to be a bit more gender neutral, and update admin - #11

Merged
Heliodex merged 57 commits into
prodfrom
main
Sep 9, 2026
Merged

Change language to be a bit more gender neutral, and update admin#11
Heliodex merged 57 commits into
prodfrom
main

Conversation

@KavyanshKhaitan2

Copy link
Copy Markdown
Collaborator

Before

image image

After

image image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A few new request-path validations rely on assert (unsafe in production) and the auth callback can still raise on missing sub, both leading to avoidable 500s.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR modernizes Twisted’s Django code and templates by adding typing/defensive checks, refactoring Slack notifications for admin/review flows, and reformatting UI templates (including some accessibility improvements like lang and alt attributes).

Changes:

  • Add/adjust type annotations and more explicit empty-string checks across client/admin views and model helpers.
  • Refactor Slack messaging to use a send_blocks helper and add Slack logging error handling.
  • Reformat many templates/CSS and improve some markup semantics/accessibility (e.g., lang="en", alt=).
File summaries
File Description
twisted/twisted_site/views/image_upload.py Tightens upload typing/validation and return types.
twisted/twisted_site/views/client/referrals.py Adds typing and explicit referral-code emptiness checks.
twisted/twisted_site/views/client/projects.py Adds typing/casts for profile/projects and request data.
twisted/twisted_site/views/client/project.py Adds typed context, helper formatting, and safer sorting.
twisted/twisted_site/views/client/pathways.py Adds typing/casts and list element typing.
twisted/twisted_site/views/client/journal.py Adds typing and switches to typed template context.
twisted/twisted_site/views/client/homepage.py Adds typing and explicit query-param emptiness checks.
twisted/twisted_site/views/client/discover.py Adds typed request/response signatures.
twisted/twisted_site/views/client/dashboard.py Adds typing for context and query param handling.
twisted/twisted_site/views/client/auth.py Adds typed OAuth flow and more explicit null/empty handling.
twisted/twisted_site/views/ari.py Refactors Slack blocks sending and adds some defensive checks.
twisted/twisted_site/views/admin/users.py Adds typing and minor query handling tweaks.
twisted/twisted_site/views/admin/shop.py Adds typed request/response signatures.
twisted/twisted_site/views/admin/review.py Adds typing and minor cleanup for debug paths.
twisted/twisted_site/views/admin/pathways.py Adds typing and explicit empty-string checks for form inputs.
twisted/twisted_site/views/admin/fulfillment.py Adds typed request/response signatures.
twisted/twisted_site/views/admin/dashboard.py Adds typing for chart data containers.
twisted/twisted_site/views/admin/audit_logs.py Adds typed request/response and parameter typing.
twisted/twisted_site/views/admin/announcements.py Adds typed request/response signatures.
twisted/twisted_site/views/admin/admin.py Adds typed context/dispatch and staff permission provisioning.
twisted/twisted_site/templatetags/time_filters.py Adds typing to template filters.
twisted/twisted_site/templatetags/maths.py Adds typing to divide template filter.
twisted/twisted_site/templates/cotton/svg/tick.html Reformat SVG markup.
twisted/twisted_site/templates/cotton/svg/cross.html Reformat SVG markup.
twisted/twisted_site/templates/cotton/sidebar/item.html Reformat sidebar item markup.
twisted/twisted_site/templates/cotton/sidebar/index.html Reformat sidebar layout + add missing alt text.
twisted/twisted_site/templates/cotton/ship_message.html Reformat ship message layout.
twisted/twisted_site/templates/cotton/project_ship_mark.html Reformat and normalize quote style/indentation.
twisted/twisted_site/templates/cotton/pathway_card.html Reformat pathway card markup.
twisted/twisted_site/templates/cotton/mdpreview.html Reformat md preview wrapper.
twisted/twisted_site/templates/cotton/mdedit.html Reformat md editor markup and JS indentation.
twisted/twisted_site/templates/cotton/button.html Collapse button class formatting.
twisted/twisted_site/templates/cotton/base.html Reformat admin base template, add lang, adjust message toasts.
twisted/twisted_site/templates/client/referrals.html Reformat + add missing alt attributes.
twisted/twisted_site/templates/client/projects/ship.html Reformat ship submission UI and some element semantics.
twisted/twisted_site/templates/client/projects/settings.html Reformat + improves screenshot upload preview handling.
twisted/twisted_site/templates/client/projects/list.html Reformat + set explicit type="button" where needed.
twisted/twisted_site/templates/client/projects/journal/new_untracked.html Reformat + button/link semantics tweaks.
twisted/twisted_site/templates/client/projects/journal/new_journal.base.html Reformat and simplify journal creation layout.
twisted/twisted_site/templates/client/projects/journal/new_hackatime.html Reformat + button/link semantics tweaks.
twisted/twisted_site/templates/client/projects/journal/delete.html Reformat delete confirmation UI.
twisted/twisted_site/templates/client/projects/create.html Reformat create project UI.
twisted/twisted_site/templates/client/pathways.html Reformat pathways listing and layout.
twisted/twisted_site/templates/client/osbase.html Add lang, reformat, and tweak cookie setting JS.
twisted/twisted_site/templates/client/homepage.html Reformat homepage UI and CTA button/link markup.
twisted/twisted_site/templates/client/faqs.html Reformat FAQ page and close button markup.
twisted/twisted_site/templates/client/discover.html Reformat discover UI and pagination buttons.
twisted/twisted_site/templates/admin/users.html Reformat admin users search UI.
twisted/twisted_site/templates/admin/user.html Reformat admin user detail view and tables.
twisted/twisted_site/templates/admin/shop.html Reformat placeholder buttons.
twisted/twisted_site/templates/admin/review.html Reformat placeholder buttons.
twisted/twisted_site/templates/admin/pathways/list.html Reformat pathways list and SVG markup.
twisted/twisted_site/templates/admin/pathways/detail.html Reformat pathway detail and participant table.
twisted/twisted_site/templates/admin/pathways/create.html Reformat pathway create form and button markup.
twisted/twisted_site/templates/admin/logs.html Reformat audit logs rendering + add alt to avatars.
twisted/twisted_site/templates/admin/fulfillment.html Reformat placeholder buttons.
twisted/twisted_site/templates/admin/debug/review.html Reformat debug review UI.
twisted/twisted_site/templates/admin/dashboard.html Reformat dashboard tabs and Google charts scripts.
twisted/twisted_site/templates/admin/announcements.html Reformat placeholder buttons.
twisted/twisted_site/slack.py Adds send_blocks helper and Slack error handling for logging.
twisted/twisted_site/models.py Adds typing, @override, and improves queryset truthiness handling.
twisted/twisted_site/hackatime.py Adds typing and narrows JSON parsing shapes.
twisted/twisted_site/ari.py Adds typing and more explicit empty checks; tightens helper signatures.
twisted/tailwindcsstheme/static_src/src/styles.css Reformat styling and normalize casing/format.
twisted/mysite/wsgi.py Assigns return value to _ for lint/type cleanliness.
twisted/mysite/settings.py Uses explicit (None, \"\") empty checks and adds type-ignore comments.
twisted/mysite/middleware.py Adds typing and explicit empty-cookie handling.
twisted/mysite/asgi.py Assigns return value to _ for lint/type cleanliness.
twisted/manage.py Adds return type and assigns env default to _.
twisted/common/templates/base.html Adds doctype/lang and reformat cookie JS.
Review details

Files not reviewed (1)

  • twisted/tailwindcsstheme/static_src/src/cotton-ui.sources.css: Generated file

Suppressed comments (3)

twisted/twisted_site/views/image_upload.py:49

  • assert file.size is not None is not safe for production (asserts may be disabled) and will produce a 500 if size is missing. Prefer an explicit check with a clear client error response before computing file_size_mb.
    twisted/twisted_site/views/admin/admin.py:101
  • When staff_permissions is missing, a new object is created but perms is never updated, so self.perms remains None even after provisioning permissions. Assign the newly created permissions to perms before storing it on self.
    twisted/twisted_site/views/image_upload.py:124
  • file_uploader relies on assert image.name is not None for a required field. If asserts are disabled, this can raise later (e.g., Path(None)) and return a 500. Handle missing/empty names by returning a structured error dict.
  • Files reviewed: 73/74 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 72 to 76
email = userinfo.get("email", "hackclubber@example.com")
name = userinfo.get("name", "")
sub = userinfo.get("sub")
sub = cast(str, userinfo.get("sub"))
clean_sub = sub.replace("!", "_")
slack_id = userinfo.get("slack_id", "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also will fix later

Comment on lines 32 to 35
if "file" in request.FILES:
file = request.FILES["file"]
assert isinstance(file, DjangoUploadedFile)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in the next PR

yes the buttons still work :pensive-wobble:
@Heliodex
Heliodex merged commit 3415e33 into prod Sep 9, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants