Skip to content

Commit

Permalink
add language page template, view, and styling
Browse files Browse the repository at this point in the history
temporary
  • Loading branch information
“OMosimege” committed Jul 23, 2024
1 parent 52fa1ca commit f5a3f19
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
path("projects/<int:project_id>/", views.project_detail, name="project_detail"),
path("institution/<int:institution_id>/", views.institution_detail, name="institution_detail"),
path("documents/<int:document_id>/", views.document_detail, name="document_detail"),
path("language/<int:pk>/", views.language_detail, name="language_detail"),
path("subject/<int:pk>/", 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")),
Expand Down
25 changes: 19 additions & 6 deletions app/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
54 changes: 54 additions & 0 deletions app/templates/app/languages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}

{% block content %}
<br/>
<div class="detail">
<h2>Languages</h2>
<br>
<div class="detail-row row">
{% for item in language_data %}
<h5>{{ item.language.name }}</h5>
<div class="col-md-6 col-12 detail-col">
<p><strong>Documents</strong></p>
{% if item.documents.exists %}
<div class="documents">
<ul>
{% for document in item.documents %}
<li>
<span class="icon-text"><i class="detail-icon bi-file-earmark"></i></span>
<span class="icon-text"><a href="{% url 'document_detail' document.id %}">{{ document.title }}</a></span>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<p>{% trans "No documents available for this language." %}</p>
{% endif %}
</div>
<div class="col-md-6 col-12 detail-col">
<p><strong>Projects</strong></p>
{% if item.projects.exists %}
<div class="projects">
<ul>
{% for project in item.projects %}
<li>
<span class="icon-text"><i class="detail-icon bi-clipboard2"></i></span>
<span class="icon-text"><a href="{% url 'project_detail' project.id %}">{{ project.name }}</a></span>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<p>{% trans "No projects available for this language." %}</p>
{% endif %}
</div>
<br>
<hr>
<br>
{% endfor %}
</div>
</div>

{% endblock content %}
Empty file.
File renamed without changes.

0 comments on commit f5a3f19

Please sign in to comment.