Skip to content

Commit

Permalink
tag detail view (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 authored Jul 19, 2024
1 parent fae40f9 commit fee2888
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 66 deletions.
23 changes: 23 additions & 0 deletions archiv/migrations/0021_alter_courtdecission_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2024-07-19 13:22

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("archiv", "0020_keyword_linked_to_cases_and_more"),
]

operations = [
migrations.AlterField(
model_name="courtdecission",
name="tag",
field=models.ManyToManyField(
blank=True,
help_text="Tags",
related_name="has_related_tags",
to="archiv.tag",
verbose_name="Tags",
),
),
]
23 changes: 23 additions & 0 deletions archiv/migrations/0022_alter_courtdecission_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2024-07-19 13:23

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("archiv", "0021_alter_courtdecission_tag"),
]

operations = [
migrations.AlterField(
model_name="courtdecission",
name="tag",
field=models.ManyToManyField(
blank=True,
help_text="Tags",
related_name="has_related_decisions",
to="archiv.tag",
verbose_name="Tags",
),
),
]
2 changes: 1 addition & 1 deletion archiv/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class CourtDecission(models.Model):
)
tag = models.ManyToManyField(
"Tag",
related_name="has_related_keywords",
related_name="has_related_decisions",
blank=True,
verbose_name="Tags",
help_text="Tags",
Expand Down
2 changes: 0 additions & 2 deletions archiv/templates/archiv/court_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
</div>
<div class="col-md-8">
<h1 class="text-center">
<small><a href="{{ object.get_listview_url }}"><i class="bi bi-list"
title="back to list view"></i></a></small>
{{ object.abbreviation }}
{% if user.is_authenticated %}
<small>
Expand Down
2 changes: 0 additions & 2 deletions archiv/templates/archiv/keyword_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
</div>
<div class="col-md-8">
<h1 class="text-center">
<small><a href="{{ object.get_listview_url }}"><i class="bi bi-list"
title="back to list view"></i></a></small>
{{ object.name }}
{% if user.is_authenticated %}
<small>
Expand Down
40 changes: 0 additions & 40 deletions archiv/templates/archiv/partials/courtdecission_table.html

This file was deleted.

2 changes: 0 additions & 2 deletions archiv/templates/archiv/partials/detailview_title.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
</div>
<div class="col-md-8">
<h1 class="text-center">
<small><a href="{{ object.get_listview_url }}"><i class="bi bi-list"
title="back to list view"></i></a></small>
{{ object }}
{% if user.is_authenticated %}
<small>
Expand Down
124 changes: 105 additions & 19 deletions archiv/templates/archiv/tag_detail.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,120 @@
{% extends "webpage/base.html" %}
{% load static %}
{% load webpage_extras %}
{% block title %}{{ object.name }}{% endblock %}
{% block title %}{{ object }}{% 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">
{% with courtdecissions=object.has_related_keywords %}
<h2>{{ courtdecissions.count }} Tagged Court Decissions</h2>
{% include "archiv/partials/courtdecission_table.html" %}
{% endwith %}
{% include 'archiv/partials/detailview_title.html' %}

<div class="container">
{% with courtdecissions=object.has_related_decisions %}
<h2>{{ courtdecissions.count }} case(s)</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">Legal system</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>
{{ x.partial_legal_system }}
<a href="{{ x.partial_legal_system.get_absolute_url }}"><i class="bi bi-link-45deg"></i></a>
</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>
<div class="ps-5">
{% endwith %}



{% if user.is_authenticated %}
<div class="float-end">
<a href="{{ object.get_delete_url }}">
<i class="bi bi-trash3" title="delete entry"></i>
</a>
</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>
{% endif %}
{% 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",
minWidth: 320
},
{
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: "Legal system",
field: "Legal system",
sorter: "string",
headerFilter: "input",
formatter: scrollHtml
},
{
title: "Keywords",
field: "Keywords",
sorter: "string",
headerFilter: "input",
formatter: scrollHtml
}
]
});
</script>
{% endblock scripts2 %}

0 comments on commit fee2888

Please sign in to comment.