From 37f26d603135f8320edbe97bc831297f18550c83 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 31 Aug 2014 01:23:38 +0200 Subject: [PATCH] unify hosts and domains overview views into one --- nsupdate/main/_tests/test_main.py | 2 - nsupdate/main/templates/main/domain.html | 2 +- .../main/templates/main/domain_overview.html | 46 ------------------- .../templates/main/generate_ns_secret.html | 2 +- .../{host_overview.html => overview.html} | 39 ++++++++++++++++ nsupdate/main/urls.py | 3 +- nsupdate/main/views.py | 39 +++++----------- nsupdate/templates/base.html | 7 +-- 8 files changed, 56 insertions(+), 84 deletions(-) delete mode 100644 nsupdate/main/templates/main/domain_overview.html rename nsupdate/main/templates/main/{host_overview.html => overview.html} (62%) diff --git a/nsupdate/main/_tests/test_main.py b/nsupdate/main/_tests/test_main.py index 76c9131..ea903c6 100644 --- a/nsupdate/main/_tests/test_main.py +++ b/nsupdate/main/_tests/test_main.py @@ -21,7 +21,6 @@ def test_views_anon(client): # stuff that requires being logged-in redirects to the login view: ('status', dict(), 302), ('overview', dict(), 302), - ('domain_overview', dict(), 302), ('host_view', dict(pk=1), 302), ('domain_view', dict(pk=1), 302), ('generate_secret_view', dict(pk=1), 302), @@ -47,7 +46,6 @@ def test_views_logged_in(client): ('robots', dict(), 200), ('status', dict(), 200), ('overview', dict(), 200), - ('domain_overview', dict(), 200), ('host_view', dict(pk=1), 200), ('domain_view', dict(pk=1), 200), ('generate_secret_view', dict(pk=1), 200), diff --git a/nsupdate/main/templates/main/domain.html b/nsupdate/main/templates/main/domain.html index b84355e..1b6fe38 100644 --- a/nsupdate/main/templates/main/domain.html +++ b/nsupdate/main/templates/main/domain.html @@ -3,7 +3,7 @@ {% block content %}
-

{{ domain.domain }}
{% trans "back to overview" %}

+

{{ domain.domain }}
{% trans "back to overview" %}

{% trans "Edit Domain" %}

{% trans "You can't change the domain name. If you want to have another domain name, you have to delete this domain and create a new one." %}

diff --git a/nsupdate/main/templates/main/domain_overview.html b/nsupdate/main/templates/main/domain_overview.html deleted file mode 100644 index af1e052..0000000 --- a/nsupdate/main/templates/main/domain_overview.html +++ /dev/null @@ -1,46 +0,0 @@ -{% extends "base.html" %} -{% load i18n %}{% load bootstrap %} - -{% block content %} -
-
-

- {% trans "Domains (yours first, then public)" %} - {% trans "Add Domain" %} -

- - - - - - - - - - - {% for domain in your_domains %} - - - - - - - - {% empty %} - - {% endfor %} - {% for domain in public_domains %} - - - - - - - - {% empty %} - - {% endfor %} -
{% trans "Domain" %}{% trans "Public?" %}{% trans "Available?" %}{% trans "Owner" %}{% trans "Comment" %}
{{ domain.domain }}{{ domain.public|yesno }}{{ domain.available|yesno }}{{ domain.created_by }}{{ domain.comment }}
{% trans "No domains from you yet." %}
{{ domain.domain }}{{ domain.public|yesno }}{{ domain.available|yesno }}{{ domain.created_by }}{{ domain.comment }}
{% trans "No public domains from other users yet." %}
-
-
-{% endblock %} diff --git a/nsupdate/main/templates/main/generate_ns_secret.html b/nsupdate/main/templates/main/generate_ns_secret.html index 29fc4ce..ea6a9a1 100644 --- a/nsupdate/main/templates/main/generate_ns_secret.html +++ b/nsupdate/main/templates/main/generate_ns_secret.html @@ -6,7 +6,7 @@

{% trans "Nameserver Shared Secret Generated" %}
- {% trans "back to overview" %}

+ {% trans "back to overview" %}

{% trans "New nameserver shared secret generated for you. Everytime you visit this page a new secret will be generated and the old one becomes invalid." %}

{% trans "Algorithm:" %} {{ object.get_bind9_algorithm }}

{% trans "Secret:" %} {{ shared_secret }}

diff --git a/nsupdate/main/templates/main/host_overview.html b/nsupdate/main/templates/main/overview.html similarity index 62% rename from nsupdate/main/templates/main/host_overview.html rename to nsupdate/main/templates/main/overview.html index 5190311..7f14430 100644 --- a/nsupdate/main/templates/main/host_overview.html +++ b/nsupdate/main/templates/main/overview.html @@ -60,5 +60,44 @@ {% endfor %}
+
+

+ {% trans "Domains (yours first, then public)" %} + {% trans "Add Domain" %} +

