Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support access organization by subdomain #344

Merged
merged 13 commits into from
Oct 17, 2023
Merged

Support access organization by subdomain #344

merged 13 commits into from
Oct 17, 2023

Conversation

leduythuccs
Copy link
Contributor

Description

Now we can access organizations by subdomain. For example: team-bedao.vnoi.info will be equal to https://oj.vnoi.info/organization/team-bedao

Type of change: new feature

What

  • Added a Middleware to get the org slug from subdomain, and attach it to request instance
  • Override the navbar to redirect to org page instead of the normal page

How

  • Just add judge.middleware.OrganizationSubdomainMiddleware to your middleware list:
MIDDLEWARE += (
    "judge.middleware.OrganizationSubdomainMiddleware",
)
  • You might want to whitelist your domain/subdomain so that the middleware doesn't see it as a org slug. For example, vnoj is deployed at oj.vnoi.info, so we want to whitelist oj.
VNOJ_IGNORED_ORGANIZATION_SUBDOMAINS += ['oj']
# actually `oj` already whitelisted, this is just for example

UI

The old UI (without subdomain) is not changed. The UI with subdomain is here:

  • Navbar and problem list:
image - Contests list: image - Submissions list: image

Note: because the team-bedao doesn't have any submissions, so i used a random org for the above image

Why

  • With this, each organization page will look more legit

How Has This Been Tested?

  • Tested on my local, with my own domain

By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.

@leduythuccs leduythuccs requested a review from hieplpvip October 17, 2023 01:24
@leduythuccs
Copy link
Contributor Author

I didn't add the middleware to the default settings on purpose

@hieplpvip hieplpvip merged commit b676c30 into master Oct 17, 2023
6 checks passed
@hieplpvip hieplpvip deleted the thuc/subdomain branch October 17, 2023 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants