diff --git a/nsupdate/main/models.py b/nsupdate/main/models.py index 889b8ab..bf07daa 100644 --- a/nsupdate/main/models.py +++ b/nsupdate/main/models.py @@ -5,9 +5,9 @@ from django.forms import ModelForm class Host(models.Model): """TODO: hash update_secret""" - fqdn = models.CharField(max_length=256) + fqdn = models.CharField(max_length=256,unique=True) update_secret = models.CharField(max_length=256) - comment = models.CharField(max_length=256,default='') + comment = models.CharField(max_length=256,default='',blank=True, null=True) last_update = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) diff --git a/nsupdate/main/templates/main/delete_host.html b/nsupdate/main/templates/main/delete_host.html index fb2169b..57d7b98 100644 --- a/nsupdate/main/templates/main/delete_host.html +++ b/nsupdate/main/templates/main/delete_host.html @@ -4,7 +4,6 @@ {% block content %}
-

Delete Host back to overview

diff --git a/nsupdate/main/templates/main/overview.html b/nsupdate/main/templates/main/overview.html index 23c3ca1..8be9743 100644 --- a/nsupdate/main/templates/main/overview.html +++ b/nsupdate/main/templates/main/overview.html @@ -23,8 +23,8 @@ {% endfor %}
-

New host

-
+
+

New host

{% csrf_token %} {{ form|bootstrap }} @@ -33,13 +33,11 @@
+

Information

your IPv4: {{ request.session.ipv4 }}
your IPv6: {{ request.session.ipv6 }} -
-
- - +
{% endblock %} diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index 6e822a6..056035e 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -9,6 +9,7 @@ from django.contrib.auth.decorators import login_required from django.contrib import messages from django.utils.decorators import method_decorator from django.core.urlresolvers import reverse +import dns.inet from main.forms import HostForm from main.models import Host @@ -19,8 +20,11 @@ class HomeView(TemplateView): def get_context_data(self, *args, **kwargs): context = super(HomeView, self).get_context_data(*args, **kwargs) - context.update(create_context(self.request)) context['nav_home'] = True + ipaddr = self.request.META['REMOTE_ADDR'] + af = dns.inet.af_for_address(ipaddr) + key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6' + self.request.session[key] = ipaddr return context diff --git a/nsupdate/manage.py b/nsupdate/manage.py old mode 100644 new mode 100755 diff --git a/nsupdate/nsupdate/templates/base.html b/nsupdate/nsupdate/templates/base.html index 45836cf..eb31462 100644 --- a/nsupdate/nsupdate/templates/base.html +++ b/nsupdate/nsupdate/templates/base.html @@ -51,15 +51,19 @@
-
- {% if messages %} - {% for message in messages %} -
- - {{ message }} -
- {% endfor %} - {% endif %} +
+
+
+ {% if messages %} + {% for message in messages %} +
+ + {{ message }} +
+ {% endfor %} + {% endif %} +
+
{% block content %}
@@ -88,16 +92,16 @@
- {% if session.ipv4 and session.ipv6 %} + {% if request.session.ipv4 and request.session.ipv6 %}

We think this are your IPs:

- {% elif session.ipv4 or session.ipv6 %} + {% elif request.session.ipv4 or request.session.ipv6 %}

We think this is your IP:

{% endif %} - {% if session.ipv4 %} -

{{session.ipv4}}

- {% elif session.ipv6 %} -

{{session.ipv6}}

+ {% if request.session.ipv4 %} +

{{request.session.ipv4}}

+ {% elif request.session.ipv6 %} +

{{request.session.ipv4}}

{% else %}

HeyHo!

{% endif %} @@ -120,6 +124,11 @@
+
+ + +
+