Skip to content

Commit

Permalink
Add link to "List Datapackage" for the Person Detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
cpina committed Oct 14, 2020
1 parent 62bf3e3 commit 5593a07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
{% block main_contents %}
<h1>Person detail</h1>
<strong>Name:</strong> {% include 'core/_value-or-dash.tmpl' with value=person.full_name only %}

<p></p>

<strong>Created on:</strong> {% include 'core/_value-or-dash.tmpl' with value=person.created_on only %}<br>
<strong>Modified on:</strong> {% include 'core/_value-or-dash.tmpl' with value=person.modified_on only %}<br>
<p></p>

<a href="{% url 'management:person-update' pk=person.id %}" class="btn btn-primary">Edit</a>
<a href="{{ person.list_datapackages_url }}" class="btn btn-primary">List Datapackages</a>
{% include 'core/_clipboard-button.html' with class="btn btn-primary" url=person.list_datapackages_url id='copy_edit_link' button_text='Copy List Datapackages' only %}
{% endblock %}
13 changes: 10 additions & 3 deletions SchemaCollaboration/management/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def get_context_data(self, **kwargs):
return context


def add_list_datapackage_url_to_person(person, request):
person.list_datapackages_url = request.build_absolute_uri(
reverse('datapackage-list', kwargs={'collaborator_uuid': person.uuid}
))


class PersonListView(PersonMixin, ListView):
template_name = 'management/person-list.html'
model = Person
Expand All @@ -45,9 +51,7 @@ def get_context_data(self, **kwargs):
context['breadcrumb'] = [{'name': 'People'}]

for person in context['people']:
person.list_datapackages_url = self.request.build_absolute_uri(
reverse('datapackage-list', kwargs={'collaborator_uuid': person.uuid}
))
add_list_datapackage_url_to_person(person, self.request)

return context

Expand Down Expand Up @@ -89,6 +93,9 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['breadcrumb'] = [{'name': 'People', 'url': reverse('management:list-people')},
{'name': 'Detail'}]

add_list_datapackage_url_to_person(context['person'], self.request)

return context


Expand Down

0 comments on commit 5593a07

Please sign in to comment.