mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Fix regex for pages
This commit is contained in:
parent
e2078a8c15
commit
aa49b2d4ce
@ -6,8 +6,12 @@ from club.models import Club
|
||||
|
||||
|
||||
def generate_club_pages(apps, schema_editor):
|
||||
for club in Club.objects.all():
|
||||
def recursive_generate_club_page(club):
|
||||
club.make_page()
|
||||
for child in Club.objects.filter(parent=club).all():
|
||||
recursive_generate_club_page(child)
|
||||
for club in Club.objects.filter(parent=None).all():
|
||||
recursive_generate_club_page(club)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -28,5 +32,7 @@ class Migration(migrations.Migration):
|
||||
name='page',
|
||||
field=models.OneToOneField(related_name='club', blank=True, null=True, to='core.Page'),
|
||||
),
|
||||
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE', reverse_sql=migrations.RunSQL.noop),
|
||||
migrations.RunPython(generate_club_pages),
|
||||
migrations.RunSQL(migrations.RunSQL.noop, reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
|
||||
]
|
||||
|
@ -841,7 +841,7 @@ class Page(models.Model):
|
||||
name = models.CharField(_('page unix name'), max_length=30,
|
||||
validators=[
|
||||
validators.RegexValidator(
|
||||
r'^[A-z.+-]+$',
|
||||
r'^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$',
|
||||
_('Enter a valid page name. This value may contain only '
|
||||
'unaccented letters, numbers ' 'and ./+/-/_ characters.')
|
||||
), ],
|
||||
|
10
core/urls.py
10
core/urls.py
@ -87,9 +87,9 @@ urlpatterns = [
|
||||
url(r'^page/$', PageListView.as_view(), name='page_list'),
|
||||
url(r'^page/create$', PageCreateView.as_view(), name='page_new'),
|
||||
url(r'^page/(?P<page_id>[0-9]*)/delete$', PageDeleteView.as_view(), name='page_delete'),
|
||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/edit$', PageEditView.as_view(), name='page_edit'),
|
||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/prop$', PagePropView.as_view(), name='page_prop'),
|
||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/hist$', PageHistView.as_view(), name='page_hist'),
|
||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/$', PageView.as_view(), name='page'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/edit$', PageEditView.as_view(), name='page_edit'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/prop$', PagePropView.as_view(), name='page_prop'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/hist$', PageHistView.as_view(), name='page_hist'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
||||
url(r'^page/(?P<page_name>[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])/$', PageView.as_view(), name='page'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user