diff --git a/label/templates/label/releases.html b/label/templates/label/releases.html
index 08e9d1c..e20c8df 100644
--- a/label/templates/label/releases.html
+++ b/label/templates/label/releases.html
@@ -14,7 +14,7 @@
{% for release in releases %}
- {{ release.ident }}
+ {{ release.tag }}
|
@@ -24,7 +24,7 @@
|
- {{ release.title }}
+ {{ release.title }}
{% if release.release_type == 1 %}(EP){% endif %}
{% if release.release_type == 2 %}(Split){% endif %}
{% if release.release_type == 3 %}(Demo){% endif %}
diff --git a/label/tools.py b/label/tools.py
index 0444773..40a90b8 100644
--- a/label/tools.py
+++ b/label/tools.py
@@ -1,6 +1,12 @@
-def get_catalog_tag(ident):
+def get_catalog_tag_from_id(ident):
return "IDRE{:0>3d}".format(ident)
+def get_id_from_catalog_tag(tag):
+ try:
+ return int(tag[4:])
+ except ValueError:
+ return -1
+
def get_contribs(contributors):
contrib_list = []
diff --git a/label/views.py b/label/views.py
index bdea82e..6a3328a 100644
--- a/label/views.py
+++ b/label/views.py
@@ -27,10 +27,12 @@ def releases(request):
releases_and_infos = []
for release in releases:
+ release_tag = tools.get_catalog_tag_from_id(release.ident)
releases_and_infos.append({
"id": release.id,
"release_type": release.release_type,
- "ident": tools.get_catalog_tag(release.ident),
+ "tag": release_tag,
+ "tag_lower": release_tag.lower(),
"title": release.title,
"contribs": tools.get_contribs(release.contributors.all()),
"year": release.year
@@ -40,8 +42,9 @@ def releases(request):
return render(request, "label/releases.html", context)
-def release(request, rid):
- release = Release.objects.get(id = rid)
+def release(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())
context = { "release": release, "contribs": contribs }
return render(request, "label/release.html", context)
|