From fe7b68fcc995e6b9c66ad2d9d3700dff8a0b5d2c Mon Sep 17 00:00:00 2001 From: Shgck Date: Mon, 1 Feb 2016 19:04:09 +0100 Subject: [PATCH] Move label urls to their own module instead of polluting idre.urls --- idre/urls.py | 12 +++++------- label/urls.py | 11 +++++++++++ label/views.py | 18 +++++------------- 3 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 label/urls.py diff --git a/idre/urls.py b/idre/urls.py index 3845ae4..9c300a2 100644 --- a/idre/urls.py +++ b/idre/urls.py @@ -3,19 +3,17 @@ from django.conf.urls.static import static from django.contrib import admin import idre.settings -import label.views +import idre.views +import label.urls admin.autodiscover() urlpatterns = [ - url(r"^$", label.views.home, name = "home"), - url(r"^artists/$", label.views.artists, name = "artists"), - url(r"^artists/(?P\S+)$", label.views.artist, name = "artist"), - url(r"^releases/$", label.views.releases, name = "releases"), - url(r"^releases/(?P\S+)$", label.views.release, name = "release"), - url(r"^admin/", include(admin.site.urls)), + url(r"^$", idre.views.home, name = "home") +] + label.urls.urlpatterns + [ + url(r"^admin/", include(admin.site.urls)) ] if idre.settings.DEBUG: diff --git a/label/urls.py b/label/urls.py new file mode 100644 index 0000000..ccbfc70 --- /dev/null +++ b/label/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls import url + +import label.views + + +urlpatterns = [ + url(r"^artists/$", label.views.artists_view, name = "artists"), + url(r"^artists/(?P\S+)$", label.views.artist_view, name = "artist"), + url(r"^releases/$", label.views.releases_view, name = "releases"), + url(r"^releases/(?P\S+)$", label.views.release_view, name = "release") +] diff --git a/label/views.py b/label/views.py index c83fc59..54c93dd 100644 --- a/label/views.py +++ b/label/views.py @@ -1,22 +1,16 @@ -import markdown - from django.shortcuts import get_object_or_404, render +import markdown from label.models import Artist, Release import label.tools as tools -def home(request): - return render(request, "label/home.html") - - -def artists(request): +def artists_view(request): artists = Artist.objects.all() context = { "artists": artists } return render(request, "label/artists.html", context) - -def artist(request, slug): +def artist_view(request, slug): artist = get_object_or_404(Artist, slug = slug) artist.description = markdown.markdown(artist.description) @@ -27,8 +21,7 @@ def artist(request, slug): context = { "artist": artist, "releases": releases } return render(request, "label/artist.html", context) - -def releases(request): +def releases_view(request): artists = Artist.objects.all() releases = Release.objects.all() @@ -47,8 +40,7 @@ def releases(request): context = { "releases": releases_and_infos } return render(request, "label/releases.html", context) - -def release(request, tag): +def release_view(request, tag): ident = tools.get_id_from_catalog_tag(tag) release = get_object_or_404(Release, ident = ident) contribs = tools.get_contribs(release.contributors.all())