diff --git a/app/app/views.py b/app/app/views.py index 05020a17..a97e444a 100644 --- a/app/app/views.py +++ b/app/app/views.py @@ -50,6 +50,22 @@ def get_logo(project): return logo +def get_languages(languages): + if languages.count() < 4: + languages_data = ", ".join(sorted(language.name for language in languages)) + else: + languages_data = _("Multilingual") + return languages_data + + +def get_subjects(subjects): + if subjects.count() < 4: + subjects_data = ", ".join(sorted([subject.name for subject in subjects])) + else: + subjects_data = _("Multiple subjects") + return subjects_data + + def projects(request): template = "app/projects.html" @@ -79,15 +95,8 @@ def projects(request): project_subjects = project.subjects.all() project_languages = project.languages.all() - if project_languages.count() < 4: - languages_data = ", ".join(sorted(language.name for language in project_languages)) - else: - languages_data = _("Multilingual") - - if project_subjects.count() < 4: - subjects_data = ", ".join(sorted([subject.name for subject in project_subjects])) - else: - subjects_data = _("Multiple subjects") + languages_data = get_languages(project_languages) + subjects_data = get_subjects(project_subjects) logo = get_logo(project) @@ -161,8 +170,59 @@ def institution_detail(request, institution_id): def documents(request): template = "app/documents.html" + subject_id = request.GET.get("subject") + language_id = request.GET.get("language") + institution_id = request.GET.get("institution") + + documents = ( + DocumentFile.objects.select_related("institution") + .prefetch_related("subjects", "languages") + .order_by("title") + ) + + if subject_id: + documents = documents.filter(subjects__id=subject_id) + if language_id: + documents = documents.filter(languages__id=language_id) + if institution_id: + documents = documents.filter(institution__id=institution_id) + + paginator = Paginator(documents, 10) + + page_number = request.GET.get("page") + page_obj = paginator.get_page(page_number) + + subjects = Subject.objects.order_by("name") + languages = Language.objects.order_by("name") + institutions = Institution.objects.order_by("name") + + document_data = [] + for document in page_obj: + document_subjects = document.subjects.all() + document_languages = document.languages.all() + + languages_data = get_languages(document_languages) + subjects_data = get_subjects(document_subjects) + + document_data.append( + { + "document": document, + "subjects": subjects_data, + "languages": languages_data, + "institution_name": document.institution.name, + "description": document.description, + "url": document.url, + "category": document.document_type, + } + ) + context = { "current_page": "documents", + "page_obj": page_obj, + "documents": document_data, + "subjects": subjects, + "languages": languages, + "institutions": institutions, } return render(request, template_name=template, context=context) diff --git a/app/static/css/styles.css b/app/static/css/styles.css index d6e97f89..d17e3ae5 100755 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -133,6 +133,41 @@ html { background-color: var(--primary-fg); border-color: var(--primary-fg); } +.pagination-wrapper { + display: flex; + justify-content: center; + margin-top: 20px; +} +.pagination { + display: flex; + list-style: none; + padding: 0; + border: 1px solid #000; + border-radius: 5px; +} +.pagination .page-item { + margin: 0; + border-left: 1px solid #000; +} +.pagination .page-item:first-child { + border-left: none; +} +.pagination .page-link { + padding: 5px 10px; + text-decoration: none; + color: var(--text-color); +} +.pagination .page-item.active .page-link { + background-color: var(--primary); + color: var(--primary-fg); +} +.pagination .page-item.disabled .page-link { + color: #6c757d; +} +.button-spacing { + margin-right: 10px; +} + /*Home page*/ .content-card { border-color: var(--primary-red); @@ -343,6 +378,10 @@ html { .project-date-row { font-size: 0.875rem; } +.gap-2 > * { + margin-right: 0.5rem; + margin-bottom: 0.5rem; +} /*Accounts*/ .user-account-body { @@ -403,6 +442,13 @@ html { padding-right: 20px; margin-right: 10px; } + .form-group.col-md-4 { + flex: 0 0 100%; + max-width: 100%; + } + .gap-2 > * { + margin-right: 0; + } } /*small devices (tablets, 600px and up) */ @@ -436,6 +482,13 @@ html { .content-card { font-size: smaller; } + .form-group.col-md-4 { + flex: 0 0 100%; + max-width: 100%; + } + .gap-2 > * { + margin-right: 0; + } } /*Medium screens (tablets, between 768px and 1001px)*/ @@ -611,12 +664,3 @@ html { display: flex; } } - -/*Search Css*/ -.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 */ -} diff --git a/app/templates/app/documents.html b/app/templates/app/documents.html index 84d76d25..43e174f7 100644 --- a/app/templates/app/documents.html +++ b/app/templates/app/documents.html @@ -3,5 +3,110 @@ {% load i18n %} {% block content %} +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + {% trans "Reset" %} +
+
+
-{% endblock content%} +
+ +
+ {% for document in documents %} +
+
+

+ {{ document.document.title }} +

+ +
+ {{ document.institution_name }} +
+
+
+
+ {{ document.description|truncatewords:30 }} {% trans "Read more" %} +
+
+ {% if document.languages %} + + {{ document.languages }} + {% endif %} +
+
+ {% if document.subjects %} + + {{ document.subjects }} + {% endif %} +
+
+
+ +
+ {% endfor %} +
+ +
+ +
+{% endblock content %} diff --git a/app/templates/app/projects.html b/app/templates/app/projects.html index a0bc745d..ef155fcc 100644 --- a/app/templates/app/projects.html +++ b/app/templates/app/projects.html @@ -4,53 +4,40 @@ {% block content %}
-
- -
- -
- -
- - -
- -
- - -
- -
- - -
- - - + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + {% trans "Reset" %} +
diff --git a/app/templates/base.html b/app/templates/base.html index 2b8a3967..d5dc7da3 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -51,6 +51,12 @@ class="nav-link" href="{% url 'projects' %}">{% trans "Projects" %} +