Move label urls to their own module instead of polluting idre.urls
This commit is contained in:
parent
582520ddff
commit
fe7b68fcc9
12
idre/urls.py
12
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<slug>\S+)$", label.views.artist, name = "artist"),
|
||||
url(r"^releases/$", label.views.releases, name = "releases"),
|
||||
url(r"^releases/(?P<tag>\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:
|
||||
|
|
11
label/urls.py
Normal file
11
label/urls.py
Normal file
|
@ -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<slug>\S+)$", label.views.artist_view, name = "artist"),
|
||||
url(r"^releases/$", label.views.releases_view, name = "releases"),
|
||||
url(r"^releases/(?P<tag>\S+)$", label.views.release_view, name = "release")
|
||||
]
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue