-
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.
Merge pull request #85 from SADiLaR/feature/institution-detail-page
Add individual institution page
- Loading branch information
Showing
7 changed files
with
140 additions
and
21 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,30 @@ | ||
from django.http import Http404 | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from general.models import DocumentFile, Institution, Project | ||
|
||
|
||
class InstitutionDetailViewTests(TestCase): | ||
def setUp(self): | ||
self.institution = Institution.objects.create( | ||
name="Sample Institution", | ||
abbreviation="SI", | ||
url="https://example.com", | ||
email="[email protected]", | ||
logo="path/to/logo.png", | ||
) | ||
|
||
def test_institution_detail_view_with_valid_id(self): | ||
response = self.client.get(reverse("institution_detail", args=[self.institution.id])) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, self.institution.name) | ||
|
||
def test_institution_detail_view_with_invalid_id(self): | ||
invalid_id = self.institution.id + 1 | ||
response = self.client.get(reverse("institution_detail", args=[invalid_id])) | ||
self.assertEqual(response.status_code, 404) | ||
|
||
def test_project_detail_view_num_queries(self): | ||
with self.assertNumQueries(1): | ||
response = self.client.get(reverse("project_detail", args=[self.institution.id])) |
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,66 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block content %} | ||
<br/> | ||
<div class="detail"> | ||
<p><a href="{% url 'institutions' %}">{% trans "Institutions" %}</a> > {{ institution.name }}</p> | ||
|
||
<div class="detail-row"> | ||
|
||
<div class="col-sm-6 detail-left-col"> | ||
<h1>{{ institution.name }} ({{ institution.abbreviation }})</h1> | ||
{% if institution.url %} | ||
<p><a href="{{ institution.url }}">{{ institution.url }}</a></p> | ||
{% endif %} | ||
{% if institution.email %} | ||
<p><a href="mailto:{{ institution.email }}">{{ institution.email }}</a></p> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="col-sm-6 detail-right-col"> | ||
{% if institution.logo %} | ||
<img src="{{ institution.logo.url }}" alt="{{ institution.name }}" class="project-logo"> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
<br/> | ||
|
||
<div class="detail-row"> | ||
<div class="col-sm-6 detail-col"> | ||
<h2>{% trans "Projects" %}</h2> | ||
{% if projects %} | ||
<ul> | ||
{% for project in 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> | ||
{% else %} | ||
<p>{% trans "No projects available for this institution." %}</p> | ||
{% endif %} | ||
</div> | ||
<div class="col-sm-6 detail-col"> | ||
<h2>{% trans "Documents" %}</h2> | ||
{% if documents %} | ||
<ul> | ||
{% for document in 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> | ||
{% else %} | ||
<p>{% trans "No documents available for this institution." %}</p> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
{% endblock content %} |
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