unify hosts and domains overview views into one

This commit is contained in:
Thomas Waldmann 2014-08-31 01:23:38 +02:00
parent c6bdd34fee
commit 37f26d6031
8 changed files with 56 additions and 84 deletions

View File

@ -21,7 +21,6 @@ def test_views_anon(client):
# stuff that requires being logged-in redirects to the login view: # stuff that requires being logged-in redirects to the login view:
('status', dict(), 302), ('status', dict(), 302),
('overview', dict(), 302), ('overview', dict(), 302),
('domain_overview', dict(), 302),
('host_view', dict(pk=1), 302), ('host_view', dict(pk=1), 302),
('domain_view', dict(pk=1), 302), ('domain_view', dict(pk=1), 302),
('generate_secret_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), ('robots', dict(), 200),
('status', dict(), 200), ('status', dict(), 200),
('overview', dict(), 200), ('overview', dict(), 200),
('domain_overview', dict(), 200),
('host_view', dict(pk=1), 200), ('host_view', dict(pk=1), 200),
('domain_view', dict(pk=1), 200), ('domain_view', dict(pk=1), 200),
('generate_secret_view', dict(pk=1), 200), ('generate_secret_view', dict(pk=1), 200),

View File

@ -3,7 +3,7 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
<h3>{{ domain.domain }} <br><small><a href="{% url 'domain_overview' %}"><i class="fa fa-angle-double-left"></i> {% trans "back to overview" %}</a></small></h3> <h3>{{ domain.domain }} <br><small><a href="{% url 'overview' %}"><i class="fa fa-angle-double-left"></i> {% trans "back to overview" %}</a></small></h3>
<div class="col-md-8"> <div class="col-md-8">
<h3>{% trans "Edit Domain" %}</h3> <h3>{% trans "Edit Domain" %}</h3>
<p>{% 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." %}</p> <p>{% 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." %}</p>

View File

@ -1,46 +0,0 @@
{% extends "base.html" %}
{% load i18n %}{% load bootstrap %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h3>
{% trans "Domains (yours first, then public)" %}
<a href="{% url 'add_domain' %}" class="btn btn-primary">{% trans "Add Domain" %}</a>
</h3>
<table class="table">
<thead>
<tr>
<th>{% trans "Domain" %}</th>
<th>{% trans "Public?" %}</th>
<th>{% trans "Available?" %}</th>
<th>{% trans "Owner" %}</th>
<th>{% trans "Comment" %}</th>
</tr>
</thead>
{% for domain in your_domains %}
<tr>
<td><a href="{% url 'domain_view' domain.pk %}">{{ domain.domain }}</a></td>
<td>{{ domain.public|yesno }}</td>
<td>{{ domain.available|yesno }}</td>
<td>{{ domain.created_by }}</td>
<td>{{ domain.comment }}</td>
</tr>
{% empty %}
<tr><td colspan="5">{% trans "No domains from you yet." %}</td></tr>
{% endfor %}
{% for domain in public_domains %}
<tr>
<td>{{ domain.domain }}</td>
<td>{{ domain.public|yesno }}</td>
<td>{{ domain.available|yesno }}</td>
<td>{{ domain.created_by }}</td>
<td>{{ domain.comment }}</td>
</tr>
{% empty %}
<tr><td colspan="5">{% trans "No public domains from other users yet." %}</td></tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}

View File

@ -6,7 +6,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="well"> <div class="well">
<h3>{% trans "Nameserver Shared Secret Generated" %} <small><br> <h3>{% trans "Nameserver Shared Secret Generated" %} <small><br>
<a href="{% url 'domain_overview' %}"><i class="fa fa-angle-double-left"></i> {% trans "back to overview" %}</a></small></h3> <a href="{% url 'overview' %}"><i class="fa fa-angle-double-left"></i> {% trans "back to overview" %}</a></small></h3>
<p>{% 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." %}</p> <p>{% 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." %}</p>
<p>{% trans "Algorithm:" %} <b>{{ object.get_bind9_algorithm }}</b></p> <p>{% trans "Algorithm:" %} <b>{{ object.get_bind9_algorithm }}</b></p>
<p>{% trans "Secret:" %} <b>{{ shared_secret }}</b></p> <p>{% trans "Secret:" %} <b>{{ shared_secret }}</b></p>

View File

@ -60,5 +60,44 @@
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
<div class="col-md-12">
<h3>
{% trans "Domains (yours first, then public)" %}
<a href="{% url 'add_domain' %}" class="btn btn-primary">{% trans "Add Domain" %}</a>
</h3>
<table class="table">
<thead>
<tr>
<th>{% trans "Domain" %}</th>
<th>{% trans "Public?" %}</th>
<th>{% trans "Available?" %}</th>
<th>{% trans "Owner" %}</th>
<th>{% trans "Comment" %}</th>
</tr>
</thead>
{% for domain in your_domains %}
<tr>
<td><a href="{% url 'domain_view' domain.pk %}">{{ domain.domain }}</a></td>
<td>{{ domain.public|yesno }}</td>
<td>{{ domain.available|yesno }}</td>
<td>{{ domain.created_by }}</td>
<td>{{ domain.comment }}</td>
</tr>
{% empty %}
<tr><td colspan="5">{% trans "No domains from you yet." %}</td></tr>
{% endfor %}
{% for domain in public_domains %}
<tr>
<td>{{ domain.domain }}</td>
<td>{{ domain.public|yesno }}</td>
<td>{{ domain.available|yesno }}</td>
<td>{{ domain.created_by }}</td>
<td>{{ domain.comment }}</td>
</tr>
{% empty %}
<tr><td colspan="5">{% trans "No public domains from other users yet." %}</td></tr>
{% endfor %}
</table>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -7,7 +7,7 @@ from django.views.generic import TemplateView
from .views import ( from .views import (
HomeView, OverviewView, HostView, AddHostView, DeleteHostView, AboutView, GenerateSecretView, GenerateNSSecretView, 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) UpdaterHostConfigOverviewView, UpdaterHostConfigView, DeleteUpdaterHostConfigView, CustomTemplateView)
from ..api.views import ( from ..api.views import (
myip_view, DetectIpView, AjaxGetIps, NicUpdateView, AuthorizedNicUpdateView, myip_view, DetectIpView, AjaxGetIps, NicUpdateView, AuthorizedNicUpdateView,
@ -29,7 +29,6 @@ urlpatterns = patterns(
url(r'^generate_ns_secret/(?P<pk>\d+)/$', GenerateNSSecretView.as_view(), name='generate_ns_secret_view'), url(r'^generate_ns_secret/(?P<pk>\d+)/$', GenerateNSSecretView.as_view(), name='generate_ns_secret_view'),
url(r'^host/add/$', AddHostView.as_view(), name='add_host'), url(r'^host/add/$', AddHostView.as_view(), name='add_host'),
url(r'^host/(?P<pk>\d+)/delete/$', DeleteHostView.as_view(), name='delete_host'), url(r'^host/(?P<pk>\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/add/$', AddDomainView.as_view(), name='add_domain'),
url(r'^domain/(?P<pk>\d+)/delete/$', DeleteDomainView.as_view(), name='delete_domain'), url(r'^domain/(?P<pk>\d+)/delete/$', DeleteDomainView.as_view(), name='delete_domain'),
url(r'^updater_hostconfig_overview/(?P<pk>\d+)/$', UpdaterHostConfigOverviewView.as_view(), url(r'^updater_hostconfig_overview/(?P<pk>\d+)/$', UpdaterHostConfigOverviewView.as_view(),

View File

@ -41,7 +41,7 @@ class GenerateSecretView(UpdateView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(GenerateSecretView, self).get_context_data(*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 # generate secret, store it hashed and return the plain secret for the context
context['update_secret'] = self.object.generate_secret() context['update_secret'] = self.object.generate_secret()
context['hosts'] = Host.objects.filter(created_by=self.request.user) context['hosts'] = Host.objects.filter(created_by=self.request.user)
@ -174,7 +174,7 @@ class JsUpdateView(TemplateView):
class OverviewView(TemplateView): class OverviewView(TemplateView):
template_name = "main/host_overview.html" template_name = "main/overview.html"
@method_decorator(login_required) @method_decorator(login_required)
def dispatch(self, *args, **kwargs): def dispatch(self, *args, **kwargs):
@ -182,8 +182,12 @@ class OverviewView(TemplateView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(OverviewView, self).get_context_data(*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['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 return context
@ -232,7 +236,7 @@ class AddHostView(CreateView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(AddHostView, self).get_context_data(*args, **kwargs) context = super(AddHostView, self).get_context_data(*args, **kwargs)
context['nav_host_overview'] = True context['nav_overview'] = True
return context return context
@ -262,7 +266,7 @@ class HostView(UpdateView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(HostView, self).get_context_data(*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['remote_addr'] = self.request.META['REMOTE_ADDR']
context['hosts'] = Host.objects.filter(created_by=self.request.user) context['hosts'] = Host.objects.filter(created_by=self.request.user)
return context return context
@ -287,29 +291,11 @@ class DeleteHostView(DeleteView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(DeleteHostView, self).get_context_data(*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) context['hosts'] = Host.objects.filter(created_by=self.request.user)
return context 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): class AddDomainView(CreateView):
template_name = "main/domain_add.html" template_name = "main/domain_add.html"
model = Domain model = Domain
@ -350,7 +336,7 @@ class DomainView(UpdateView):
return super(DomainView, self).dispatch(*args, **kwargs) return super(DomainView, self).dispatch(*args, **kwargs)
def get_success_url(self): def get_success_url(self):
return reverse('domain_overview') return reverse('overview')
def form_valid(self, form): def form_valid(self, form):
self.object = form.save(commit=False) self.object = form.save(commit=False)
@ -386,7 +372,7 @@ class DeleteDomainView(DeleteView):
return obj return obj
def get_success_url(self): def get_success_url(self):
return reverse('domain_overview') return reverse('overview')
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(DeleteDomainView, self).get_context_data(*args, **kwargs) context = super(DeleteDomainView, self).get_context_data(*args, **kwargs)
@ -500,7 +486,6 @@ Disallow: /update/
Disallow: /host/ Disallow: /host/
Disallow: /overview/ Disallow: /overview/
Disallow: /domain/ Disallow: /domain/
Disallow: /domain_overview/
Disallow: /updater_hostconfig/ Disallow: /updater_hostconfig/
Disallow: /updater_hostconfig_overview/ Disallow: /updater_hostconfig_overview/
""" """

View File

@ -40,11 +40,8 @@
<a href="{% url 'home' %}"><i class="fa fa-home fa-fw"></i> {% trans "Home" %}</a> <a href="{% url 'home' %}"><i class="fa fa-home fa-fw"></i> {% trans "Home" %}</a>
</li> </li>
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<li{% if nav_host_overview %} class="active"{% endif %}> <li{% if nav_overview %} class="active"{% endif %}>
<a href="{% url 'overview' %}"><i class="fa fa-list fa-fw"></i> {% trans "Hosts" %}</a> <a href="{% url 'overview' %}"><i class="fa fa-list fa-fw"></i> {% trans "Overview" %}</a>
</li>
<li{% if nav_domain_overview %} class="active"{% endif %}>
<a href="{% url 'domain_overview' %}"><i class="fa fa-list fa-fw"></i> {% trans "Domains" %}</a>
</li> </li>
<li{% if nav_status %} class="active"{% endif %}> <li{% if nav_status %} class="active"{% endif %}>
<a href="{% url 'status' %}"><i class="fa fa-list fa-fw"></i> {% trans "Status" %}</a> <a href="{% url 'status' %}"><i class="fa fa-list fa-fw"></i> {% trans "Status" %}</a>