From f5a3f192c6f5fe80661e43304348e1975f2c1811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9COMosimege=E2=80=9D?= <“onalerona.mosimege@gmail.com”> Date: Tue, 23 Jul 2024 09:16:02 +0200 Subject: [PATCH] add language page template, view, and styling temporary --- app/app/urls.py | 4 +- app/app/views.py | 25 ++++++--- app/templates/app/languages.html | 54 +++++++++++++++++++ app/templates/app/subject_detail.html | 0 .../{language_detail.html => subjects.html} | 0 5 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 app/templates/app/languages.html delete mode 100644 app/templates/app/subject_detail.html rename app/templates/app/{language_detail.html => subjects.html} (100%) diff --git a/app/app/urls.py b/app/app/urls.py index a9986360..7ba0c260 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -37,8 +37,8 @@ path("projects//", views.project_detail, name="project_detail"), path("institution//", views.institution_detail, name="institution_detail"), path("documents//", views.document_detail, name="document_detail"), - path("language//", views.language_detail, name="language_detail"), - path("subject//", views.subject_detail, name="subject_detail"), + path("languages/", views.languages, name="languages"), + path("subjects/", views.subjects, name="subjects"), path("search/", views.search, name="search"), path("i18n/", include("django.conf.urls.i18n")), path("accounts/", include("accounts.urls")), diff --git a/app/app/views.py b/app/app/views.py index 05020a17..5da33b41 100644 --- a/app/app/views.py +++ b/app/app/views.py @@ -185,19 +185,32 @@ def document_detail(request, document_id): return render(request, template_name=template, context=context) -def language_detail(request, project_id): - template = "app/language_detail.html" +def languages(request): + template = "app/languages.html" - project = Project.objects.get(id=project_id) + languages = Language.objects.all() + language_data = [] + + for language in languages: + documents = DocumentFile.objects.filter(languages=language) + projects = Project.objects.filter(languages=language) + language_data.append( + { + "language": language, + "documents": documents, + "projects": projects, + } + ) context = { - "current_page": "language_detail", + "current_page": "languages", + "language_data": language_data, } return render(request, template_name=template, context=context) -def subject_detail(request, project_id): - template = "app/subject_detail.html" +def subjects(request): + template = "app/subjects.html" project = Project.objects.get(id=project_id) diff --git a/app/templates/app/languages.html b/app/templates/app/languages.html new file mode 100644 index 00000000..1da446a0 --- /dev/null +++ b/app/templates/app/languages.html @@ -0,0 +1,54 @@ +{% extends "base.html" %} +{% load static %} +{% load i18n %} + +{% block content %} +
+
+

Languages

+
+
+ {% for item in language_data %} +
{{ item.language.name }}
+
+

Documents

+ {% if item.documents.exists %} +
+ +
+ {% else %} +

{% trans "No documents available for this language." %}

+ {% endif %} +
+
+

Projects

+ {% if item.projects.exists %} +
+ +
+ {% else %} +

{% trans "No projects available for this language." %}

+ {% endif %} +
+
+
+
+ {% endfor %} +
+
+ +{% endblock content %} diff --git a/app/templates/app/subject_detail.html b/app/templates/app/subject_detail.html deleted file mode 100644 index e69de29b..00000000 diff --git a/app/templates/app/language_detail.html b/app/templates/app/subjects.html similarity index 100% rename from app/templates/app/language_detail.html rename to app/templates/app/subjects.html