fixed add_page and edit_page URL definitions to work with "/" path.
This commit is contained in:
@@ -179,6 +179,7 @@ class PageAddForm(WYSIWYGEditorMixin, generic.CreateView):
|
||||
|
||||
def get_initial(self):
|
||||
"""Try to get the path of the parent page as initial data."""
|
||||
if self.kwargs['path']:
|
||||
path = os.path.splitext(self.kwargs['path'])[0]
|
||||
if path.startswith('/'):
|
||||
path = path[1:]
|
||||
@@ -186,6 +187,8 @@ class PageAddForm(WYSIWYGEditorMixin, generic.CreateView):
|
||||
path = path[:-1]
|
||||
parent = models.Page.objects.get(path=path)
|
||||
return {'parent': parent}
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView):
|
||||
@@ -204,7 +207,8 @@ class PageEditForm(WYSIWYGEditorMixin, generic.UpdateView):
|
||||
:param queryset: Get the single item from this filtered queryset.
|
||||
:return:
|
||||
"""
|
||||
path = os.path.splitext(self.kwargs['path'])[0]
|
||||
path = self.kwargs['path'] or 'index.html'
|
||||
path = os.path.splitext(path)[0]
|
||||
queryset = queryset or self.get_queryset()
|
||||
if path.startswith('/'):
|
||||
path = path[1:]
|
||||
|
||||
@@ -29,13 +29,13 @@ sitemaps = {
|
||||
urlpatterns = [ # Ignore PyLintBear (C0103)
|
||||
url(r'^$', views.StartPage.as_view()),
|
||||
url(r'^404/$', TemplateView.as_view(template_name='404.html')),
|
||||
url(r'^add_page/(?P<path>[\+\.\-\d\w\/]+)/$',
|
||||
url(r'^add_page/(?P<path>[\+\.\-\d\w\/]*)$',
|
||||
views.PageAddForm.as_view(), name='add-page'),
|
||||
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
|
||||
url(r'^comments/', include('django_comments.urls')),
|
||||
url(r'^edit_page/(?P<path>[\+\.\-\d\w\/]+)/$',
|
||||
url(r'^edit_page/(?P<path>[\+\.\-\d\w\/]*)$',
|
||||
views.PageEditForm.as_view(), name='edit-page'),
|
||||
url(r'^events/', include('events.urls')),
|
||||
url(r'^events.ics$', EventListIcal.as_view(), name='events-ical'),
|
||||
|
||||
Reference in New Issue
Block a user