Skip to content

Commit

Permalink
Merge pull request #52 from acdh-oeaw/48-use-better-prevnext-logic
Browse files Browse the repository at this point in the history
48 use better prevnext logic
  • Loading branch information
csae8092 authored Dec 29, 2023
2 parents 9c6b320 + 7cfb939 commit db773b4
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 33 deletions.
12 changes: 9 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true
"cSpell.enableFiletypes": [
"!css",
"!python",
"!yaml",
"!yml",
"!html"
],
"isort.check": true,
"isort.importStrategy": "fromEnvironment"
}
32 changes: 16 additions & 16 deletions archiv/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ class HapaPlaceNameListFilter(django_filters.FilterSet):
url="gn_places-ac:geonamesplace-autocomplete",
),
)
beleg = django_filters.ModelMultipleChoiceFilter(
queryset=HapaBeleg.objects.all(),
help_text=HapaPlaceName._meta.get_field("beleg").help_text,
label=HapaPlaceName._meta.get_field("beleg").verbose_name,
widget=autocomplete.Select2Multiple(
url="archiv-ac:hapabeleg-autocomplete",
),
)
beleg__zotero_id = django_filters.ModelMultipleChoiceFilter(
queryset=ZotItem.objects.all(),
help_text="Bibliographischer Eintrag",
label="Bibliographischer Eintrag",
widget=autocomplete.Select2Multiple(
url="bib:zotitem-autocomplete",
),
)
# beleg = django_filters.ModelMultipleChoiceFilter(
# queryset=HapaBeleg.objects.all(),
# help_text=HapaPlaceName._meta.get_field("beleg").help_text,
# label=HapaPlaceName._meta.get_field("beleg").verbose_name,
# widget=autocomplete.Select2Multiple(
# url="archiv-ac:hapabeleg-autocomplete",
# ),
# )
# beleg__zotero_id = django_filters.ModelMultipleChoiceFilter(
# queryset=ZotItem.objects.all(),
# help_text="Bibliographischer Eintrag",
# label="Bibliographischer Eintrag",
# widget=autocomplete.Select2Multiple(
# url="bib:zotitem-autocomplete",
# ),
# )
orig_sprache = django_filters.ModelMultipleChoiceFilter(
queryset=SkosConcept.objects.filter(collection__name="orig_sprache"),
help_text=HapaPlaceName._meta.get_field("orig_sprache").help_text,
Expand Down
2 changes: 1 addition & 1 deletion archiv/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, *args, **kwargs):
"etymology",
"syntax",
"comment",
"beleg",
# "beleg",
# 'beleg__zotero_id',
css_id="etym",
),
Expand Down
21 changes: 9 additions & 12 deletions archiv/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.core.serializers import serialize
from django.db import models
from django.urls import reverse
from next_prev import next_in_order, prev_in_order
from taggit.managers import TaggableManager

from bib.models import ZotItem
Expand Down Expand Up @@ -158,15 +159,15 @@ def get_edit_url(self):
return reverse("archiv:hapabeleg_edit", kwargs={"pk": self.id})

def get_next(self):
next = self.__class__.objects.filter(id__gt=self.id)
next = next_in_order(self)
if next:
return reverse("archiv:hapabeleg_detail", kwargs={"pk": next.first().id})
return reverse("archiv:hapabeleg_detail", kwargs={"pk": next.id()})
return False

def get_prev(self):
prev = self.__class__.objects.filter(id__lt=self.id).order_by("-id")
prev = prev_in_order(self)
if prev:
return reverse("archiv:hapabeleg_detail", kwargs={"pk": prev.first().id})
return reverse("archiv:hapabeleg_detail", kwargs={"pk": prev.id})
return False


Expand Down Expand Up @@ -381,19 +382,15 @@ def get_edit_url(self):
return reverse("archiv:hapaplacename_edit", kwargs={"pk": self.id})

def get_next(self):
next = self.__class__.objects.filter(id__gt=self.id)
next = next_in_order(self)
if next:
return reverse(
"archiv:hapaplacename_detail", kwargs={"pk": next.first().id}
)
return reverse("archiv:hapaplacename_detail", kwargs={"pk": next.id})
return False

def get_prev(self):
prev = self.__class__.objects.filter(id__lt=self.id).order_by("-id")
prev = prev_in_order(self)
if prev:
return reverse(
"archiv:hapaplacename_detail", kwargs={"pk": prev.first().id}
)
return reverse("archiv:hapaplacename_detail", kwargs={"pk": prev.id})
return False

def as_geojson(self):
Expand Down
2 changes: 1 addition & 1 deletion archiv/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HapaPlaceNameTable(tables.Table):
id = tables.LinkColumn(verbose_name="ID")
tags = tables.ManyToManyColumn()
# merge = MergeColumn(verbose_name='keep | remove', accessor='pk')
beleg = tables.columns.ManyToManyColumn()
beleg = tables.columns.ManyToManyColumn(verbose_name="Belege")
wortbildung = tables.TemplateColumn("{{ record.wortbildung|safe }}")
etymology = tables.TemplateColumn("{{ record.etymology|safe }}")
syntax = tables.TemplateColumn("{{ record.syntax|safe }}")
Expand Down
1 change: 1 addition & 0 deletions djangobaseproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
path("vocabs/", include("vocabs.urls", namespace="vocabs")),
path("vocabs-ac/", include("vocabs.dal_urls", namespace="vocabs-ac")),
path("", include("webpage.urls", namespace="webpage")),
path("__debug__/", include("debug_toolbar.urls")),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

handler404 = "webpage.views.handler404"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ acdh-django-browsing>=2.0,<3
acdh-django-charts>=0.5.3
acdh-django-geonames>=0.1.8
acdh-django-netvis>=0.1.0
django-next-prev==1.1.0
django-taggit==1.3.0
acdh-django-vocabs>=0.1.3
crispy-bootstrap4
Expand Down

0 comments on commit db773b4

Please sign in to comment.