diff --git a/conntrackt/templates/conntrackt/index.html b/conntrackt/templates/conntrackt/index.html
--- a/conntrackt/templates/conntrackt/index.html
+++ b/conntrackt/templates/conntrackt/index.html
@@ -4,30 +4,64 @@
{% load conntrackt_tags %}
{% block content %}
+
-{% if projects %}
- {% for project in projects %}
-
-
{% include "conntrackt/project_widget.html" %}
+
+
+
Projects
+
+ {% if projects %}
+
+ {% for project in projects %}
+
+ {% html_link project.name "project" project.id class="btn btn-link" %} |
+ {% html_link '' "project_iptables" project.id class="btn btn-link" %} |
+ {% html_link '' "project_update" project.id class="btn btn-link" %} |
+ {% html_link '' "project_delete" project.id class="btn btn-link" %} |
+
+ {% endfor %}
+
+ {% else %}
+ There are no projects defined.
+ {% endif %}
+
- {% endfor %}
-{% else %}
-
Currently there are no projects defined in the database. Use the administration pages in order to add a new project.
-{% endif %}
+
+
+
Locations
+
+ {% if locations %}
+
+ {% for location in locations %}
+
+ {{location.name}} |
+
+ {% endfor %}
+
+ {% else %}
+ There are no locations defined.
+ {% endif %}
+
+
+
{% endblock %}
-
diff --git a/conntrackt/tests/test_views.py b/conntrackt/tests/test_views.py
--- a/conntrackt/tests/test_views.py
+++ b/conntrackt/tests/test_views.py
@@ -9,7 +9,7 @@ from django.test.client import Client
from django.contrib.auth.models import User, Permission
# Application imports
-from conntrackt.models import Project
+from conntrackt.models import Project, Location
class ViewTest(TestCase):
@@ -65,7 +65,19 @@ class IndexViewTest(ViewTest):
self.client.login(username="fullperms", password="fullperms")
response = self.client.get(reverse("index"))
- self.assertContains(response, "Currently there are no projects defined in the database. Use the administration pages in order to add a new project.")
+ self.assertContains(response, "There are no projects defined.")
+
+ def test_no_locations(self):
+ """
+ Tests the index view when no locations are defined.
+ """
+
+ Location.objects.all().delete()
+
+ self.client.login(username="fullperms", password="fullperms")
+ response = self.client.get(reverse("index"))
+
+ self.assertContains(response, "There are no locations defined.")
def test_projects_available(self):
"""
@@ -80,6 +92,19 @@ class IndexViewTest(ViewTest):
self.assertContains(response, "Test Project 1")
self.assertContains(response, "Test Project 2")
+ def test_locations_available(self):
+ """
+ Tests if locations are show or not.
+ """
+
+ self.client.login(username="fullperms", password="fullperms")
+
+ response = self.client.get(reverse("index"))
+
+ self.assertQuerysetEqual(response.context["locations"], ["
", ""])
+ self.assertContains(response, "Test Location 1")
+ self.assertContains(response, "Test Location 2")
+
class ProjectViewTest(ViewTest):
diff --git a/conntrackt/views.py b/conntrackt/views.py
--- a/conntrackt/views.py
+++ b/conntrackt/views.py
@@ -27,7 +27,7 @@ class IndexView(MultiplePermissionsRequi
# Required permissions.
permissions = {
- "all": ("conntrackt.view", "conntrackt.view",),
+ "all": ("conntrackt.view",),
}
# Raise authorisation denied exception for unmet permissions.
raise_exception = True
@@ -44,9 +44,11 @@ class IndexView(MultiplePermissionsRequi
# Set the context using the parent class.
context = super(IndexView, self).get_context_data(**kwargs)
- # Store information about all projcts in context. Optimise database
- # access for the view.
- context['projects'] = Project.objects.all().prefetch_related('entity_set').order_by('name')
+ # Store information about all projcts in context.
+ context['projects'] = Project.objects.all().order_by('name')
+
+ # Store information about all locations in context.
+ context['locations'] = Location.objects.all().order_by('name')
return context
@@ -59,7 +61,7 @@ class ProjectView(MultiplePermissionsReq
model = Project
permissions = {
- "all": ("conntrackt.view", "conntrackt.view",)
+ "all": ("conntrackt.view",),
}
# Raise authorisation denied exception for unmet permissions.
raise_exception = True
@@ -108,7 +110,7 @@ class EntityView(MultiplePermissionsRequ
# Required permissions.
permissions = {
- "all": ("conntrackt.view",)
+ "all": ("conntrackt.view",),
}
# Raise authorisation denied exception for unmet permissions.
raise_exception = True