Skip to content

Commit

Permalink
Make URL configurations compatible with django 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhagander committed May 8, 2024
1 parent 831ca03 commit 99c80e4
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 123 deletions.
60 changes: 30 additions & 30 deletions pgweb/account/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path
from django.conf import settings

import pgweb.account.views
Expand All @@ -7,51 +7,51 @@
pgweb.account.oauthclient.configure()

urlpatterns = [
url(r'^$', pgweb.account.views.home),
re_path(r'^$', pgweb.account.views.home),

# Community authenticatoin
url(r'^auth/(\d+)/$', pgweb.account.views.communityauth),
url(r'^auth/(\d+)/logout/$', pgweb.account.views.communityauth_logout),
url(r'^auth/(\d+)/consent/$', pgweb.account.views.communityauth_consent),
url(r'^auth/(\d+)/search/$', pgweb.account.views.communityauth_search),
url(r'^auth/(\d+)/getkeys/(\d+/)?$', pgweb.account.views.communityauth_getkeys),
url(r'^auth/(\d+)/subscribe/$', pgweb.account.views.communityauth_subscribe),
re_path(r'^auth/(\d+)/$', pgweb.account.views.communityauth),
re_path(r'^auth/(\d+)/logout/$', pgweb.account.views.communityauth_logout),
re_path(r'^auth/(\d+)/consent/$', pgweb.account.views.communityauth_consent),
re_path(r'^auth/(\d+)/search/$', pgweb.account.views.communityauth_search),
re_path(r'^auth/(\d+)/getkeys/(\d+/)?$', pgweb.account.views.communityauth_getkeys),
re_path(r'^auth/(\d+)/subscribe/$', pgweb.account.views.communityauth_subscribe),

# Profile
url(r'^profile/$', pgweb.account.views.profile),
url(r'^profile/add_email/([0-9a-f]+)/$', pgweb.account.views.confirm_add_email),
re_path(r'^profile/$', pgweb.account.views.profile),
re_path(r'^profile/add_email/([0-9a-f]+)/$', pgweb.account.views.confirm_add_email),

# List of items to edit
url(r'^edit/(.*)/$', pgweb.account.views.listobjects),
re_path(r'^edit/(.*)/$', pgweb.account.views.listobjects),

# Submitted items
url(r'^(?P<objtype>news)/(?P<item>\d+)/(?P<what>submit|withdraw)/$', pgweb.account.views.submitted_item_submitwithdraw),
url(r'^(?P<objtype>news|events|products|organisations|services)/(?P<item>\d+|new)/$', pgweb.account.views.submitted_item_form),
url(r'^organisations/confirm/([0-9a-f]+)/$', pgweb.account.views.confirm_org_email),
re_path(r'^(?P<objtype>news)/(?P<item>\d+)/(?P<what>submit|withdraw)/$', pgweb.account.views.submitted_item_submitwithdraw),
re_path(r'^(?P<objtype>news|events|products|organisations|services)/(?P<item>\d+|new)/$', pgweb.account.views.submitted_item_form),
re_path(r'^organisations/confirm/([0-9a-f]+)/$', pgweb.account.views.confirm_org_email),

# Markdown preview (silly to have in /account/, but that's where all the markdown forms are so meh)
url(r'^mdpreview/', pgweb.account.views.markdown_preview),
re_path(r'^mdpreview/', pgweb.account.views.markdown_preview),

# Organisation information
url(r'^orglist/$', pgweb.account.views.orglist),
re_path(r'^orglist/$', pgweb.account.views.orglist),

# Docs comments
url(r'^comments/(new)/([^/]+)/([^/]+)/$', pgweb.docs.views.commentform),
url(r'^comments/(new)/([^/]+)/([^/]+)/done/$', pgweb.docs.views.commentform_done),
re_path(r'^comments/(new)/([^/]+)/([^/]+)/$', pgweb.docs.views.commentform),
re_path(r'^comments/(new)/([^/]+)/([^/]+)/done/$', pgweb.docs.views.commentform_done),

# Log in, logout, change password etc
url(r'^login/$', pgweb.account.views.login),
url(r'^logout/$', pgweb.account.views.logout),
url(r'^changepwd/$', pgweb.account.views.changepwd),
url(r'^changepwd/done/$', pgweb.account.views.change_done),
url(r'^reset/$', pgweb.account.views.resetpwd),
url(r'^reset/done/$', pgweb.account.views.reset_done),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)-(?P<token>[0-9A-Za-z]+-[0-9A-Za-z]+)/$', pgweb.account.views.reset_confirm),
url(r'^reset/complete/$', pgweb.account.views.reset_complete),
url(r'^signup/$', pgweb.account.views.signup),
url(r'^signup/complete/$', pgweb.account.views.signup_complete),
url(r'^signup/oauth/$', pgweb.account.views.signup_oauth),
re_path(r'^login/$', pgweb.account.views.login),
re_path(r'^logout/$', pgweb.account.views.logout),
re_path(r'^changepwd/$', pgweb.account.views.changepwd),
re_path(r'^changepwd/done/$', pgweb.account.views.change_done),
re_path(r'^reset/$', pgweb.account.views.resetpwd),
re_path(r'^reset/done/$', pgweb.account.views.reset_done),
re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)-(?P<token>[0-9A-Za-z]+-[0-9A-Za-z]+)/$', pgweb.account.views.reset_confirm),
re_path(r'^reset/complete/$', pgweb.account.views.reset_complete),
re_path(r'^signup/$', pgweb.account.views.signup),
re_path(r'^signup/complete/$', pgweb.account.views.signup_complete),
re_path(r'^signup/oauth/$', pgweb.account.views.signup_oauth),
]

