Skip to content
Permalink
Browse files

Re path alised (#986)

* Rename url to re_path

* Fix comment
  • Loading branch information...
tomasmor42 authored and benjaoming committed Oct 27, 2019
1 parent 7e9bd1c commit cbbff45f0575f58af9ec1010bb5c96d50621686d
@@ -1,32 +1,32 @@
from django.urls import re_path as url
from django.urls import re_path
from wiki.plugins.attachments import views

urlpatterns = [
url(r'^$',
re_path(r'^$',
views.AttachmentView.as_view(),
name='attachments_index'),
url(r'^search/$',
re_path(r'^search/$',
views.AttachmentSearchView.as_view(),
name='attachments_search'),
url(r'^add/(?P<attachment_id>[0-9]+)/$',
re_path(r'^add/(?P<attachment_id>[0-9]+)/$',
views.AttachmentAddView.as_view(),
name='attachments_add'),
url(r'^replace/(?P<attachment_id>[0-9]+)/$',
re_path(r'^replace/(?P<attachment_id>[0-9]+)/$',
views.AttachmentReplaceView.as_view(),
name='attachments_replace'),
url(r'^history/(?P<attachment_id>[0-9]+)/$',
re_path(r'^history/(?P<attachment_id>[0-9]+)/$',
views.AttachmentHistoryView.as_view(),
name='attachments_history'),
url(r'^download/(?P<attachment_id>[0-9]+)/$',
re_path(r'^download/(?P<attachment_id>[0-9]+)/$',
views.AttachmentDownloadView.as_view(),
name='attachments_download'),
url(r'^delete/(?P<attachment_id>[0-9]+)/$',
re_path(r'^delete/(?P<attachment_id>[0-9]+)/$',
views.AttachmentDeleteView.as_view(),
name='attachments_delete'),
url(r'^download/(?P<attachment_id>[0-9]+)/revision/(?P<revision_id>[0-9]+)/$',
re_path(r'^download/(?P<attachment_id>[0-9]+)/revision/(?P<revision_id>[0-9]+)/$',
views.AttachmentDownloadView.as_view(),
name='attachments_download'),
url(r'^change/(?P<attachment_id>[0-9]+)/revision/(?P<revision_id>[0-9]+)/$',
re_path(r'^change/(?P<attachment_id>[0-9]+)/revision/(?P<revision_id>[0-9]+)/$',
views.AttachmentChangeRevisionView.as_view(),
name='attachments_revision_change'),
]
@@ -1,4 +1,4 @@
from django.urls import include, re_path as url
from django.urls import include, re_path
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
@@ -12,7 +12,7 @@ class AttachmentPlugin(BasePlugin):

slug = settings.SLUG
urlpatterns = {
'article': [url('', include('wiki.plugins.attachments.urls'))]
'article': [re_path('', include('wiki.plugins.attachments.urls'))]
}

article_tab = (_('Attachments'), "fa fa-file")
@@ -1,4 +1,4 @@
from django.urls import re_path as url
from django.urls import re_path
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin

@@ -9,8 +9,8 @@ class GlobalHistoryPlugin(BasePlugin):

slug = settings.SLUG
urlpatterns = {'root': [
url(r'^$', views.GlobalHistory.as_view(), name='globalhistory'),
url('^(?P<only_last>[01])/$', views.GlobalHistory.as_view(), name='globalhistory'),
re_path(r'^$', views.GlobalHistory.as_view(), name='globalhistory'),
re_path('^(?P<only_last>[01])/$', views.GlobalHistory.as_view(), name='globalhistory'),
]}


@@ -1,4 +1,4 @@
from django.urls import re_path as url
from django.urls import re_path
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
@@ -42,23 +42,23 @@ class RenderMedia:
}

urlpatterns = {'article': [
url('^$',
re_path('^$',
views.ImageView.as_view(),
name='images_index'),
url('^delete/(?P<image_id>[0-9]+)/$',
re_path('^delete/(?P<image_id>[0-9]+)/$',
views.DeleteView.as_view(),
name='images_delete'),
url('^restore/(?P<image_id>[0-9]+)/$',
re_path('^restore/(?P<image_id>[0-9]+)/$',
views.DeleteView.as_view(),
name='images_restore',
kwargs={'restore': True}),
url('^purge/(?P<image_id>[0-9]+)/$',
re_path('^purge/(?P<image_id>[0-9]+)/$',
views.PurgeView.as_view(),
name='images_purge'),
url('^(?P<image_id>[0-9]+)/revision/change/(?P<rev_id>[0-9]+)/$',
re_path('^(?P<image_id>[0-9]+)/revision/change/(?P<rev_id>[0-9]+)/$',
views.RevisionChangeView.as_view(),
name='images_set_revision'),
url('^(?P<image_id>[0-9]+)/revision/add/$',
re_path('^(?P<image_id>[0-9]+)/revision/add/$',
views.RevisionAddView.as_view(),
name='images_add_revision'),
]}
@@ -1,4 +1,4 @@
from django.urls import re_path as url, reverse_lazy
from django.urls import re_path, reverse_lazy
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
@@ -11,7 +11,7 @@ class LinkPlugin(BasePlugin):

slug = 'links'
urlpatterns = {'article': [
url(r'^json/query-urlpath/$',
re_path(r'^json/query-urlpath/$',
views.QueryUrlPath.as_view(),
name='links_query_urlpath'),
]}
@@ -1,4 +1,4 @@
from django.urls import re_path as url
from django.urls import re_path
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin

@@ -9,7 +9,7 @@ class NotifyPlugin(BasePlugin):

slug = settings.SLUG
urlpatterns = {'root': [
url(r'^$', views.NotificationSettings.as_view(), name='notification_settings'),
re_path(r'^$', views.NotificationSettings.as_view(), name='notification_settings'),
]}

article_view = views.NotificationSettings().dispatch
@@ -1,5 +1,5 @@
from django.apps import apps
from django.urls import include, re_path as url
from django.urls import include, re_path
from django.utils.functional import LazyObject
from django.utils.module_loading import import_string
from wiki.conf import settings
@@ -73,27 +73,27 @@ def urls(self):

def get_root_urls(self):
urlpatterns = [
url(r'^$', self.article_view, name='root', kwargs={'path': ''}),
url(r'^create-root/$', self.root_view, name='root_create'),
url(r'^missing-root/$', self.root_missing_view, name='root_missing'),
url(r'^_search/$', self.search_view, name='search'),
url(r'^_revision/diff/(?P<revision_id>[0-9]+)/$', self.article_diff_view, name='diff'),
re_path(r'^$', self.article_view, name='root', kwargs={'path': ''}),
re_path(r'^create-root/$', self.root_view, name='root_create'),
re_path(r'^missing-root/$', self.root_missing_view, name='root_missing'),
re_path(r'^_search/$', self.search_view, name='search'),
re_path(r'^_revision/diff/(?P<revision_id>[0-9]+)/$', self.article_diff_view, name='diff'),
]
return urlpatterns

def get_deleted_list_urls(self):
urlpatterns = [
url('^_admin/$', self.deleted_list_view, name="deleted_list"),
re_path('^_admin/$', self.deleted_list_view, name="deleted_list"),
]
return urlpatterns

def get_accounts_urls(self):
if settings.ACCOUNT_HANDLING:
urlpatterns = [
url(r'^_accounts/sign-up/$', self.signup_view, name='signup'),
url(r'^_accounts/logout/$', self.logout_view, name='logout'),
url(r'^_accounts/login/$', self.login_view, name='login'),
url(r'^_accounts/settings/$', self.profile_update_view, name='profile_update'),
re_path(r'^_accounts/sign-up/$', self.signup_view, name='signup'),
re_path(r'^_accounts/logout/$', self.logout_view, name='logout'),
re_path(r'^_accounts/login/$', self.login_view, name='login'),
re_path(r'^_accounts/settings/$', self.profile_update_view, name='profile_update'),
]
else:
urlpatterns = []
@@ -103,53 +103,53 @@ def get_revision_urls(self):
urlpatterns = [
# This one doesn't work because it don't know
# where to redirect after...
url(r'^change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
url(r'^preview/$', self.article_preview_view, name='preview_revision'),
url(r'^merge/(?P<revision_id>[0-9]+)/preview/$', self.revision_preview_merge_view, name='merge_revision_preview'),
re_path(r'^change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
re_path(r'^preview/$', self.article_preview_view, name='preview_revision'),
re_path(r'^merge/(?P<revision_id>[0-9]+)/preview/$', self.revision_preview_merge_view, name='merge_revision_preview'),
]
return [
url(r'^_revision/(?P<article_id>[0-9]+)/', include(urlpatterns)),
re_path(r'^_revision/(?P<article_id>[0-9]+)/', include(urlpatterns)),
]

def get_article_urls(self):
urlpatterns = [
# Paths decided by article_ids
url(r'^$', self.article_view, name='get'),
url(r'^delete/$', self.article_delete_view, name='delete'),
url(r'^deleted/$', self.article_deleted_view, name='deleted'),
url(r'^edit/$', self.article_edit_view, name='edit'),
url(r'^move/$', self.article_move_view, name='move'),
url(r'^preview/$', self.article_preview_view, name='preview'),
url(r'^history/$', self.article_history_view, name='history'),
url(r'^settings/$', self.article_settings_view, name='settings'),
url(r'^source/$', self.article_source_view, name='source'),
url(r'^revision/change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
url(r'^revision/merge/(?P<revision_id>[0-9]+)/$', self.revision_merge_view, name='merge_revision'),
url(r'^plugin/(?P<slug>\w+)/$', self.article_plugin_view, name='plugin'),
re_path(r'^$', self.article_view, name='get'),
re_path(r'^delete/$', self.article_delete_view, name='delete'),
re_path(r'^deleted/$', self.article_deleted_view, name='deleted'),
re_path(r'^edit/$', self.article_edit_view, name='edit'),
re_path(r'^move/$', self.article_move_view, name='move'),
re_path(r'^preview/$', self.article_preview_view, name='preview'),
re_path(r'^history/$', self.article_history_view, name='history'),
re_path(r'^settings/$', self.article_settings_view, name='settings'),
re_path(r'^source/$', self.article_source_view, name='source'),
re_path(r'^revision/change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
re_path(r'^revision/merge/(?P<revision_id>[0-9]+)/$', self.revision_merge_view, name='merge_revision'),
re_path(r'^plugin/(?P<slug>\w+)/$', self.article_plugin_view, name='plugin'),
]
return [
url(r'^(?P<article_id>[0-9]+)/', include(urlpatterns)),
re_path(r'^(?P<article_id>[0-9]+)/', include(urlpatterns)),
]

def get_article_path_urls(self):
urlpatterns = [
# Paths decided by URLs
url(r'^(?P<path>.+/|)_create/$', self.article_create_view, name='create'),
url(r'^(?P<path>.+/|)_delete/$', self.article_delete_view, name='delete'),
url(r'^(?P<path>.+/|)_deleted/$', self.article_deleted_view, name='deleted'),
url(r'^(?P<path>.+/|)_edit/$', self.article_edit_view, name='edit'),
url(r'^(?P<path>.+/|)_move/$', self.article_move_view, name='move'),
url(r'^(?P<path>.+/|)_preview/$', self.article_preview_view, name='preview'),
url(r'^(?P<path>.+/|)_history/$', self.article_history_view, name='history'),
url(r'^(?P<path>.+/|)_dir/$', self.article_dir_view, name='dir'),
url(r'^(?P<path>.+/|)_search/$', self.search_view, name='search'),
url(r'^(?P<path>.+/|)_settings/$', self.article_settings_view, name='settings'),
url(r'^(?P<path>.+/|)_source/$', self.article_source_view, name='source'),
url(r'^(?P<path>.+/|)_revision/change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
url(r'^(?P<path>.+/|)_revision/merge/(?P<revision_id>[0-9]+)/$', self.revision_merge_view, name='merge_revision'),
url(r'^(?P<path>.+/|)_plugin/(?P<slug>\w+)/$', self.article_plugin_view, name='plugin'),
re_path(r'^(?P<path>.+/|)_create/$', self.article_create_view, name='create'),
re_path(r'^(?P<path>.+/|)_delete/$', self.article_delete_view, name='delete'),
re_path(r'^(?P<path>.+/|)_deleted/$', self.article_deleted_view, name='deleted'),
re_path(r'^(?P<path>.+/|)_edit/$', self.article_edit_view, name='edit'),
re_path(r'^(?P<path>.+/|)_move/$', self.article_move_view, name='move'),
re_path(r'^(?P<path>.+/|)_preview/$', self.article_preview_view, name='preview'),
re_path(r'^(?P<path>.+/|)_history/$', self.article_history_view, name='history'),
re_path(r'^(?P<path>.+/|)_dir/$', self.article_dir_view, name='dir'),
re_path(r'^(?P<path>.+/|)_search/$', self.search_view, name='search'),
re_path(r'^(?P<path>.+/|)_settings/$', self.article_settings_view, name='settings'),
re_path(r'^(?P<path>.+/|)_source/$', self.article_source_view, name='source'),
re_path(r'^(?P<path>.+/|)_revision/change/(?P<revision_id>[0-9]+)/$', self.revision_change_view, name='change_revision'),
re_path(r'^(?P<path>.+/|)_revision/merge/(?P<revision_id>[0-9]+)/$', self.revision_merge_view, name='merge_revision'),
re_path(r'^(?P<path>.+/|)_plugin/(?P<slug>\w+)/$', self.article_plugin_view, name='plugin'),
# This should always go last!
url(r'^(?P<path>.+/|)$', self.article_view, name='get'),
re_path(r'^(?P<path>.+/|)$', self.article_view, name='get'),
]
return urlpatterns

@@ -160,14 +160,14 @@ def get_plugin_urls(self):
if slug:
article_urlpatterns = plugin.urlpatterns.get('article', [])
urlpatterns += [
url(r'^(?P<article_id>[0-9]+)/plugin/' + slug + '/',
re_path(r'^(?P<article_id>[0-9]+)/plugin/' + slug + '/',
include(article_urlpatterns)),
url(r'^(?P<path>.+/|)_plugin/' + slug + '/',
re_path(r'^(?P<path>.+/|)_plugin/' + slug + '/',
include(article_urlpatterns)),
]
root_urlpatterns = plugin.urlpatterns.get('root', [])
urlpatterns += [
url(r'^_plugin/' + slug + '/', include(root_urlpatterns)),
re_path(r'^_plugin/' + slug + '/', include(root_urlpatterns)),
]
return urlpatterns

0 comments on commit cbbff45

Please sign in to comment.
You can’t perform that action at this time.