Skip to content

Commit

Permalink
closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Oct 24, 2023
1 parent f8d62b1 commit 7a3dfec
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 16 deletions.
11 changes: 3 additions & 8 deletions archiv/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# generated by appcreator
from django.contrib import admin
from .models import (
Court,
CourtDecission,
KeyWord,
PartialLegalSystem,
Person,
)
from .models import Court, CourtDecission, KeyWord, PartialLegalSystem, Person, Tag

admin.site.register(Court)
admin.site.register(CourtDecission)
admin.site.register(KeyWord)
admin.site.register(PartialLegalSystem)
admin.site.register(Person)
admin.site.register(Person),
admin.site.register(Tag)
7 changes: 6 additions & 1 deletion archiv/dal_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
),
path(
"tag-autocomplete",
dal_views.YearBookAC.as_view(),
dal_views.TagAC.as_view(create_field="tag", validate_create=True),
name="tag-autocomplete",
),
path(
"tag-filter-autocomplete",
dal_views.TagAC.as_view(),
name="tag-no-filter-autocomplete",
),
]
9 changes: 9 additions & 0 deletions archiv/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ class CourtDecissionListFilter(django_filters.FilterSet):
url="archiv-ac:yearbook-autocomplete",
),
)
tag = django_filters.ModelMultipleChoiceFilter(
queryset=Tag.objects.all(),
help_text=CourtDecission._meta.get_field("tag").help_text,
label=CourtDecission._meta.get_field("tag").verbose_name,
widget=autocomplete.Select2Multiple(
url="archiv-ac:tag-no-filter-autocomplete",
),
)
partial_legal_system = django_filters.ModelMultipleChoiceFilter(
queryset=PartialLegalSystem.objects.all(),
help_text=CourtDecission._meta.get_field("partial_legal_system").help_text,
Expand Down Expand Up @@ -229,6 +237,7 @@ class Meta:
"commentary",
"additional_information",
"keyword",
"tag",
"author",
"year_book_title",
]
Expand Down
31 changes: 24 additions & 7 deletions archiv/fixtures/dump.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions archiv/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from crispy_forms.layout import Submit, Layout
from crispy_forms.bootstrap import AccordionGroup
from crispy_bootstrap5.bootstrap5 import BS5Accordion
from dal import autocomplete

from .models import (
Court,
Expand Down Expand Up @@ -116,6 +117,7 @@ def __init__(self, *args, **kwargs):
"commentary",
"additional_information",
"keyword",
"tag",
"author",
css_id="more",
),
Expand All @@ -130,6 +132,9 @@ class Meta:
exclude = [
"vector_column",
]
widgets = {
"tag": autocomplete.ModelSelect2Multiple(url="archiv-ac:tag-autocomplete"),
}

def __init__(self, *args, **kwargs):
super(CourtDecissionForm, self).__init__(*args, **kwargs)
Expand Down
16 changes: 16 additions & 0 deletions archiv/migrations/0011_alter_tag_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.4 on 2023-10-24 05:50

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("archiv", "0010_tag_courtdecission_tag"),
]

operations = [
migrations.AlterModelOptions(
name="tag",
options={"ordering": ["tag"], "verbose_name": "Tag"},
),
]
6 changes: 6 additions & 0 deletions archiv/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,12 @@ class Tag(models.Model):
blank=True, null=True, max_length=300, verbose_name="Tag", help_text="Tag"
)

class Meta:
ordering = [
"tag",
]
verbose_name = "Tag"

def __str__(self):
return f"{self.tag}"

Expand Down
69 changes: 69 additions & 0 deletions archiv/templates/archiv/tag_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{% extends "webpage/base.html" %}
{% load static %}
{% load webpage_extras %}
{% block title %}{{ object.name }}{% endblock %}
{% block content %}
<!-- <div class="container"> -->

<div class="card">
<div class="card-header">
<div class="row">
<div class="col-md-2">
{% if object.get_prev %}
<p class="text-start">
<a href="{{ object.get_prev }}">
<i class="bi bi-chevron-left" title="previous entry"></i>
</a>
</p>
{% endif %}
</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>
<a href="{{ object.get_edit_url }}">
<i class="bi bi-pencil-square" title="edit entry"></i>
</a>
</small>
{% endif %}

</h1>
</div>
<div class="col-md-2">
<p class="text-end">
{% if object.get_next %}
<a href="{{ object.get_next }}">
<i class="bi bi-chevron-right" title="next entry"></i>
</a>
</p>
{% endif %}
</div>
</div>
</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 %}



</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 %}
</div>

{% endblock %}
{% block scripts2 %}
{% include "archiv/partials/courtdecission_table_js.html" %}
{% endblock scripts2 %}
2 changes: 2 additions & 0 deletions webpage/templates/webpage/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
</li>
<li><a class="dropdown-item" href="{% url 'archiv:keyword_browse' %}">Keywords</a>
</li>
<li><a class="dropdown-item" href="{% url 'archiv:tag_browse' %}">Tags</a>
</li>
<li><a class="dropdown-item" href="{% url 'archiv:partiallegalsystem_browse' %}">Legal Systems</a>
</li>
<li><a class="dropdown-item" href="{% url 'archiv:yearbook_browse' %}">Yearbooks</a>
Expand Down

0 comments on commit 7a3dfec

Please sign in to comment.