for provider in list(settings.OAUTH.keys()):
urlpatterns.append(url(r'^login/({0})/$'.format(provider), pgweb.account.oauthclient.login_oauth))
urlpatterns.append(re_path(r'^login/({0})/$'.format(provider), pgweb.account.oauthclient.login_oauth))
186 changes: 93 additions & 93 deletions pgweb/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf.urls import include, url
from django.urls import path
from django.conf.urls import include
from django.urls import path, re_path
from django.views.generic import RedirectView
from django.conf import settings

Expand Down Expand Up @@ -30,147 +30,147 @@
admin.autodiscover()

urlpatterns = [
url(r'^$', pgweb.core.views.home),
url(r'^dyncss/(?P<css>base).css$', pgweb.core.views.dynamic_css),

url(r'^about/$', pgweb.core.views.about),
url(r'^about/newsarchive/(?P<tag>[^/]*/)?(?P<paginator>[0-9]{8}/)?$', pgweb.news.views.archive),
url(r'^about/news/(?P<slug>[^/]+)-(?P<itemid>\d+)/$', pgweb.news.views.item),
url(r'^about/news/(?P<itemid>\d+)(?P<slug>-.*)?/$', pgweb.news.views.item),
url(r'^about/news/taglist.json/$', pgweb.news.views.taglist_json),
url(r'^about/events/$', pgweb.events.views.main),
url(r'^about/eventarchive/$', pgweb.events.views.archive),
url(r'^about/event/(?P<itemid>\d+)(<?P<slug>-.*)?/$', pgweb.events.views.item),
url(r'^about/event/(?P<slug>[^/]+)-(?P<itemid>\d+)/$', pgweb.events.views.item),
url(r'^about/featurematrix/$', pgweb.featurematrix.views.root),
url(r'^about/featurematrix/detail/(\d+)/$', pgweb.featurematrix.views.detail),
url(r'^about/privacypolicy/$', RedirectView.as_view(url='/about/policies/privacy/', permanent=True)),

url(r'^ftp/(.*/)?$', pgweb.downloads.views.ftpbrowser),
url(r'^download/mirrors-ftp/+(.*)$', pgweb.downloads.views.mirrorselect),
url(r'^download/product-categories/$', pgweb.downloads.views.categorylist),
url(r'^download/products/(\d+)(-.*)?/$', pgweb.downloads.views.productlist),
url(r'^applications-v2.xml$', pgweb.downloads.views.applications_v2_xml),
url(r'^download/uploadftp/', pgweb.downloads.views.uploadftp),
url(r'^download/uploadyum/', pgweb.downloads.views.uploadyum),
url(r'^download/js/yum.js', pgweb.downloads.views.yum_js),

url(r'^docs/$', pgweb.docs.views.root),
url(r'^docs/manuals/$', pgweb.docs.views.manuals),
url(r'^docs/manuals/archive/$', pgweb.docs.views.manualarchive),
url(r'^docs/release/$', pgweb.docs.views.release_notes_list),
url(r'^docs/release/(\d+(?:\.\d+){0,2})/$', pgweb.docs.views.release_notes),
re_path(r'^$', pgweb.core.views.home),
re_path(r'^dyncss/(?P<css>base).css$', pgweb.core.views.dynamic_css),

re_path(r'^about/$', pgweb.core.views.about),
re_path(r'^about/newsarchive/(?P<tag>[^/]*/)?(?P<paginator>[0-9]{8}/)?$', pgweb.news.views.archive),
re_path(r'^about/news/(?P<slug>[^/]+)-(?P<itemid>\d+)/$', pgweb.news.views.item),
re_path(r'^about/news/(?P<itemid>\d+)(?P<slug>-.*)?/$', pgweb.news.views.item),
re_path(r'^about/news/taglist.json/$', pgweb.news.views.taglist_json),
re_path(r'^about/events/$', pgweb.events.views.main),
re_path(r'^about/eventarchive/$', pgweb.events.views.archive),
re_path(r'^about/event/(?P<itemid>\d+)(<?P<slug>-.*)?/$', pgweb.events.views.item),
re_path(r'^about/event/(?P<slug>[^/]+)-(?P<itemid>\d+)/$', pgweb.events.views.item),
re_path(r'^about/featurematrix/$', pgweb.featurematrix.views.root),
re_path(r'^about/featurematrix/detail/(\d+)/$', pgweb.featurematrix.views.detail),
re_path(r'^about/privacypolicy/$', RedirectView.as_view(url='/about/policies/privacy/', permanent=True)),

re_path(r'^ftp/(.*/)?$', pgweb.downloads.views.ftpbrowser),
re_path(r'^download/mirrors-ftp/+(.*)$', pgweb.downloads.views.mirrorselect),
re_path(r'^download/product-categories/$', pgweb.downloads.views.categorylist),
re_path(r'^download/products/(\d+)(-.*)?/$', pgweb.downloads.views.productlist),
re_path(r'^applications-v2.xml$', pgweb.downloads.views.applications_v2_xml),
re_path(r'^download/uploadftp/', pgweb.downloads.views.uploadftp),
re_path(r'^download/uploadyum/', pgweb.downloads.views.uploadyum),
re_path(r'^download/js/yum.js', pgweb.downloads.views.yum_js),

re_path(r'^docs/$', pgweb.docs.views.root),
re_path(r'^docs/manuals/$', pgweb.docs.views.manuals),
re_path(r'^docs/manuals/archive/$', pgweb.docs.views.manualarchive),
re_path(r'^docs/release/$', pgweb.docs.views.release_notes_list),
re_path(r'^docs/release/(\d+(?:\.\d+){0,2})/$', pgweb.docs.views.release_notes),
# Legacy URLs for accessing the docs page; provides a permanent redirect
url(r'^docs/(current|devel|\d+(?:\.\d)?)/(static|interactive)/(([^/]+).html?)?$', pgweb.docs.views.docspermanentredirect),
url(r'^docs/(current|devel|\d+(?:\.\d)?)/([^/]+).html?$', pgweb.docs.views.docpage),
url(r'^docs/(current|devel|\d+(?:\.\d)?)/([^/]+).svg$', pgweb.docs.views.docsvg),
url(r'^docs/(current|devel|\d+(?:\.\d)?)/$', pgweb.docs.views.docsrootpage),
url(r'^docs/(current|devel|\d+(?:\.\d)?)/$', pgweb.docs.views.redirect_root),

url(r'^community/$', pgweb.core.views.community),
url(r'^community/contributors/$', pgweb.contributors.views.completelist),
url(r'^community/lists/$', RedirectView.as_view(url='/list/', permanent=True)),
url(r'^community/lists/subscribe/$', RedirectView.as_view(url='https://lists.postgresql.org/', permanent=True)),

url(r'^community/lists/listinfo/$', pgweb.lists.views.listinfo),
url(r'^community/recognition/$', RedirectView.as_view(url='/about/policies/', permanent=True)),
url(r'^community/survey/vote/(\d+)/$', pgweb.survey.views.vote),
url(r'^community/survey[/\.](\d+)(-.*)?/$', pgweb.survey.views.results),
url(r'^community/user-groups/$', pgweb.pugs.views.index),

url(r'^search/$', pgweb.search.views.search),

url(r'^support/security/$', pgweb.security.views.index),
url(r'^support/security/(\d\.\d|\d{2})/$', pgweb.security.views.version),
url(r'^support/security/(?P<cve_prefix>CVE|cve)-(?P<cve>\d{4}-\d{4,7})/$', pgweb.security.views.details),
url(r'^support/security_archive/$', RedirectView.as_view(url='/support/security/', permanent=True)),

url(r'^support/professional_(support|hosting)/$', pgweb.profserv.views.root),
url(r'^support/professional_(support|hosting)[/_](.*)/$', pgweb.profserv.views.region),
url(r'^account/submitbug/$', pgweb.misc.views.submitbug),
url(r'^account/submitbug/(\d+)/$', pgweb.misc.views.submitbug_done),
url(r'^support/submitbug/$', RedirectView.as_view(url='/account/submitbug/', permanent=True)),
url(r'^support/versioning/$', pgweb.core.views.versions),
url(r'^bugs_redir/(\d+)/$', pgweb.misc.views.bugs_redir),

url(r'^about/sponsors/$', pgweb.sponsors.views.sponsors),
url(r'^about/contributing/$', pgweb.sponsors.views.contributing),
url(r'^about/financial/$', pgweb.sponsors.views.financial),
url(r'^about/servers/$', pgweb.sponsors.views.servers),

url(r'^robots.txt$', pgweb.core.views.robots),
re_path(r'^docs/(current|devel|\d+(?:\.\d)?)/(static|interactive)/(([^/]+).html?)?$', pgweb.docs.views.docspermanentredirect),
re_path(r'^docs/(current|devel|\d+(?:\.\d)?)/([^/]+).html?$', pgweb.docs.views.docpage),
re_path(r'^docs/(current|devel|\d+(?:\.\d)?)/([^/]+).svg$', pgweb.docs.views.docsvg),
re_path(r'^docs/(current|devel|\d+(?:\.\d)?)/$', pgweb.docs.views.docsrootpage),
re_path(r'^docs/(current|devel|\d+(?:\.\d)?)/$', pgweb.docs.views.redirect_root),

re_path(r'^community/$', pgweb.core.views.community),
re_path(r'^community/contributors/$', pgweb.contributors.views.completelist),
re_path(r'^community/lists/$', RedirectView.as_view(url='/list/', permanent=True)),
re_path(r'^community/lists/subscribe/$', RedirectView.as_view(url='https://lists.postgresql.org/', permanent=True)),

re_path(r'^community/lists/listinfo/$', pgweb.lists.views.listinfo),
re_path(r'^community/recognition/$', RedirectView.as_view(url='/about/policies/', permanent=True)),
re_path(r'^community/survey/vote/(\d+)/$', pgweb.survey.views.vote),
re_path(r'^community/survey[/\.](\d+)(-.*)?/$', pgweb.survey.views.results),
re_path(r'^community/user-groups/$', pgweb.pugs.views.index),

re_path(r'^search/$', pgweb.search.views.search),

re_path(r'^support/security/$', pgweb.security.views.index),
re_path(r'^support/security/(\d\.\d|\d{2})/$', pgweb.security.views.version),
re_path(r'^support/security/(?P<cve_prefix>CVE|cve)-(?P<cve>\d{4}-\d{4,7})/$', pgweb.security.views.details),
re_path(r'^support/security_archive/$', RedirectView.as_view(url='/support/security/', permanent=True)),

re_path(r'^support/professional_(support|hosting)/$', pgweb.profserv.views.root),
re_path(r'^support/professional_(support|hosting)[/_](.*)/$', pgweb.profserv.views.region),
re_path(r'^account/submitbug/$', pgweb.misc.views.submitbug),
re_path(r'^account/submitbug/(\d+)/$', pgweb.misc.views.submitbug_done),
re_path(r'^support/submitbug/$', RedirectView.as_view(url='/account/submitbug/', permanent=True)),
re_path(r'^support/versioning/$', pgweb.core.views.versions),
re_path(r'^bugs_redir/(\d+)/$', pgweb.misc.views.bugs_redir),

re_path(r'^about/sponsors/$', pgweb.sponsors.views.sponsors),
re_path(r'^about/contributing/$', pgweb.sponsors.views.contributing),
re_path(r'^about/financial/$', pgweb.sponsors.views.financial),
re_path(r'^about/servers/$', pgweb.sponsors.views.servers),

re_path(r'^robots.txt$', pgweb.core.views.robots),

###
# RSS feeds
###
url(r'^versions.rss$', VersionFeed()),
url(r'^news(/(?P<tagurl>[^/]+))?.rss$', NewsFeed()),
url(r'^events.rss$', EventFeed()),
re_path(r'^versions.rss$', VersionFeed()),
re_path(r'^news(/(?P<tagurl>[^/]+))?.rss$', NewsFeed()),
re_path(r'^events.rss$', EventFeed()),

###
# JSON feeds
###
url(r'^versions.json$', versions_json),
re_path(r'^versions.json$', versions_json),

###
# Special sections
###
url(r'^account/', include('pgweb.account.urls')),
re_path(r'^account/', include('pgweb.account.urls')),

###
# Sitemap (FIXME: support for >50k urls!)
###
url(r'^sitemap.xml', pgweb.core.views.sitemap),
url(r'^sitemap_internal.xml', pgweb.core.views.sitemap_internal),
re_path(r'^sitemap.xml', pgweb.core.views.sitemap),
re_path(r'^sitemap_internal.xml', pgweb.core.views.sitemap_internal),

###
# Workaround for broken links pushed in press release
###
url(r'^downloads/$', RedirectView.as_view(url='/download/', permanent=True)),
re_path(r'^downloads/$', RedirectView.as_view(url='/download/', permanent=True)),

###
# Legacy URLs from old structurs, but used in places like press releases
# so needs to live a bit longer.
###
url(r'^about/press/contact/$', RedirectView.as_view(url='/about/press/', permanent=True)),
re_path(r'^about/press/contact/$', RedirectView.as_view(url='/about/press/', permanent=True)),

###
# Images that are used from other community sites
###
url(r'^layout/images/(?P<f>[a-z0-9_\.]+)$', RedirectView.as_view(url='/media/img/layout/%(f)s', permanent=True)),
re_path(r'^layout/images/(?P<f>[a-z0-9_\.]+)$', RedirectView.as_view(url='/media/img/layout/%(f)s', permanent=True)),
###
# Handle redirect on incorrect spelling of licence
###
url(r'^about/license/$', RedirectView.as_view(url='/about/licence', permanent=True)),
re_path(r'^about/license/$', RedirectView.as_view(url='/about/licence', permanent=True)),

###
# Links included in emails on the lists (do we need to check this for XSS?)
###
url(r'^mailpref/([a-z0-9_-]+)/$', pgweb.legacyurl.views.mailpref),
re_path(r'^mailpref/([a-z0-9_-]+)/$', pgweb.legacyurl.views.mailpref),

# Some basic information about the connection (for debugging purposes)
url(r'^system_information/$', pgweb.core.views.system_information),
re_path(r'^system_information/$', pgweb.core.views.system_information),
# Sync timestamp, for automirror
url(r'^web_sync_timestamp$', pgweb.core.views.sync_timestamp),
re_path(r'^web_sync_timestamp$', pgweb.core.views.sync_timestamp),

# API endpoints
url(r'^api/varnish/purge/$', pgweb.core.views.api_varnish_purge),
re_path(r'^api/varnish/purge/$', pgweb.core.views.api_varnish_purge),

# Override some URLs in admin, to provide our own pages
url(r'^admin/pending/$', pgweb.core.views.admin_pending),
url(r'^admin/purge/$', pgweb.core.views.admin_purge),
url(r'^admin/mergeorg/$', pgweb.core.views.admin_mergeorg),
url(r'^admin/_moderate/(\w+)/(\d+)/$', pgweb.core.views.admin_moderate),
url(r'^admin/auth/user/(\d+)/change/resetpassword/$', pgweb.core.views.admin_resetpassword),
re_path(r'^admin/pending/$', pgweb.core.views.admin_pending),
re_path(r'^admin/purge/$', pgweb.core.views.admin_purge),
re_path(r'^admin/mergeorg/$', pgweb.core.views.admin_mergeorg),
re_path(r'^admin/_moderate/(\w+)/(\d+)/$', pgweb.core.views.admin_moderate),
re_path(r'^admin/auth/user/(\d+)/change/resetpassword/$', pgweb.core.views.admin_resetpassword),

# Uncomment the next line to enable the admin:
url(r'^admin/', admin.site.urls),
re_path(r'^admin/', admin.site.urls),

# Crash testing URL :-)
url(r'^crashtest/$', pgweb.misc.views.crashtest),
re_path(r'^crashtest/$', pgweb.misc.views.crashtest),

# Fallback for static pages, must be at the bottom
url(r'^(.*)/$', pgweb.core.views.fallback),
re_path(r'^(.*)/$', pgweb.core.views.fallback),
]


Expand Down

0 comments on commit 99c80e4

Please sign in to comment.