From 882a060921cc01b489733f1163a8fe569a48a5a9 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Fri, 12 Jul 2024 08:56:31 +0200 Subject: [PATCH] backup of code --- app/app/views.py | 23 +++ app/static/css/styles.css | 6 +- app/templates/app/search.html | 277 ++++++++++++++++------------------ 3 files changed, 158 insertions(+), 148 deletions(-) diff --git a/app/app/views.py b/app/app/views.py index f8cc1b29..fbca72b8 100644 --- a/app/app/views.py +++ b/app/app/views.py @@ -245,10 +245,33 @@ def search(request): except EmptyPage: page_obj = paginator.page(paginator.num_pages) + search_params = pagination_url(request) + context = { "search_results": paginator.page(page_obj.number), "filter": f, "documents": page_obj, + "search_params": search_params, } return render(request, template_name=template, context=context) + + +def pagination_url( + request, +): + url_params = { + "search": request.GET.get("search", ""), + "document_type": request.GET.get("document_type", ""), + "institution": request.GET.get("institution", ""), + "subjects": request.GET.get("subjects", ""), + "languages": request.GET.get("languages", ""), + } + + return "?search={search}&document_type={document_type}&institution={institution}&subjects={subjects}&languages={languages}".format( + search=url_params["search"], + document_type=url_params["document_type"], + institution=url_params["institution"], + subjects=url_params["subjects"], + languages=url_params["languages"], + ) diff --git a/app/static/css/styles.css b/app/static/css/styles.css index bea1813b..d6e97f89 100755 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -613,14 +613,10 @@ html { } /*Search Css*/ -.subjects-checkbox-container { +.checkbox-container { cursor: pointer; max-height: 130px; /* Adjust based on your line-height and padding to show only 4 rows */ overflow-y: auto; /* Enable vertical scrollbar when content overflows */ border: 1px solid #ced4da; /* Bootstrap's form control border color */ border-radius: 0.25rem; /* Bootstrap's form control border radius */ } - -.subjects-checkbox-container input[type="checkbox"] { - cursor: pointer; -} diff --git a/app/templates/app/search.html b/app/templates/app/search.html index 85073e39..9d1bd85c 100644 --- a/app/templates/app/search.html +++ b/app/templates/app/search.html @@ -3,165 +3,156 @@ {% load i18n %} {% block content %} +
+
+
+
+
{% trans "Search a term" %}
+
+ +
+ +
+
+
+
+ {% for document in search_results %} +
+
    +
  • + {% trans "Title:" %} + {{ document.title }} +
  • +
  • + {% trans "Institution:" %} + {{ document.institution }} +
  • +
  • + {% trans "Headline:" %} + {{ document.search_headline|safe }} +
  • +
  • + {% trans "File:" %} + {{ document.uploaded_file }} +
  • +
  • + {% trans "License:" %} + {{ document.license }} +
  • +
  • + {% trans "License:" %} + {{ document.document_type }} +
  • +
  • + {% trans "Mime Type:" %} + {{ document.mime_type }} +
  • +
  • + {% trans "Rank:" %} + {{ document.rank }} +
  • +
+
+ {% endfor %} +
+
+
+
-
-
-
-
-
{% trans "Search a term" %}
+ {{ search_params }} + +
+

- -
-
-
-
- {% for document in search_results %} -
-
    -
  • - {% trans "Title:" %} - {{ document.title }} -
  • -
  • - {% trans "Institution:" %} - {{ document.institution }} -
  • -
  • - {% trans "Headline:" %} - {{ document.search_headline|safe }} -
  • -
  • - {% trans "File:" %} - {{ document.uploaded_file }} -
  • -
  • - {% trans "License:" %} - {{ document.license }} -
  • -
  • - {% trans "License:" %} - {{ document.document_type }} -
  • -
  • - {% trans "Mime Type:" %} - {{ document.mime_type }} -
  • -
  • - {% trans "Rank:" %} - {{ document.rank }} -
  • -
-
- {% endfor %} -
-
-
-
- -
-
-
- -
-
-
-
- -
- {% for checkbox in filter.form.institution %} -
- {{ checkbox.tag }} - -
- {% endfor %} +
+
+
+ +
+ {% for checkbox in filter.form.institution %} +
+ {{ checkbox.tag }} + +
+ {% endfor %} +
-
-
-
- -
- {% for checkbox in filter.form.document_type %} -
- {{ checkbox.tag }} - -
- {% endfor %} +
+
+ +
+ {% for checkbox in filter.form.document_type %} +
+ {{ checkbox.tag }} + +
+ {% endfor %} +
-
-
-
- -
- {% for checkbox in filter.form.subjects %} -
- {{ checkbox.tag }} - -
- {% endfor %} +
+
+ +
+ {% for checkbox in filter.form.subjects %} +
+ {{ checkbox.tag }} + +
+ {% endfor %} +
-
-
-
- -
- {% for checkbox in filter.form.languages %} -
- {{ checkbox.tag }} - -
- {% endfor %} +
+
+ +
+ {% for checkbox in filter.form.languages %} +
+ {{ checkbox.tag }} + +
+ {% endfor %} +
-
-
- -
- +
+ +
+ +
+
-
-
{% endblock content %}