Fix URL namespace changes
authorMagnus Hagander <magnus@hagander.net>
Thu, 28 Apr 2016 09:25:02 +0000 (11:25 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sat, 14 May 2016 17:49:12 +0000 (19:49 +0200)
1. Prefix all our local modules with "pgweb" as required by the new
   project layout.
2. Change the django core imports to match 1.8
3. redirect_to has been changed to RedirectView

In passing also tabify the urls file which used a horrible mix of tabs
and spaces. The python standard is spaces, but since the rest of the
pgweb projects uses tabs, make the urls.py files do that as well.

pgweb/account/urls.py
pgweb/urls.py

index 490a8cf98abff3481c9b3c1c65f2022965aaf41a..f00638bb808848b4bd785d168d53a6c47b1cbc69 100644 (file)
@@ -1,48 +1,48 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns
 
 
 urlpatterns = patterns('',
-    (r'^$', 'account.views.home'),
+       (r'^$', 'pgweb.account.views.home'),
 
-    # Community authenticatoin
-    (r'^auth/(\d+)/$', 'account.views.communityauth'),
-    (r'^auth/(\d+)/logout/$', 'account.views.communityauth_logout'),
-    (r'^auth/(\d+)/search/$', 'account.views.communityauth_search'),
+       # Community authenticatoin
+       (r'^auth/(\d+)/$', 'pgweb.account.views.communityauth'),
+       (r'^auth/(\d+)/logout/$', 'pgweb.account.views.communityauth_logout'),
+       (r'^auth/(\d+)/search/$', 'pgweb.account.views.communityauth_search'),
 
        # Profile
-       (r'^profile/$', 'account.views.profile'),
-    (r'^profile/change_email/$', 'account.views.change_email'),
-    (r'^profile/change_email/([0-9a-f]+)/$', 'account.views.confirm_change_email'),
-
-    # List of items to edit
-    (r'^edit/(.*)/$', 'account.views.listobjects'),
-
-    # News & Events
-    (r'^news/(.*)/$', 'news.views.form'),
-    (r'^events/(.*)/$', 'events.views.form'),
-
-    # Software catalogue
-    (r'^organisations/(.*)/$', 'core.views.organisationform'),
-    (r'^products/(.*)/$', 'downloads.views.productform'),
-
-    # Organisation information
-       (r'^orglist/$', 'account.views.orglist'),
-
-    # Professional services
-    (r'^services/(.*)/$', 'profserv.views.profservform'),
-
-    # Docs comments
-    (r'^comments/(new)/(.*)/(.*)/$', 'docs.views.commentform'),
-
-    # Log in, logout, change password etc
-    (r'^login/$', 'account.views.login'),
-    (r'^logout/$', 'account.views.logout'),
-       (r'^changepwd/$', 'account.views.changepwd'),
-       (r'^changepwd/done/$', 'account.views.change_done'),
-       (r'^reset/$', 'account.views.resetpwd'),
-       (r'^reset/done/$', 'account.views.reset_done'),
-       (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'account.views.reset_confirm'),
-       (r'^reset/complete/$', 'account.views.reset_complete'),
-       (r'^signup/$', 'account.views.signup'),
-       (r'^signup/complete/$', 'account.views.signup_complete'),
+       (r'^profile/$', 'pgweb.account.views.profile'),
+       (r'^profile/change_email/$', 'pgweb.account.views.change_email'),
+       (r'^profile/change_email/([0-9a-f]+)/$', 'pgweb.account.views.confirm_change_email'),
+
+       # List of items to edit
+       (r'^edit/(.*)/$', 'pgweb.account.views.listobjects'),
+
+       # News & Events
+       (r'^news/(.*)/$', 'pgweb.news.views.form'),
+       (r'^events/(.*)/$', 'pgweb.events.views.form'),
+
+       # Software catalogue
+       (r'^organisations/(.*)/$', 'pgweb.core.views.organisationform'),
+       (r'^products/(.*)/$', 'pgweb.downloads.views.productform'),
+
+       # Organisation information
+       (r'^orglist/$', 'pgweb.account.views.orglist'),
+
+       # Professional services
+       (r'^services/(.*)/$', 'pgweb.profserv.views.profservform'),
+
+       # Docs comments
+       (r'^comments/(new)/(.*)/(.*)/$', 'pgweb.docs.views.commentform'),
+
+       # Log in, logout, change password etc
+       (r'^login/$', 'pgweb.account.views.login'),
+       (r'^logout/$', 'pgweb.account.views.logout'),
+       (r'^changepwd/$', 'pgweb.account.views.changepwd'),
+       (r'^changepwd/done/$', 'pgweb.account.views.change_done'),
+       (r'^reset/$', 'pgweb.account.views.resetpwd'),
+       (r'^reset/done/$', 'pgweb.account.views.reset_done'),
+       (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'pgweb.account.views.reset_confirm'),
+       (r'^reset/complete/$', 'pgweb.account.views.reset_complete'),
+       (r'^signup/$', 'pgweb.account.views.signup'),
+       (r'^signup/complete/$', 'pgweb.account.views.signup_complete'),
 )
index 9875ca0584a9994a26004cdf5dbd296a033d3e88..c674615957bdf4b2b676040ba8a55491f6a05bbc 100644 (file)
@@ -1,5 +1,5 @@
-from django.conf.urls.defaults import *
-from django.views.generic.simple import redirect_to
+from django.conf.urls import patterns, include, url
+from django.views.generic import RedirectView
 
 # Register our save signal handlers
 from pgweb.util.signals import register_basic_signal_handlers
@@ -11,149 +11,149 @@ admin.autodiscover()
 
 
 # dict with all the RSS feeds we can serve
-from core.feeds import VersionFeed
-from news.feeds import NewsFeed
-from events.feeds import EventFeed
-from pwn.feeds import PwnFeed
+from pgweb.core.feeds import VersionFeed
+from pgweb.news.feeds import NewsFeed
+from pgweb.events.feeds import EventFeed
+from pgweb.pwn.feeds import PwnFeed
 
 urlpatterns = patterns('',
-    (r'^$', 'pgweb.core.views.home'),
-    (r'^dyncss/(?P<css>base|docs).css$', 'pgweb.core.views.dynamic_css'),
-
-    (r'^about/newsarchive/$', 'news.views.archive'),
-    (r'^about/news/(\d+)(-.*)?/$', 'news.views.item'),
-    (r'^about/events/$', 'events.views.main'),
-    (r'^about/eventarchive/$', 'events.views.archive'),
-    (r'^about/eventarchive/training/$', 'events.views.trainingarchive'),
-    (r'^about/event/(\d+)(-.*)?/$', 'events.views.item'),
-    (r'^about/featurematrix/$', 'featurematrix.views.root'),
-    (r'^about/featurematrix/detail/(\d+)/$', 'featurematrix.views.detail'),
-    (r'^about/quotesarchive/$', 'quotes.views.allquotes'),
-    
-    (r'^ftp/(.*/)?$', 'downloads.views.ftpbrowser'),
-    (r'^download/mirrors-ftp/+(.*)$', 'downloads.views.mirrorselect'),
-    (r'^download/product-categories/$', 'downloads.views.categorylist'),
-    (r'^download/products/(\d+)(-.*)?/$', 'downloads.views.productlist'),
-    (r'^redir/(\d+)/([hf])/([a-zA-Z0-9/\._-]+)$', 'downloads.views.mirror_redirect'),
-    (r'^redir$', 'downloads.views.mirror_redirect_old'),
-    (r'^mirrors.xml$', 'downloads.views.mirrors_xml'),
-    (r'^applications-v2.xml$', 'downloads.views.applications_v2_xml'),
-    (r'^download/uploadftp/', 'downloads.views.uploadftp'),
-
-    (r'^docs/$', 'docs.views.root'),
-    (r'^docs/manuals/$', 'docs.views.manuals'),
-    (r'^docs/manuals/archive/$', 'docs.views.manualarchive'),
-    (r'^docs/(current|devel|\d\.\d)/(static|interactive)/(.*).html?$', 'docs.views.docpage'),
-    (r'^docs/(current|devel|\d\.\d)/(static|interactive)/$', 'docs.views.docsrootpage'),
-    (r'^docs/(current|devel|\d\.\d)/$', 'docs.views.redirect_root'),
-
-    (r'^community/$', 'core.views.community'),
-    (r'^community/contributors/$', 'contributors.views.completelist'),
-    (r'^community/lists/$', redirect_to, {'url': '/list/'}),
-    (r'^community/lists/subscribe/$', 'lists.views.subscribe'),
-    (r'^community/lists/listinfo/$', 'lists.views.listinfo'),
-    (r'^community/survey/vote/(\d+)/$', 'survey.views.vote'),
-    (r'^community/survey[/\.](\d+)(-.*)?/$', 'survey.views.results'),
-    (r'^community/user-groups/$', 'pugs.views.index'),
-       (r'^community/weeklynews/$', 'pwn.views.index'),
-       (r'^community/weeklynews/pwn(\d{4})(\d{2})(\d{2})/$', 'pwn.views.post'),
-
-    (r'^search/$', 'search.views.search'),
-
-    (r'^support/professional_(support|hosting)/$', 'profserv.views.root'),
-    (r'^support/professional_(support|hosting)[/_](.*)/$', 'profserv.views.region'),
-    (r'^support/submitbug/$', 'misc.views.submitbug'),
-    (r'^support/versioning/$', 'core.views.versions'),
-
-    (r'^about/sponsors/$', 'pgweb.sponsors.views.sponsors'),
-    (r'^about/servers/$', 'pgweb.sponsors.views.servers'),
+       (r'^$', 'pgweb.core.views.home'),
+       (r'^dyncss/(?P<css>base|docs).css$', 'pgweb.core.views.dynamic_css'),
+
+       (r'^about/newsarchive/$', 'pgweb.news.views.archive'),
+       (r'^about/news/(\d+)(-.*)?/$', 'pgweb.news.views.item'),
+       (r'^about/events/$', 'pgweb.events.views.main'),
+       (r'^about/eventarchive/$', 'pgweb.events.views.archive'),
+       (r'^about/eventarchive/training/$', 'pgweb.events.views.trainingarchive'),
+       (r'^about/event/(\d+)(-.*)?/$', 'pgweb.events.views.item'),
+       (r'^about/featurematrix/$', 'pgweb.featurematrix.views.root'),
+       (r'^about/featurematrix/detail/(\d+)/$', 'pgweb.featurematrix.views.detail'),
+       (r'^about/quotesarchive/$', 'pgweb.quotes.views.allquotes'),
+
+       (r'^ftp/(.*/)?$', 'pgweb.downloads.views.ftpbrowser'),
+       (r'^download/mirrors-ftp/+(.*)$', 'pgweb.downloads.views.mirrorselect'),
+       (r'^download/product-categories/$', 'pgweb.downloads.views.categorylist'),
+       (r'^download/products/(\d+)(-.*)?/$', 'pgweb.downloads.views.productlist'),
+       (r'^redir/(\d+)/([hf])/([a-zA-Z0-9/\._-]+)$', 'pgweb.downloads.views.mirror_redirect'),
+       (r'^redir$', 'pgweb.downloads.views.mirror_redirect_old'),
+       (r'^mirrors.xml$', 'pgweb.downloads.views.mirrors_xml'),
+       (r'^applications-v2.xml$', 'pgweb.downloads.views.applications_v2_xml'),
+       (r'^download/uploadftp/', 'pgweb.downloads.views.uploadftp'),
+
+       (r'^docs/$', 'pgweb.docs.views.root'),
+       (r'^docs/manuals/$', 'pgweb.docs.views.manuals'),
+       (r'^docs/manuals/archive/$', 'pgweb.docs.views.manualarchive'),
+       (r'^docs/(current|devel|\d\.\d)/(static|interactive)/(.*).html?$', 'pgweb.docs.views.docpage'),
+       (r'^docs/(current|devel|\d\.\d)/(static|interactive)/$', 'pgweb.docs.views.docsrootpage'),
+       (r'^docs/(current|devel|\d\.\d)/$', 'pgweb.docs.views.redirect_root'),
+
+       (r'^community/$', 'pgweb.core.views.community'),
+       (r'^community/contributors/$', 'pgweb.contributors.views.completelist'),
+       (r'^community/lists/$', RedirectView.as_view(url='/list/', permanent=True)),
+       (r'^community/lists/subscribe/$', 'pgweb.lists.views.subscribe'),
+       (r'^community/lists/listinfo/$', 'pgweb.lists.views.listinfo'),
+       (r'^community/survey/vote/(\d+)/$', 'pgweb.survey.views.vote'),
+       (r'^community/survey[/\.](\d+)(-.*)?/$', 'pgweb.survey.views.results'),
+       (r'^community/user-groups/$', 'pgweb.pugs.views.index'),
+       (r'^community/weeklynews/$', 'pgweb.pwn.views.index'),
+       (r'^community/weeklynews/pwn(\d{4})(\d{2})(\d{2})/$', 'pgweb.pwn.views.post'),
+
+       (r'^search/$', 'pgweb.search.views.search'),
+
+       (r'^support/professional_(support|hosting)/$', 'pgweb.profserv.views.root'),
+       (r'^support/professional_(support|hosting)[/_](.*)/$', 'pgweb.profserv.views.region'),
+       (r'^support/submitbug/$', 'pgweb.misc.views.submitbug'),
+       (r'^support/versioning/$', 'pgweb.core.views.versions'),
+
+       (r'^about/sponsors/$', 'pgweb.sponsors.views.sponsors'),
+       (r'^about/servers/$', 'pgweb.sponsors.views.servers'),
 
        (r'^robots.txt$', 'pgweb.core.views.robots'),
 
-    ###
-    # RSS feeds
-    ###
-    (r'^versions.rss$', VersionFeed()),
-    (r'^news.rss$', NewsFeed()),
-    (r'^events.rss$', EventFeed()),
-    (r'^weeklynews.rss$', PwnFeed()),
+       ###
+       # RSS feeds
+       ###
+       (r'^versions.rss$', VersionFeed()),
+       (r'^news.rss$', NewsFeed()),
+       (r'^events.rss$', EventFeed()),
+       (r'^weeklynews.rss$', PwnFeed()),
 
-    ###
-    # Special sections
-    ###
-    (r'^account/', include('account.urls')),
+       ###
+       # Special sections
+       ###
+       (r'^account/', include('pgweb.account.urls')),
 
        ###
        # Sitemap (FIXME: support for >50k urls!)
        ###
        (r'^sitemap.xml', 'pgweb.core.views.sitemap'),
 
-    ###
-    # Workaround for broken links pushed in press release
-    ###
-    (r'^downloads/$', redirect_to, {'url': '/download/'}),
-
-    ###
-    # Legacy URLs from the old website, that are likely to be used from other
-    # sites or press releases or such
-    ###
-    (r'^about/press/presskit(\d+)\.html\.(\w+)$', 'pgweb.legacyurl.views.presskit'),
-    (r'^about/news\.(\d+)$', 'pgweb.legacyurl.views.news'),
-    (r'^about/event\.(\d+)$', 'pgweb.legacyurl.views.event'),
-    (r'^community/signup', 'pgweb.legacyurl.views.signup'),
-
-    ###
-    # Images that are used from other community sites
-    ###
-    (r'^layout/images/(?P<f>[a-z0-9_\.]+)$', redirect_to, {'url': '/media/img/layout/%(f)s' }),
-    ###
-    # These URLs were legacy even on the old site...
-    ###
-    (r'^developer/sourcecode/$', redirect_to, {'url': '/developer/coding/' }),
-    (r'^developer/bios/$', redirect_to, {'url': '/community/contributors/' }),
-    (r'^docs/techdocs.*', redirect_to, {'url': 'https://wiki.postgresql.org/' }),
-    (r'^docs/faqs.FAQ.html$', redirect_to, {'url': 'https://wiki.postgresql.org/wiki/FAQ' }),
-    (r'^docs/faqs.FAQ_DEV.*', redirect_to, {'url': 'https://wiki.postgresql.org/wiki/Development_information' }),
-    (r'^docs/faqs.TODO.*', redirect_to, {'url': 'https://wiki.postgresql.org/wiki/Todo' }),
-    (r'^about/license/$', redirect_to, {'url': '/about/licence'}),
-
-    ###
-    # Links included in emails on the lists (do we need to check this for XSS?)
-    ###
-    (r'^mailpref/([a-z0-9_-]+)/$', 'pgweb.legacyurl.views.mailpref'),
-
-    # Some basic information about the connection (for debugging purposes)
+       ###
+       # Workaround for broken links pushed in press release
+       ###
+       (r'^downloads/$', RedirectView.as_view(url='/download/', permanent=True)),
+
+       ###
+       # Legacy URLs from the old website, that are likely to be used from other
+       # sites or press releases or such
+       ###
+       (r'^about/press/presskit(\d+)\.html\.(\w+)$', 'pgweb.legacyurl.views.presskit'),
+       (r'^about/news\.(\d+)$', 'pgweb.legacyurl.views.news'),
+       (r'^about/event\.(\d+)$', 'pgweb.legacyurl.views.event'),
+       (r'^community/signup', 'pgweb.legacyurl.views.signup'),
+
+       ###
+       # Images that are used from other community sites
+       ###
+       (r'^layout/images/(?P<f>[a-z0-9_\.]+)$', RedirectView.as_view(url='/media/img/layout/%(f)s', permanent=True)),
+       ###
+       # These URLs were legacy even on the old site...
+       ###
+       (r'^developer/sourcecode/$', RedirectView.as_view(url='/developer/coding/', permanent=True)),
+       (r'^developer/bios/$', RedirectView.as_view(url='/community/contributors/', permanent=True)),
+       (r'^docs/techdocs.*', RedirectView.as_view(url='https://wiki.postgresql.org/', permanent=True)),
+       (r'^docs/faqs.FAQ.html$', RedirectView.as_view(url='https://wiki.postgresql.org/wiki/FAQ', permanent=True)),
+       (r'^docs/faqs.FAQ_DEV.*', RedirectView.as_view(url='https://wiki.postgresql.org/wiki/Development_information', permanent=True)),
+       (r'^docs/faqs.TODO.*', RedirectView.as_view(url='https://wiki.postgresql.org/wiki/Todo', permanent=True)),
+       (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?)
+       ###
+       (r'^mailpref/([a-z0-9_-]+)/$', 'pgweb.legacyurl.views.mailpref'),
+
+       # Some basic information about the connection (for debugging purposes)
        (r'^system_information/$', 'pgweb.core.views.system_information'),
        (r'^system_information_ssl/$', 'pgweb.core.views.system_information_ssl'),
        # Sync timestamp, for automirror
        (r'^web_sync_timestamp$', 'pgweb.core.views.sync_timestamp'),
 
-    # API endpoints
-    (r'^api/varnish/purge/$', 'pgweb.core.views.api_varnish_purge'),
+       # API endpoints
+       (r'^api/varnish/purge/$', 'pgweb.core.views.api_varnish_purge'),
 
-    # Pingback from git repo to update site
-    (r'^api/repo_updated/$', 'pgweb.core.views.api_repo_updated'),
+       # Pingback from git repo to update site
+       (r'^api/repo_updated/$', 'pgweb.core.views.api_repo_updated'),
 
        # Override some URLs in admin, to provide our own pages
        (r'^admin/pending/$', 'pgweb.core.views.admin_pending'),
        (r'^admin/purge/$', 'pgweb.core.views.admin_purge'),
        (r'^admin/mergeorg/$', 'pgweb.core.views.admin_mergeorg'),
 
-    # Uncomment the next line to enable the admin:
-    (r'^admin/', include(admin.site.urls)),
+       # Uncomment the next line to enable the admin:
+       (r'^admin/', include(admin.site.urls)),
 
-    # This should not happen in production - serve by the webserver natively!
-    url(r'^(favicon.ico)$', 'django.views.static.serve', {
-        'document_root': '../media',
-    }),
+       # This should not happen in production - serve by the webserver natively!
+       url(r'^(favicon.ico)$', 'django.views.static.serve', {
+               'document_root': 'media',
+       }),
 
-    # Crash testing URL :-)
-    (r'^crashtest/$', 'pgweb.misc.views.crashtest'),
+       # Crash testing URL :-)
+       (r'^crashtest/$', 'pgweb.misc.views.crashtest'),
 
        # If we're getting an attempt for something ending in HTML, just get rid of it
        (r'^(.*)\.html$', 'pgweb.legacyurl.views.html_extension'),
 
-    # Fallback for static pages, must be at the bottom
-    (r'^(.*)/$', 'pgweb.core.views.fallback'),
+       # Fallback for static pages, must be at the bottom
+       (r'^(.*)/$', 'pgweb.core.views.fallback'),
 )