Skip to content

Commit

Permalink
#49 #51 Updated the Default List view and the specific list view gene…
Browse files Browse the repository at this point in the history
…ration.
  • Loading branch information
jcaraballo17 committed Nov 3, 2020
1 parent 859efa8 commit b60713a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ <h2>
<div class="clear"></div>
<h4>{{ vocabulary_def }}</h4>
<div class="vocabulary-links">
<a id="btnAddNew" href="{% url create_url %}" class="button white">New</a>
<a id="btnAddNew" href="{% url create_url_name %}" class="button white">New</a>
<a id="btnSKOSVocab" target="_blank" href="{# {% url 'api_dispatch_list' resource_name=vocabulary api_name='v1' %}#}?format=skos" class="button white">View in SKOS</a>
<a id="btnSKOS" download="{{ vocabulary }}.rdf" href="{# {% url 'api_dispatch_list' resource_name=vocabulary api_name='v1' %} #}?format=skos" class="button white">Download Vocabulary (SKOS)</a>
<a id="btnCSV" download="{{ vocabulary }}.csv" href="{# {% url 'api_dispatch_list' resource_name=vocabulary api_name='v1' %} #}?format=csv" class="button white">Download Vocabulary (CSV)</a>
<a id="btnSKOS" download="{{ vocabulary_code }}.rdf" href="{# {% url 'api_dispatch_list' resource_name=vocabulary api_name='v1' %} #}?format=skos" class="button white">Download Vocabulary (SKOS)</a>
<a id="btnCSV" download="{{ vocabulary_code }}.csv" href="{# {% url 'api_dispatch_list' resource_name=vocabulary api_name='v1' %} #}?format=csv" class="button white">Download Vocabulary (CSV)</a>
</div>
</header>
<div class="column three-columns">
Expand All @@ -32,9 +32,9 @@ <h4>{{ vocabulary_def }}</h4>
</tr>
</thead>
<tbody>
{% for concept in object_list %}
{% for concept in concepts_list %}
<tr>
<td><a href="{% url detail_url concept.term %}">{{ concept.term }}</a></td>
<td><a href="{% url detail_url_name concept.term %}">{{ concept.term }}</a></td>
<td>{{ concept.name }}</td>
<td>{{ concept.definition }}</td>
</tr>
Expand Down
23 changes: 12 additions & 11 deletions src/cvinterface/views/base_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@

# Vocabulary Basic Views
from cvservices.models import ControlledVocabularyRequest, Unit
from odm2cvs.controlled_vocabularies import Vocabulary


class DefaultVocabularyListView(ListView):
vocabulary = None
vocabulary_verbose = None
vocabulary_def = None
context_object_name: str = 'concepts_list'
vocabulary: Vocabulary = {}
vocabulary_code: str = ''

def __init__(self, **kwargs):
self.vocabulary = kwargs['vocabulary']
self.vocabulary_verbose = kwargs['vocabulary_verbose']
self.vocabulary_def = kwargs['vocabulary_def']
self.vocabulary = kwargs.get('vocabulary')
self.vocabulary_code = kwargs.get('vocabulary_code')
self.model = self.vocabulary.get('model')
super(DefaultVocabularyListView, self).__init__(**kwargs)

def get_context_data(self, **kwargs):
context = super(DefaultVocabularyListView, self).get_context_data(**kwargs)
context['vocabulary_verbose'] = self.vocabulary_verbose
context['create_url'] = self.vocabulary + 'request_form'
context['detail_url'] = self.vocabulary + '_detail'
context['vocabulary_def'] = self.vocabulary_def
context['vocabulary'] = self.vocabulary
context['vocabulary_verbose_name'] = self.vocabulary.get('name')
context['vocabulary_description'] = self.vocabulary.get('description')
context['create_url_name'] = self.vocabulary.get('request').get('create_url_name')
context['detail_url_name'] = self.vocabulary.get('detail_url_name')
context['vocabulary_code'] = self.vocabulary_code
return context

def get_queryset(self):
Expand Down
11 changes: 5 additions & 6 deletions src/cvinterface/views/vocabulary_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
list_views = {}
detail_views = {}

for vocabulary_name, vocabulary in vocabularies.items():
for vocabulary_code, vocabulary in vocabularies.items():
# list view
list_views[vocabulary_name] = vocabulary.get('list_view', defaults['list_view']).as_view(
vocabulary=vocabulary_name, vocabulary_def=vocabulary.get('description'),
vocabulary_verbose=vocabulary.get('name'), model=vocabulary.get('model'),
list_views[vocabulary_code] = vocabulary.get('list_view', defaults['list_view']).as_view(
vocabulary=vocabulary, vocabulary_code=vocabulary_code,
template_name=vocabulary.get('list_template', defaults['list_template'])
)

# detail view
detail_views[vocabulary_name] = vocabulary.get('list_view', defaults['detail_view']).as_view(
vocabulary=vocabulary_name, vocabulary_verbose=vocabulary.get('name'),
detail_views[vocabulary_code] = vocabulary.get('list_view', defaults['detail_view']).as_view(
vocabulary=vocabulary_code, vocabulary_verbose=vocabulary.get('name'),
model=vocabulary.get('model'), template_name=vocabulary.get('detail_template', defaults['detail_template'])
)

Expand Down

0 comments on commit b60713a

Please sign in to comment.