1
0
Fork 0

Links to releases now with "idreXXX" tag and not internal ID

This commit is contained in:
Shgck 2015-05-02 14:34:53 +02:00
parent 85b66a87ee
commit 3669857f3d
3 changed files with 15 additions and 6 deletions

View file

@ -14,7 +14,7 @@
{% for release in releases %}
<tr class="release">
<td>
{{ release.ident }}
{{ release.tag }}
</td>
<td>
@ -24,7 +24,7 @@
</td>
<td>
<a href="{% url 'release' release.id %}">{{ release.title }}</a>
<a href="{% url 'release' release.tag_lower %}">{{ release.title }}</a>
{% if release.release_type == 1 %}(EP){% endif %}
{% if release.release_type == 2 %}(Split){% endif %}
{% if release.release_type == 3 %}(Demo){% endif %}

View file

@ -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 = []

View file

@ -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)