Skip to content

Commit

Permalink
detail view for YearBook (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 authored Apr 5, 2024
1 parent 9880cc5 commit 70e58a2
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 35 deletions.
151 changes: 116 additions & 35 deletions archiv/templates/archiv/yearbook_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,136 @@
{% load webpage_extras %}
{% block title %}{{ object.name }}{% endblock %}
{% block content %}
{% include 'archiv/partials/detailview_breadcrumb.html' %}
<div class="card">
<div class="card-header">
{% include 'archiv/partials/detailview_title.html' %}
</div>
<div class="card-body container">
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="{{ object.get_listview_url }}">{{ verbose_name_plural }}</a></li>
{% if object.part_of %}
<div class="text-center">
<h2>Parent Item</h2>
<a href="{{ object.part_of.get_absolute_url }}">{{ object.part_of }}</a>
</div>
<li class="breadcrumb-item"><a href="{{ object.part_of.get_absolute_url }}">{{ object.part_of.title }}</a></li>
{% endif %}
<li class="breadcrumb-item active" aria-current="page">{{ object.title }}</li>
</ol>
</nav>
{% include 'archiv/partials/detailview_title.html' %}
<div class="container">
{% if object.part_of %}
<h2>published in</h2>
<p class="ps-5">
<a href="{{ object.part_of.get_absolute_url }}">{{ object.part_of }}</a>
</p>
{% endif %}

{% if object.has_bibliographic_items.all %}
<h2 class="text-center">has bibliographic items</h2>
<ul>
{% for x in object.has_bibliographic_items.all %}
<li> <a href="{{ x.get_absolute_url }}">{{ x }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if object.has_bibliographic_items.all %}
<h2>has bibliographic items</h2>
<ul>
{% for x in object.has_bibliographic_items.all %}
<li> <a href="{{ x.get_absolute_url }}">{{ x }}</a></li>
{% endfor %}
</ul>
{% endif %}

{% if object.doi %}
<div class="text-center">
<h2>DOI</h2>
<a href="{{ object.doi }}">{{ object.doi }}</a>
</div>
{% endif %}
{% if object.doi %}
<h2>DOI</h2>
<p class="ps-5">
<a href="{{ object.doi }}">{{ object.doi }}</a>
</p>
{% endif %}

{% with courtdecissions=cases %}
<h2>{{ courtdecissions.count }} quoted cases</h2>
<table id="tabulatortable">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Court</th>
<th scope="col">Case Reference</th>
<th scope="col">Subject matter</th>
<th scope="col">Keywords</th>
</tr>
</thead>
<tbody>
{% for x in courtdecissions.all %}
<tr>
<td>{{ x.decission_date|date:"Y-m-d" }}</td>
<td>
{{ x.court }}
<a href="{{ x.court.get_absolute_url }}"><i class="bi bi-link-45deg"></i></a>
</td>
<td scope="row"><a href="{{ x.get_absolute_url }}">{{ x.case_reference }}</a></td>
<td scope="row">{{ x.short_description|safe }}</td>
<td>
<ul class="list-unstyled">
{% for y in x.keyword.all %}
<li>
<span class="badge rounded-pill text-bg-primary ">{{ y.name }}</span> <a
href="{{ y.get_absolute_url }}"><i class="bi bi-link-45deg"></i></a>
</li>
{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endwith %}

{% with courtdecissions=object.related_court_decission %}
<h2>{{ courtdecissions.count }} quoted Court Decissions</h2>
{% include "archiv/partials/courtdecission_table.html" %}
{% endwith %}



</div>
{% if user.is_authenticated %}
<div class="card-footer">
<div class="float-end">
<a href="{{ object.get_delete_url }}">
<i class="bi bi-trash3" title="delete entry"></i>
</a>
</div>

<div class="float-end">
<a href="{{ object.get_delete_url }}">
<i class="bi bi-trash3" title="delete entry"></i>
</a>
</div>
{% endif %}
</div>

{% endblock %}
{% block scripts2 %}
{% include "archiv/partials/courtdecission_table_js.html" %}
<script>
var table = new Tabulator("#tabulatortable", {
layout: "fitColumns",
responsiveLayout: "collapse",
height: 800,
columns: [
{
title: "Date",
field: "Date",
sorter: "string",
headerFilter: "input"
},
{
title: "Court",
field: "Court",
sorter: "string",
headerFilter: "input",
formatter: scrollHtml
},
{
title: "Case Reference",
field: "Case Reference",
sorter: "string",
headerFilter: "input",
formatter: "html"
},
{
title: "Subject matter",
field: "Subject matter",
sorter: "string",
headerFilter: "input",
formatter: scrollHtml
},
{
title: "Keywords",
field: "Keywords",
sorter: "string",
headerFilter: "input",
formatter: scrollHtml
}
]
});
</script>
{% endblock scripts2 %}
13 changes: 13 additions & 0 deletions archiv/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,19 @@ class YearBookDetailView(CustomDetailView):
model = YearBook
template_name = "archiv/yearbook_detail.html"

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.object.part_of:
context[
"cases"
] = self.object.related_court_decission.all().distinct()
return context
else:
children = self.object.has_bibliographic_items.all()
cases = CourtDecission.objects.filter(year_book_title__in=children).distinct()
context["cases"] = cases
return context


class YearBookCreate(CustomCreateView):
h1 = "Create bibliographic item"
Expand Down

0 comments on commit 70e58a2

Please sign in to comment.