diff --git a/nsupdate/main/forms.py b/nsupdate/main/forms.py
index 515ea4a..01c6491 100644
--- a/nsupdate/main/forms.py
+++ b/nsupdate/main/forms.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django import forms
-from .models import Host, Domain
+from .models import Host, Domain, ServiceUpdaterHostConfig
class CreateHostForm(forms.ModelForm):
@@ -34,3 +34,20 @@ class EditDomainForm(forms.ModelForm):
model = Domain
fields = ['comment', 'nameserver_ip', 'public', 'available',
'nameserver_update_algorithm', 'nameserver_update_secret']
+
+
+class CreateUpdaterHostConfigForm(forms.ModelForm):
+ class Meta(object):
+ model = ServiceUpdaterHostConfig
+ fields = ['service', 'hostname', 'name', 'password',
+ 'give_ipv4', 'give_ipv6', 'comment']
+ widgets = {
+ 'hostname': forms.widgets.TextInput(attrs=dict(autofocus=None)),
+ }
+
+
+class EditUpdaterHostConfigForm(forms.ModelForm):
+ class Meta(object):
+ model = ServiceUpdaterHostConfig
+ fields = ['hostname', 'comment', 'name', 'password',
+ 'give_ipv4', 'give_ipv6']
diff --git a/nsupdate/main/templates/main/host.html b/nsupdate/main/templates/main/host.html
index 2af388b..b260ef3 100644
--- a/nsupdate/main/templates/main/host.html
+++ b/nsupdate/main/templates/main/host.html
@@ -12,6 +12,11 @@
{{ form|bootstrap }}
+
Update other Services
+ We can send updates to other services when we receive an update from you.
+
Show Configurations
diff --git a/nsupdate/main/templates/main/updater_hostconfig.html b/nsupdate/main/templates/main/updater_hostconfig.html
new file mode 100644
index 0000000..df1f180
--- /dev/null
+++ b/nsupdate/main/templates/main/updater_hostconfig.html
@@ -0,0 +1,38 @@
+{% extends "base.html" %}
+{% load bootstrap %}
+
+{% block content %}
+
+
{{ object.hostname }} ({{ object.service.name }})
back to overview
+
+
Edit Updater Configuration
+
+
Delete Updater Configuration
+
+ Deleting a updater configuration is not undoable. If you need it back, you'll have to add it again.
+
+
+
+
+
+
Help
+
Here you can edit the configuration of the "{{ object.service.name }}" updater.
+
+
+ The values you need here are the same ones as you would usually enter in your router
+ or update client.
+
+
+ You get these values after registering with the "{{ object.service.name }}" service
+ and (likely) configuring that service to accept updates.
+
+
+
+
+{% endblock %}
diff --git a/nsupdate/main/templates/main/updater_hostconfig_overview.html b/nsupdate/main/templates/main/updater_hostconfig_overview.html
new file mode 100644
index 0000000..8075692
--- /dev/null
+++ b/nsupdate/main/templates/main/updater_hostconfig_overview.html
@@ -0,0 +1,55 @@
+{% extends "base.html" %}
+{% load bootstrap %}
+
+{% block content %}
+
+
+
Your updater configurations for other services
+
+
+
+ Service |
+ Host |
+ give IPv4 |
+ give IPv6 |
+ Comment |
+
+
+ {% for uc in updater_configs %}
+
+ {{ uc.service.name }} (SSL: {{ uc.service.secure|yesno }}) |
+ {{ uc.hostname }} |
+ {{ uc.give_ipv4|yesno }} |
+ {{ uc.give_ipv6|yesno }} |
+ {{ uc.comment }} |
+
+ {% empty %}
+ No other services to update yet.
+ {% endfor %}
+
+
+
+
+
+
+
+
+
Create a new updater configuration
+
+
+
+
+
+
Help
+
Here you can add new configurations for 3rd party services you like to get updated.
+
+
We will send an update to them each time you update your host with us.
+
+
+
+
+{% endblock %}
diff --git a/nsupdate/main/urls.py b/nsupdate/main/urls.py
index 5844122..2843191 100644
--- a/nsupdate/main/urls.py
+++ b/nsupdate/main/urls.py
@@ -3,7 +3,8 @@ from django.views.generic import TemplateView
from .views import (
HomeView, OverviewView, HostView, DeleteHostView, AboutView, GenerateSecretView, GenerateNSSecretView,
- RobotsTxtView, DomainOverviewView, DomainView, DeleteDomainView, StatusView)
+ RobotsTxtView, DomainOverviewView, DomainView, DeleteDomainView, StatusView,
+ UpdaterHostConfigOverviewView, UpdaterHostConfigView, DeleteUpdaterHostConfigView)
from ..api.views import (
myip_view, DetectIpView, AjaxGetIps, NicUpdateView, AuthorizedNicUpdateView)
@@ -23,6 +24,11 @@ urlpatterns = patterns(
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/(?P\d+)/delete/$', DeleteDomainView.as_view(), name='delete_domain'),
+ url(r'^updater_hostconfig_overview/(?P\d+)/$', UpdaterHostConfigOverviewView.as_view(),
+ name='updater_hostconfig_overview'),
+ url(r'^updater_hostconfig/(?P\d+)/$', UpdaterHostConfigView.as_view(), name='updater_hostconfig'),
+ url(r'^updater_hostconfig/(?P\d+)/delete/$', DeleteUpdaterHostConfigView.as_view(),
+ name='delete_updater_hostconfig'),
# internal use by the web ui
url(r'^detectip/(?P\w+)/$', DetectIpView.as_view(), name='detectip'),
url(r'^ajax_get_ips/$', AjaxGetIps.as_view(), name="ajax_get_ips"),
diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py
index c16fddf..97c01df 100644
--- a/nsupdate/main/views.py
+++ b/nsupdate/main/views.py
@@ -16,8 +16,9 @@ from django.utils.timezone import now
import dnstools
-from .forms import CreateHostForm, EditHostForm, CreateDomainForm, EditDomainForm
-from .models import Host, Domain
+from .forms import (CreateHostForm, EditHostForm, CreateDomainForm, EditDomainForm,
+ CreateUpdaterHostConfigForm, EditUpdaterHostConfigForm)
+from .models import Host, Domain, ServiceUpdaterHostConfig
class GenerateSecretView(UpdateView):
@@ -317,6 +318,88 @@ class DeleteDomainView(DeleteView):
return context
+class UpdaterHostConfigOverviewView(CreateView):
+ model = ServiceUpdaterHostConfig
+ template_name = "main/updater_hostconfig_overview.html"
+ form_class = CreateUpdaterHostConfigForm
+
+ @method_decorator(login_required)
+ def dispatch(self, *args, **kwargs):
+ self.__host_pk = kwargs.pop('pk', None)
+ return super(UpdaterHostConfigOverviewView, self).dispatch(*args, **kwargs)
+
+ def get_success_url(self):
+ return reverse('updater_hostconfig_overview', args=(self.__host_pk,))
+
+ def form_valid(self, form):
+ self.object = form.save(commit=False)
+ self.object.host = Host(pk=self.__host_pk)
+ self.object.created_by = self.request.user
+ self.object.save()
+ messages.add_message(self.request, messages.SUCCESS, 'Service Updater Host Configuration added.')
+ return HttpResponseRedirect(self.get_success_url())
+
+ def get_context_data(self, *args, **kwargs):
+ context = super(
+ UpdaterHostConfigOverviewView, self).get_context_data(*args, **kwargs)
+ context['updater_configs'] = ServiceUpdaterHostConfig.objects.filter(
+ host=self.__host_pk)
+ return context
+
+
+class UpdaterHostConfigView(UpdateView):
+ model = ServiceUpdaterHostConfig
+ template_name = "main/updater_hostconfig.html"
+ form_class = EditUpdaterHostConfigForm
+
+ @method_decorator(login_required)
+ def dispatch(self, *args, **kwargs):
+ return super(UpdaterHostConfigView, self).dispatch(*args, **kwargs)
+
+ def get_success_url(self):
+ host_pk = self.object.host.pk
+ return reverse('updater_hostconfig_overview', args=(host_pk,))
+
+ def form_valid(self, form):
+ self.object = form.save(commit=False)
+ self.object.save()
+ messages.add_message(self.request, messages.SUCCESS, 'Service Updater Host Configuration updated.')
+ return HttpResponseRedirect(self.get_success_url())
+
+ def get_object(self, *args, **kwargs):
+ obj = super(UpdaterHostConfigView, self).get_object(*args, **kwargs)
+ if obj.created_by != self.request.user:
+ raise PermissionDenied() # or Http404
+ return obj
+
+ def get_context_data(self, *args, **kwargs):
+ context = super(UpdaterHostConfigView, self).get_context_data(*args, **kwargs)
+ return context
+
+
+class DeleteUpdaterHostConfigView(DeleteView):
+ model = ServiceUpdaterHostConfig
+ template_name = "main/delete_object.html"
+
+ @method_decorator(login_required)
+ def dispatch(self, *args, **kwargs):
+ return super(DeleteUpdaterHostConfigView, self).dispatch(*args, **kwargs)
+
+ def get_object(self, *args, **kwargs):
+ obj = super(DeleteUpdaterHostConfigView, self).get_object(*args, **kwargs)
+ if obj.created_by != self.request.user:
+ raise PermissionDenied() # or Http404
+ return obj
+
+ def get_success_url(self):
+ host_pk = self.object.host.pk
+ return reverse('updater_hostconfig_overview', args=(host_pk,))
+
+ def get_context_data(self, *args, **kwargs):
+ context = super(DeleteUpdaterHostConfigView, self).get_context_data(*args, **kwargs)
+ return context
+
+
class RobotsTxtView(View):
"""
Dynamically serve robots.txt content.