+ + + + + + + + + + + {% for domain in your_domains %} + + + + + + + + {% empty %} + + {% endfor %} + {% for domain in public_domains %} + + + + + + + + {% empty %} + + {% endfor %} +
{% trans "Domain" %}{% trans "Public?" %}{% trans "Available?" %}{% trans "Owner" %}{% trans "Comment" %}
{{ domain.domain }}{{ domain.public|yesno }}{{ domain.available|yesno }}{{ domain.created_by }}{{ domain.comment }}
{% trans "No domains from you yet." %}
{{ domain.domain }}{{ domain.public|yesno }}{{ domain.available|yesno }}{{ domain.created_by }}{{ domain.comment }}
{% trans "No public domains from other users yet." %}
+
{% endblock %} diff --git a/nsupdate/main/urls.py b/nsupdate/main/urls.py index b23a369..beb0273 100644 --- a/nsupdate/main/urls.py +++ b/nsupdate/main/urls.py @@ -7,7 +7,7 @@ from django.views.generic import TemplateView from .views import ( HomeView, OverviewView, HostView, AddHostView, DeleteHostView, AboutView, GenerateSecretView, GenerateNSSecretView, - RobotsTxtView, DomainOverviewView, DomainView, AddDomainView, DeleteDomainView, StatusView, JsUpdateView, + RobotsTxtView, DomainView, AddDomainView, DeleteDomainView, StatusView, JsUpdateView, UpdaterHostConfigOverviewView, UpdaterHostConfigView, DeleteUpdaterHostConfigView, CustomTemplateView) from ..api.views import ( myip_view, DetectIpView, AjaxGetIps, NicUpdateView, AuthorizedNicUpdateView, @@ -29,7 +29,6 @@ urlpatterns = patterns( url(r'^generate_ns_secret/(?P\d+)/$', GenerateNSSecretView.as_view(), name='generate_ns_secret_view'), url(r'^host/add/$', AddHostView.as_view(), name='add_host'), url(r'^host/(?P\d+)/delete/$', DeleteHostView.as_view(), name='delete_host'), - url(r'^domain_overview/$', DomainOverviewView.as_view(), name='domain_overview'), url(r'^domain/add/$', AddDomainView.as_view(), name='add_domain'), url(r'^domain/(?P\d+)/delete/$', DeleteDomainView.as_view(), name='delete_domain'), url(r'^updater_hostconfig_overview/(?P\d+)/$', UpdaterHostConfigOverviewView.as_view(), diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index c2bda8f..6477042 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -41,7 +41,7 @@ class GenerateSecretView(UpdateView): def get_context_data(self, *args, **kwargs): context = super(GenerateSecretView, self).get_context_data(*args, **kwargs) - context['nav_host_overview'] = True + context['nav_overview'] = True # generate secret, store it hashed and return the plain secret for the context context['update_secret'] = self.object.generate_secret() context['hosts'] = Host.objects.filter(created_by=self.request.user) @@ -174,7 +174,7 @@ class JsUpdateView(TemplateView): class OverviewView(TemplateView): - template_name = "main/host_overview.html" + template_name = "main/overview.html" @method_decorator(login_required) def dispatch(self, *args, **kwargs): @@ -182,8 +182,12 @@ class OverviewView(TemplateView): def get_context_data(self, *args, **kwargs): context = super(OverviewView, self).get_context_data(*args, **kwargs) - context['nav_host_overview'] = True + context['nav_overview'] = True context['hosts'] = Host.objects.filter(created_by=self.request.user) + context['your_domains'] = Domain.objects.filter( + created_by=self.request.user) + context['public_domains'] = Domain.objects.filter( + public=True).exclude(created_by=self.request.user) return context @@ -232,7 +236,7 @@ class AddHostView(CreateView): def get_context_data(self, *args, **kwargs): context = super(AddHostView, self).get_context_data(*args, **kwargs) - context['nav_host_overview'] = True + context['nav_overview'] = True return context @@ -262,7 +266,7 @@ class HostView(UpdateView): def get_context_data(self, *args, **kwargs): context = super(HostView, self).get_context_data(*args, **kwargs) - context['nav_host_overview'] = True + context['nav_overview'] = True context['remote_addr'] = self.request.META['REMOTE_ADDR'] context['hosts'] = Host.objects.filter(created_by=self.request.user) return context @@ -287,29 +291,11 @@ class DeleteHostView(DeleteView): def get_context_data(self, *args, **kwargs): context = super(DeleteHostView, self).get_context_data(*args, **kwargs) - context['nav_host_overview'] = True + context['nav_overview'] = True context['hosts'] = Host.objects.filter(created_by=self.request.user) return context -class DomainOverviewView(TemplateView): - template_name = "main/domain_overview.html" - - @method_decorator(login_required) - def dispatch(self, *args, **kwargs): - return super(DomainOverviewView, self).dispatch(*args, **kwargs) - - def get_context_data(self, *args, **kwargs): - context = super( - DomainOverviewView, self).get_context_data(*args, **kwargs) - context['nav_domain_overview'] = True - context['your_domains'] = Domain.objects.filter( - created_by=self.request.user) - context['public_domains'] = Domain.objects.filter( - public=True).exclude(created_by=self.request.user) - return context - - class AddDomainView(CreateView): template_name = "main/domain_add.html" model = Domain @@ -350,7 +336,7 @@ class DomainView(UpdateView): return super(DomainView, self).dispatch(*args, **kwargs) def get_success_url(self): - return reverse('domain_overview') + return reverse('overview') def form_valid(self, form): self.object = form.save(commit=False) @@ -386,7 +372,7 @@ class DeleteDomainView(DeleteView): return obj def get_success_url(self): - return reverse('domain_overview') + return reverse('overview') def get_context_data(self, *args, **kwargs): context = super(DeleteDomainView, self).get_context_data(*args, **kwargs) @@ -500,7 +486,6 @@ Disallow: /update/ Disallow: /host/ Disallow: /overview/ Disallow: /domain/ -Disallow: /domain_overview/ Disallow: /updater_hostconfig/ Disallow: /updater_hostconfig_overview/ """ diff --git a/nsupdate/templates/base.html b/nsupdate/templates/base.html index 908b04e..b7e703b 100644 --- a/nsupdate/templates/base.html +++ b/nsupdate/templates/base.html @@ -40,11 +40,8 @@ {% trans "Home" %} {% if request.user.is_authenticated %} - - {% trans "Hosts" %} - - - {% trans "Domains" %} + + {% trans "Overview" %} {% trans "Status" %}