Skip to content

Commit

Permalink
Switch back to using /organization/
Browse files Browse the repository at this point in the history
Create a validation rule to ensure slugs begin with a letter
  • Loading branch information
magnified103 committed Sep 26, 2023
1 parent ac970c0 commit 2f01b04
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dmoj/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ def paged_list_view(view, name):

path('organizations/', organization.OrganizationList.as_view(), name='organization_list'),
path('organizations/create', organization.CreateOrganization.as_view(), name='organization_create'),
path('org/<slug:slug>', include([
path('organization/<int:pk>-<path:suffix>',
lambda _, pk, suffix: HttpResponsePermanentRedirect('/organization/%s' % suffix)),
path('organization/<slug:slug>', include([
path('', organization.OrganizationHome.as_view(), name='organization_home'),
path('/users/', organization.OrganizationUsers.as_view(), name='organization_users'),
path('/join', organization.JoinOrganization.as_view(), name='join_organization'),
Expand Down Expand Up @@ -307,8 +309,6 @@ def paged_list_view(view, name):

path('/', lambda _, slug: HttpResponsePermanentRedirect(reverse('organization_home', args=[slug]))),
])),
path('organization/<int:pk>-<path:suffix>',
lambda _, pk, suffix: HttpResponsePermanentRedirect('/org/%s' % suffix)),

path('runtimes/', language.LanguageList.as_view(), name='runtime_list'),
path('runtimes/matrix/', status.version_matrix, name='version_matrix'),
Expand Down
20 changes: 20 additions & 0 deletions judge/migrations/0197_org_slugs_begin_with_letter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.20 on 2023-09-26 16:45

import django.core.validators
from django.db import migrations, models
import judge.models.problem


class Migration(migrations.Migration):

dependencies = [
('judge', '0196_view_all_user_comment_permission'),
]

operations = [
migrations.AlterField(
model_name='organization',
name='slug',
field=models.SlugField(help_text='Organization name shown in URLs.', max_length=128, unique=True, validators=[django.core.validators.RegexValidator('^[a-zA-Z]', 'Organization slugs must begin with a letter.')], verbose_name='organization slug'),
),
]
2 changes: 2 additions & 0 deletions judge/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Organization(models.Model):
name = models.CharField(max_length=128, verbose_name=_('organization title'))
slug = models.SlugField(max_length=128, verbose_name=_('organization slug'),
help_text=_('Organization name shown in URLs.'),
validators=[RegexValidator(r'^[a-zA-Z]',
_('Organization slugs must begin with a letter.'))],
unique=True)
short_name = models.CharField(max_length=20, verbose_name=_('short name'),
help_text=_('Displayed beside user name during contests.'))
Expand Down
4 changes: 4 additions & 0 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,10 @@ msgstr ""
msgid "Organization name shown in URL"
msgstr ""

#: judge/models/profile.py:45
msgid "Organization slugs must begin with a letter."
msgstr ""

#: judge/models/profile.py:45
msgid "Displayed beside user name during contests"
msgstr ""
Expand Down
4 changes: 4 additions & 0 deletions locale/vi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,10 @@ msgstr "tên viết tắt trên đường dẫn"
msgid "Organization name shown in URLs."
msgstr "Tên viết tắt của tổ chức, được dùng trong đường dẫn tới tổ chức"

#: judge/models/profile.py:45
msgid "Organization slugs must begin with a letter."
msgstr "Tên viết tắt của tổ chức phải bắt đầu bằng một chữ cái."

#: judge/models/profile.py:45
msgid "Displayed beside user name during contests."
msgstr "Hiển thị bên cạnh tên trong các kỳ thi"
Expand Down

0 comments on commit 2f01b04

Please sign in to comment.