diff --git a/compensation/templates/compensation/detail/compensation/view.html b/compensation/templates/compensation/detail/compensation/view.html index 80b5c0f..8e1b126 100644 --- a/compensation/templates/compensation/detail/compensation/view.html +++ b/compensation/templates/compensation/detail/compensation/view.html @@ -122,7 +122,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/comment_card.html' %} diff --git a/compensation/templates/compensation/detail/eco_account/view.html b/compensation/templates/compensation/detail/eco_account/view.html index 116b667..0eb354f 100644 --- a/compensation/templates/compensation/detail/eco_account/view.html +++ b/compensation/templates/compensation/detail/eco_account/view.html @@ -104,7 +104,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/comment_card.html' %} diff --git a/compensation/templates/compensation/report/compensation/report.html b/compensation/templates/compensation/report/compensation/report.html index 6620573..7088ff0 100644 --- a/compensation/templates/compensation/report/compensation/report.html +++ b/compensation/templates/compensation/report/compensation/report.html @@ -38,7 +38,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/report/qrcodes.html' %} diff --git a/compensation/templates/compensation/report/eco_account/report.html b/compensation/templates/compensation/report/eco_account/report.html index 823a30f..a3632ee 100644 --- a/compensation/templates/compensation/report/eco_account/report.html +++ b/compensation/templates/compensation/report/eco_account/report.html @@ -51,7 +51,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/report/qrcodes.html' %} diff --git a/ema/templates/ema/detail/view.html b/ema/templates/ema/detail/view.html index 020b7d4..31d26e0 100644 --- a/ema/templates/ema/detail/view.html +++ b/ema/templates/ema/detail/view.html @@ -90,7 +90,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/comment_card.html' %} diff --git a/ema/templates/ema/report/report.html b/ema/templates/ema/report/report.html index 40b1108..43b6486 100644 --- a/ema/templates/ema/report/report.html +++ b/ema/templates/ema/report/report.html @@ -38,7 +38,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/report/qrcodes.html' %} diff --git a/intervention/templates/intervention/detail/view.html b/intervention/templates/intervention/detail/view.html index c5f9b9c..2d9628c 100644 --- a/intervention/templates/intervention/detail/view.html +++ b/intervention/templates/intervention/detail/view.html @@ -137,7 +137,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/comment_card.html' %} diff --git a/intervention/templates/intervention/report/report.html b/intervention/templates/intervention/report/report.html index e6f13c3..6e238fa 100644 --- a/intervention/templates/intervention/report/report.html +++ b/intervention/templates/intervention/report/report.html @@ -97,7 +97,7 @@ {% include 'map/geom_form.html' %}
- {% include 'konova/includes/parcels.html' %} + {% include 'konova/includes/parcels/parcels.html' %}
{% include 'konova/includes/report/qrcodes.html' %} diff --git a/konova/templates/konova/includes/parcels/parcel_table_content.html b/konova/templates/konova/includes/parcels/parcel_table_content.html new file mode 100644 index 0000000..549a809 --- /dev/null +++ b/konova/templates/konova/includes/parcels/parcel_table_content.html @@ -0,0 +1,22 @@ +{% load l10n i18n %} +{% for parcel in parcels %} + {% if forloop.last and next_page %} + + {{parcel.parcel_group.name|default_if_none:"-"}} + {{parcel.parcel_group.key|default_if_none:"-"}} + {{parcel.flr|default_if_none:"-"|unlocalize}} + {{parcel.flrstck_zhlr|default_if_none:"-"|unlocalize}} + {{parcel.flrstck_nnr|default_if_none:"-"|unlocalize}} + + {% else %} + + {{parcel.parcel_group.name|default_if_none:"-"}} + {{parcel.parcel_group.key|default_if_none:"-"}} + {{parcel.flr|default_if_none:"-"|unlocalize}} + {{parcel.flrstck_zhlr|default_if_none:"-"|unlocalize}} + {{parcel.flrstck_nnr|default_if_none:"-"|unlocalize}} + + {% endif %} +{% endfor %} \ No newline at end of file diff --git a/konova/templates/konova/includes/parcel_table.html b/konova/templates/konova/includes/parcels/parcel_table_frame.html similarity index 75% rename from konova/templates/konova/includes/parcel_table.html rename to konova/templates/konova/includes/parcels/parcel_table_frame.html index 7650357..e329200 100644 --- a/konova/templates/konova/includes/parcel_table.html +++ b/konova/templates/konova/includes/parcels/parcel_table_frame.html @@ -37,16 +37,7 @@ - {% for parcel in parcels %} - - {{parcel.parcel_group.name|default_if_none:"-"}} - {{parcel.parcel_group.key|default_if_none:"-"}} - {{parcel.flr|default_if_none:"-"|unlocalize}} - {{parcel.flrstck_zhlr|default_if_none:"-"|unlocalize}} - {{parcel.flrstck_nnr|default_if_none:"-"|unlocalize}} - - {% endfor %} - + {% include 'konova/includes/parcels/parcel_table_content.html' %} {% endif %} diff --git a/konova/templates/konova/includes/parcels.html b/konova/templates/konova/includes/parcels/parcels.html similarity index 100% rename from konova/templates/konova/includes/parcels.html rename to konova/templates/konova/includes/parcels/parcels.html diff --git a/konova/urls.py b/konova/urls.py index d2458f5..00386a1 100644 --- a/konova/urls.py +++ b/konova/urls.py @@ -24,7 +24,7 @@ from konova.autocompletes import EcoAccountAutocomplete, \ ShareTeamAutocomplete, HandlerCodeAutocomplete from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG from konova.sso.sso import KonovaSSOClient -from konova.views import logout_view, home_view, get_geom_parcels +from konova.views import logout_view, home_view, get_geom_parcels, get_geom_parcels_content sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY) urlpatterns = [ @@ -40,7 +40,8 @@ urlpatterns = [ path('cl/', include("codelist.urls")), path('analysis/', include("analysis.urls")), path('api/', include("api.urls")), - path('geom//parcels', get_geom_parcels, name="geometry-parcels"), + path('geom//parcels/', get_geom_parcels, name="geometry-parcels"), + path('geom//parcels/', get_geom_parcels_content, name="geometry-parcels-content"), # Autocomplete paths for all apps path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"), diff --git a/konova/views.py b/konova/views.py index 2fd5ff9..97cb7d8 100644 --- a/konova/views.py +++ b/konova/views.py @@ -110,12 +110,12 @@ def get_geom_parcels(request: HttpRequest, id: str): id (str): The geometry's id Returns: - + A rendered piece of HTML """ # HTTP code 286 states that the HTMX should stop polling for updates # https://htmx.org/docs/#polling status_code = 286 - template = "konova/includes/parcel_table.html" + template = "konova/includes/parcels/parcel_table_frame.html" geom = get_object_or_404(Geometry, id=id) parcels = geom.get_underlying_parcels() geos_geom = geom.geom @@ -133,9 +133,18 @@ def get_geom_parcels(request: HttpRequest, id: str): parcels = parcels.order_by("-municipal", "flr", "flrstck_zhlr", "flrstck_nnr") municipals = parcels.order_by("municipal").distinct("municipal").values("municipal__id") municipals = Municipal.objects.filter(id__in=municipals) + + rpp = 100 + parcels = parcels[:rpp] + next_page = 1 + if len(parcels) < rpp: + next_page = None + context = { "parcels": parcels, "municipals": municipals, + "geom_id": str(id), + "next_page": next_page, } html = render_to_string(template, context, request) return HttpResponse(html, status=status_code) @@ -143,6 +152,49 @@ def get_geom_parcels(request: HttpRequest, id: str): return HttpResponse(None, status=404) +@login_required +def get_geom_parcels_content(request: HttpRequest, id: str, page: int): + """ Getter for infinite scroll of HTMX + + Returns parcels of a specific page/slice of the found parcel set. + Implementation of infinite scroll htmx example: https://htmx.org/examples/infinite-scroll/ + + Args: + request (HttpRequest): The incoming request + id (str): The geometry's id + page (int): The requested page number + + Returns: + A rendered piece of HTML + """ + if page < 0: + raise AssertionError("Parcel page can not be negative") + + # HTTP code 286 states that the HTMX should stop polling for updates + # https://htmx.org/docs/#polling + status_code = 286 + template = "konova/includes/parcels/parcel_table_content.html" + geom = get_object_or_404(Geometry, id=id) + parcels = geom.get_underlying_parcels() + + parcels = parcels.order_by("-municipal", "flr", "flrstck_zhlr", "flrstck_nnr") + rpp = 100 + from_p = rpp * (page-1) + to_p = rpp * (page) + next_page = page + 1 + parcels = parcels[from_p:to_p] + if len(parcels) < rpp: + next_page = None + + context = { + "parcels": parcels, + "geom_id": str(id), + "next_page": next_page, + } + html = render_to_string(template, context, request) + return HttpResponse(html, status=status_code) + + def get_404_view(request: HttpRequest, exception=None): """ Returns a 404 handling view diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 9626e76..4557506 100644 Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 2a78deb..35ee2c5 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-04-19 13:28+0200\n" +"POT-Creation-Date: 2022-04-21 14:16+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1582,7 +1582,7 @@ msgid "Search for file number" msgstr "Nach Aktenzeichen suchen" #: konova/filters/mixins.py:85 -#: konova/templates/konova/includes/parcel_table.html:13 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:13 msgid "District" msgstr "Kreis" @@ -1595,7 +1595,7 @@ msgid "Search for parcel gmrkng" msgstr "Nach Gemarkung suchen" #: konova/filters/mixins.py:111 -#: konova/templates/konova/includes/parcel_table.html:34 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:34 msgid "Parcel" msgstr "Flur" @@ -1604,7 +1604,7 @@ msgid "Search for parcel" msgstr "Nach Flur suchen" #: konova/filters/mixins.py:124 -#: konova/templates/konova/includes/parcel_table.html:35 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:35 msgid "Parcel counter" msgstr "Flurstückzähler" @@ -1613,7 +1613,7 @@ msgid "Search for parcel counter" msgstr "Nach Flurstückzähler suchen" #: konova/filters/mixins.py:138 -#: konova/templates/konova/includes/parcel_table.html:36 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:36 msgid "Parcel number" msgstr "Flurstücknenner" @@ -1748,33 +1748,37 @@ msgstr "" msgid "English" msgstr "" -#: konova/templates/konova/includes/parcel_table.html:5 +#: konova/templates/konova/includes/parcels/parcel_table_content.html:18 +msgid "Show more..." +msgstr "Mehr anzeigen..." + +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:5 msgid "Parcels can not be calculated, since no geometry is given." msgstr "" "Flurstücke können nicht berechnet werden, da keine Geometrie eingegeben " "wurde." -#: konova/templates/konova/includes/parcel_table.html:11 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:11 msgid "Municipal" msgstr "Gemeinde" -#: konova/templates/konova/includes/parcel_table.html:12 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:12 msgid "Municipal key" msgstr "Gemeindeschlüssel" -#: konova/templates/konova/includes/parcel_table.html:14 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:14 msgid "District key" msgstr "Kreisschlüssel" -#: konova/templates/konova/includes/parcel_table.html:32 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:32 msgid "Parcel group" msgstr "Gemarkung" -#: konova/templates/konova/includes/parcel_table.html:33 +#: konova/templates/konova/includes/parcels/parcel_table_frame.html:33 msgid "Parcel group key" msgstr "Gemarkungsschlüssel" -#: konova/templates/konova/includes/parcels.html:7 +#: konova/templates/konova/includes/parcels/parcels.html:7 msgid "Spatial reference" msgstr "Raumreferenz"