-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add language page template, view, and styling
- Loading branch information
“OMosimege”
committed
Jul 24, 2024
1 parent
ccf81cd
commit c7f90bf
Showing
7 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from general.models import DocumentFile, Institution, Language, Project | ||
|
||
|
||
class LanguagesViewTest(TestCase): | ||
def setUp(self): | ||
self.institution = Institution.objects.create( | ||
name="Test Institution", | ||
abbreviation="TI", | ||
url="http://testinstitution.org", | ||
email="[email protected]", | ||
) | ||
|
||
self.language1 = Language.objects.create(name="English", iso_code="lang1") | ||
self.language2 = Language.objects.create(name="Spanish", iso_code="lang2") | ||
|
||
self.document1 = DocumentFile.objects.create( | ||
title="Document 1", institution=self.institution, document_type="report" | ||
) | ||
self.document1.languages.add(self.language1) | ||
|
||
self.document2 = DocumentFile.objects.create( | ||
title="Document 2", institution=self.institution, document_type="report" | ||
) | ||
self.document2.languages.add(self.language2) | ||
|
||
self.project1 = Project.objects.create(name="Project 1", institution=self.institution) | ||
self.project1.languages.add(self.language1) | ||
|
||
self.project2 = Project.objects.create(name="Project 2", institution=self.institution) | ||
self.project2.languages.add(self.language2) | ||
|
||
def test_languages_view_num_queries(self): | ||
with self.assertNumQueries(3): | ||
response = self.client.get(reverse("languages")) | ||
self.assertEqual(response.status_code, 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>{% trans "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"> | ||
<h6>{% trans "Documents" %}</h6> | ||
{% 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"> | ||
<h6>{% trans "Projects" %}</h6> | ||
{% 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters