Skip to content

Commit 4586a50

Browse files
committed
#48 Updated Vocabularies detail template.
1 parent ad25036 commit 4586a50

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/cvinterface/templates/cvinterface/vocabularies/default_detail.html

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends 'cvinterface/base.html' %}
2+
{% load tools %}
23

34
{% block title %}
45
<title>ODM2 CV term: {{ concept.term }}</title>
@@ -10,19 +11,19 @@
1011
<h2>
1112
{{ concept.name }}<span class="vocabulary-type">{{ vocabulary_verbose_name }}</span>
1213
<span class="parent-link">
13-
<a href="{% url vocabulary_code %}" class="tooltip" data-tip="Navigate to the {{ vocabulary_verbose_name }} vocabulary list."></a>
14+
<a href="{{ list_url }}" class="tooltip" data-tip="Navigate to the {{ vocabulary_verbose_name }} vocabulary list."></a>
1415
</span>
1516
</h2>
1617
<h4>{{ concept.definition }}</h4>
17-
{% if concept.vocabulary_status == 'Archived' %}
18-
<h4>NOTE: This is an archived version of this term. There is a <a href="{% url detail_url_name concept.revised_version.term concept.revised_version.pk %}">new version</a> available.</h4>
18+
{% if concept.vocabulary_status == ARCHIVED %}
19+
<h4>NOTE: This is an archived version of this term. There is a <a href="{% detail_url concept.revised_version %}">new version</a> available.</h4>
1920
{% endif %}
2021
<div class="vocabulary-links">
2122
{% if concept.vocabulary_status != ARCHIVED %}
22-
<a id="btnEdit" href="{% url create_url_name concept.pk %}" class="button white">Edit</a>
23-
<a id="btnSKOSTerm" target="_blank" href="{# {% url 'api_dispatch_detail' resource_name=vocabulary api_name='v1' term=concept.term %} #}?format=skos" class="button white">View in SKOS</a>
24-
<a id="btnSKOS" download="{{vocabulary_code}}_{{concept.term}}.rdf" href="{# {% url 'api_dispatch_detail' resource_name=vocabulary api_name='v1' term=concept.term %} #}?format=skos" target="_blank" class="button white">Download Term (SKOS)</a>
25-
<a id="btnSKOS" download="{{vocabulary_code}}_{{concept.term}}.csv" href="{# {% url 'api_dispatch_detail' resource_name=vocabulary api_name='v1' term=concept.term %} #}?format=csv" target="_blank" class="button white">Download Term (CSV)</a>
23+
<a id="btnEdit" href="{{ edit_url }}" class="button white">Edit</a>
24+
<a id="btnSKOSTerm" target="_blank" href="{{ api_url }}?format=skos" class="button white">View in SKOS</a>
25+
<a id="btnSKOS" download="{{vocabulary_code}}_{{concept.term}}.rdf" href="{{ api_url }}?format=skos" target="_blank" class="button white">Download Term (SKOS)</a>
26+
<a id="btnSKOS" download="{{vocabulary_code}}_{{concept.term}}.csv" href="{{ api_url }}?format=csv" target="_blank" class="button white">Download Term (CSV)</a>
2627
{% endif %}
2728
</div>
2829
</header>
@@ -43,7 +44,7 @@ <h4>NOTE: This is an archived version of this term. There is a <a href="{% url d
4344
<div class="column two-columns data-view">
4445
<h4>
4546
{% if concept.previous_version %}
46-
Previous version of this term: <br><a href="{% url detail_url_name concept.previous_version.term concept.previous_version.pk %}">{{ concept.previous_version.term }}</a> {{ concept.previous_version.definition }}
47+
Previous version of this term: <br><a href="{% detail_url concept.previous_version %}">{{ concept.previous_version.term }}</a> {{ concept.previous_version.definition }}
4748
{% endif %}
4849
</h4>
4950
</div>

src/cvinterface/templatetags/tools.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from django import template
22
from django.urls import reverse
33

4+
from cvservices.models import ControlledVocabulary
5+
46
register = template.Library()
57

68

79
@register.simple_tag(name='detail_url', takes_context=True)
8-
def get_detail_url(context, instance):
9-
return reverse(context['detail_url_name'], args=(instance.term,))
10+
def get_detail_url(context, instance: ControlledVocabulary):
11+
if instance.vocabulary_status == instance.CURRENT:
12+
return reverse(context['detail_url_name'], args=(instance.term,))
13+
else:
14+
return reverse(context['detail_url_name'], args=(instance.term, instance.pk))
1015

1116

1217
@register.filter

src/cvinterface/views/base_views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ def get_context_data(self, **kwargs):
7676
if field.name not in self.exclude
7777
)
7878
context['vocabulary_verbose_name'] = self.vocabulary.get('name')
79-
context['create_url_name'] = self.vocabulary.get('request').get('create_url_name')
8079
context['detail_url_name'] = self.vocabulary.get('detail_url_name')
80+
context['edit_url'] = reverse(self.vocabulary.get('request').get('create_url_name'), args=(self.object.pk, ))
81+
context['api_url'] = reverse(self.vocabulary.get('api_detail_url_name'), args=(self.object.term, ))
82+
context['list_url'] = reverse(self.vocabulary.get('list_url_name'))
8183
context['vocabulary_code'] = self.vocabulary_code
8284
context['ARCHIVED'] = self.model.ARCHIVED
8385
return context

src/odm2cvs/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# cv detail views
4646
urlpatterns += [
4747
path(f'{vocabulary_code}/<slug:term>/', detail_view, name=vocabulary.get('detail_url_name')),
48-
path(f'{vocabulary_code}/<slug:term>/<int:vocabulary_id>', detail_view, name=vocabulary.get('detail_url_name'))
48+
path(f'{vocabulary_code}/<slug:term>/<int:pk>', detail_view, name=vocabulary.get('detail_url_name'))
4949
]
5050

5151
# request list views

0 commit comments

Comments
 (0)