euscanwww: fixing urls.py to be more DRY

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-11-01 16:25:32 +01:00
parent 48c1eadab4
commit 1abc4d409e

View File

@ -15,63 +15,46 @@ admin_required = user_passes_test(lambda u: u.is_superuser)
package_patterns = patterns('djeuscan.views',
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/feed/$',
PackageFeed(), name='package_feed'),
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/$',
'package', name="package"),
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/favourite/$',
'favourite_package', name="favourite_package"),
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
'unfavourite/$'), 'unfavourite_package', name="unfavourite_package"),
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
'refresh$'), "refresh_package", name="refresh_package"),
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/problem$',
'problem', name="problem"),
url(r'^$', 'package', name="package"),
url(r'^feed/$', PackageFeed(), name='package_feed'),
url(r'^favourite/$', 'favourite_package', name="favourite_package"),
url(r'^unfavourite/$', 'unfavourite_package', name="unfavourite_package"),
url(r'^refresh$', "refresh_package", name="refresh_package"),
url(r'^problem$', 'problem', name="problem"),
)
categories_patterns = patterns('djeuscan.views',
url(r'^(?P<category>[\w+][\w+.-]*)/(view/)?$', 'category',
name="category"),
url(r'^(?P<category>[\w+][\w+.-]*)/feed/$', CategoryFeed(),
name='category_feed'),
url(r'^(?P<category>[\w+][\w+.-]*)/charts/(?P<chart>[\w\-]+).png$',
'chart_category', name="chart_category"),
url(r'^(?P<category>[\w+][\w+.-]*)/favourite/$',
'favourite_category', name="favourite_category"),
url(r'^(?P<category>[\w+][\w+.-]*)/unfavourite/$',
'unfavourite_category', name="unfavourite_category"),
url(r'^$', 'categories', name="categories"),
url(r'^(?:view/)?$', 'category', name="category"),
url(r'^feed/$', CategoryFeed(), name='category_feed'),
url(r'^charts/(?P<chart>[\w\-]+).png$', 'chart_category',
name="chart_category"),
url(r'^favourite/$', 'favourite_category', name="favourite_category"),
url(r'^unfavourite/$', 'unfavourite_category',
name="unfavourite_category"),
)
herds_patterns = patterns('djeuscan.views',
url(r'^(?P<herd>[\@\{\}\w+.-]*)/(view/)?$', 'herd', name="herd"),
url(r'^(?P<herd>[\@\{\}\w+.-]*)/feed/$', HerdFeed(), name='herd_feed'),
url(r'^(?P<herd>[\@\{\}\w+.-]*)/charts/(?P<chart>[\w\-]+).png$',
'chart_herd', name="chart_herd"),
url(r'^(?P<herd>[\@\{\}\w+.-]*)/favourite/$', 'favourite_herd',
name="favourite_herd"),
url(r'^(?P<herd>[\@\{\}\w+.-]*)/unfavourite/$', 'unfavourite_herd',
name="unfavourite_herd"),
url(r'^$', 'herds', name="herds"),
url(r'^(?:view/)?$', 'herd', name="herd"),
url(r'^feed/$', HerdFeed(), name='herd_feed'),
url(r'^charts/(?P<chart>[\w\-]+).png$', 'chart_herd', name="chart_herd"),
url(r'^favourite/$', 'favourite_herd', name="favourite_herd"),
url(r'^unfavourite/$', 'unfavourite_herd', name="unfavourite_herd"),
)
prefix = '^((?P<maintainer_id>\d+)|(?P<maintainer_email>[^/]+))'
maintainers_patterns = patterns('djeuscan.views',
url(prefix + r'/(view/)?$', 'maintainer', name="maintainer"),
url(prefix + r'/feed/$', MaintainerFeed(), name='maintainer_feed'),
url(prefix + r'/charts/(?P<chart>[\w\-]+).png$', 'chart_maintainer', name="chart_maintainer"),
url(prefix + r'/favourite/$', 'favourite_maintainer', name="favourite_maintainer"),
url(prefix + r'/unfavourite/$', 'unfavourite_maintainer', name="unfavourite_maintainer"),
url(r'^$', 'maintainers', name="maintainers"),
url(r'^(?:view/)?$', 'maintainer', name="maintainer"),
url(r'^feed/$', MaintainerFeed(), name='maintainer_feed'),
url(r'^charts/(?P<chart>[\w\-]+).png$', 'chart_maintainer',
name="chart_maintainer"),
url(r'^favourite/$', 'favourite_maintainer', name="favourite_maintainer"),
url(r'^unfavourite/$', 'unfavourite_maintainer',
name="unfavourite_maintainer"),
)
overlays_patterns = patterns('djeuscan.views',
url(r'^(?P<overlay>[\w+][\w+.-]*)/(view/)?$', 'overlay', name="overlay"),
url(r'^(?P<overlay>[\w+][\w+.-]*)/favourite/$', 'favourite_overlay',
name="favourite_overlay"),
url(r'^(?P<overlay>[\w+][\w+.-]*)/unfavourite/$', 'unfavourite_overlay',
name="unfavourite_overlay"),
url(r'^$', 'overlays', name="overlays"),
url(r'^(?:view/)?$', 'overlay', name="overlay"),
url(r'^favourite/$', 'favourite_overlay', name="favourite_overlay"),
url(r'^unfavourite/$', 'unfavourite_overlay', name="unfavourite_overlay"),
)
tasks_patterns = patterns('djeuscan.views',
@ -121,11 +104,24 @@ urlpatterns = patterns('djeuscan.views',
name="unfavourite_world"),
# Real data
url(r'^categories/', include(categories_patterns)),
url(r'^herds/', include(herds_patterns)),
url(r'^maintainers/', include(maintainers_patterns)),
url(r'^overlays/', include(overlays_patterns)),
url(r'^package/', include(package_patterns)),
url(r'^categories/$', 'categories', name="categories"),
url(r'^categories/(?P<category>[\w+][\w+.-]*)/',
include(categories_patterns)),
url(r'^herds/$', 'herds', name="herds"),
url(r'^herds/(?P<herd>[\@\{\}\w+.-]+)/', include(herds_patterns)),
url(r'^maintainers/$', 'maintainers', name="maintainers"),
url(r'^maintainers/(?P<maintainer_id>\d+)/',
include(maintainers_patterns)),
url(r'^maintainers/(?P<maintainer_email>[^/]+)/',
include(maintainers_patterns)),
url(r'^overlays/$', 'overlays', name="overlays"),
url(r'^overlays/(?P<overlay>[\w+][\w+.-]*)/', include(overlays_patterns)),
url(r'^package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/',
include(package_patterns)),
url(r'^tasks/', include(tasks_patterns)),
url(r'^accounts/', include(accounts_patterns)),