diff --git a/nsupdate/accounts/forms.py b/nsupdate/accounts/forms.py index ac33696..ddf6188 100644 --- a/nsupdate/accounts/forms.py +++ b/nsupdate/accounts/forms.py @@ -3,8 +3,8 @@ from django import forms from django.contrib.auth.models import User + class UserProfileForm(forms.ModelForm): class Meta: model = User fields = ['first_name', 'last_name', ] - diff --git a/nsupdate/accounts/urls.py b/nsupdate/accounts/urls.py index 054ac09..77ce65b 100644 --- a/nsupdate/accounts/urls.py +++ b/nsupdate/accounts/urls.py @@ -1,14 +1,12 @@ from django.conf.urls import patterns, include, url -from accounts.views import ( - UserProfileView -) +from accounts.views import UserProfileView + from django.contrib.auth.views import password_change -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^profile/', UserProfileView.as_view(), name="account_profile"), url(r'^change_pw/', password_change, { - 'template_name': 'registration/password_change.html', - 'post_change_redirect': '/account/profile/', - }, - name="password_change"), -) + 'template_name': 'registration/password_change.html', + 'post_change_redirect': '/account/profile/', }, + name="password_change"), ) diff --git a/nsupdate/accounts/views.py b/nsupdate/accounts/views.py index 34b42f4..d3172ef 100644 --- a/nsupdate/accounts/views.py +++ b/nsupdate/accounts/views.py @@ -31,4 +31,3 @@ class PasswordChangeView(TemplateView): context = super(PasswordChangeView, self).get_context_data(*args, **kwargs) context['nav_change_password'] = True return context - diff --git a/nsupdate/main/admin.py b/nsupdate/main/admin.py index 6ac510e..9ef5b03 100644 --- a/nsupdate/main/admin.py +++ b/nsupdate/main/admin.py @@ -1,4 +1,5 @@ from main.models import * from django.contrib import admin -admin.site.register(Host) \ No newline at end of file + +admin.site.register(Host) diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index 3b9cbd8..c7aeaac 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -93,7 +93,7 @@ def update_ns(fqdn, rdtype='A', ipaddr=None, origin=None, action='upd', ttl=60): assert action in ['add', 'del', 'upd', ] origin, name = parse_name(fqdn, origin) upd = dns.update.Update(origin, - keyring=dns.tsigkeyring.from_text({settings.BASEDOMAIN+'.': settings.UPDATE_KEY}), + keyring=dns.tsigkeyring.from_text({settings.BASEDOMAIN + '.': settings.UPDATE_KEY}), keyalgorithm=settings.UPDATE_ALGO) if action == 'add': assert ipaddr is not None diff --git a/nsupdate/main/forms.py b/nsupdate/main/forms.py index 3b9032c..dcd2a40 100644 --- a/nsupdate/main/forms.py +++ b/nsupdate/main/forms.py @@ -2,8 +2,8 @@ from django import forms from main.models import Host + class HostForm(forms.ModelForm): class Meta: model = Host fields = ['fqdn', 'comment', 'update_secret'] - diff --git a/nsupdate/main/models.py b/nsupdate/main/models.py index e9ebeaa..4dead14 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,unique=True) + fqdn = models.CharField(max_length=256, unique=True) update_secret = models.CharField(max_length=256) - comment = models.CharField(max_length=256,default='',blank=True, null=True) + 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) @@ -17,8 +17,7 @@ class Host(models.Model): return u"%s - %s" % (self.fqdn, self.comment) - class HostForm(ModelForm): class Meta: model = Host - fields = ['fqdn', 'update_secret','comment'] \ No newline at end of file + fields = ['fqdn', 'update_secret', 'comment'] diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index adf6b58..7df666f 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -55,6 +55,7 @@ class OverviewView(CreateView): context['hosts'] = Host.objects.filter(created_by=self.request.user) return context + class HostView(UpdateView): model = Host template_name = "main/host.html" @@ -63,7 +64,7 @@ class HostView(UpdateView): @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(HostView, self).dispatch(*args, **kwargs) - + def get_success_url(self): return reverse('overview') @@ -78,7 +79,7 @@ class HostView(UpdateView): def get_object(self, *args, **kwargs): obj = super(HostView, self).get_object(*args, **kwargs) if obj.created_by != self.request.user: - raise PermissionDenied() #or Http404 + raise PermissionDenied() # or Http404 return obj def get_context_data(self, *args, **kwargs): @@ -87,6 +88,7 @@ class HostView(UpdateView): context['hosts'] = Host.objects.filter(created_by=self.request.user) return context + class DeleteHostView(DeleteView): model = Host template_name = "main/delete_host.html" @@ -95,11 +97,11 @@ class DeleteHostView(DeleteView): @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(DeleteHostView, self).dispatch(*args, **kwargs) - + def get_object(self, *args, **kwargs): obj = super(DeleteHostView, self).get_object(*args, **kwargs) if obj.created_by != self.request.user: - raise PermissionDenied() #or Http404 + raise PermissionDenied() # or Http404 return obj def get_success_url(self): @@ -110,5 +112,3 @@ class DeleteHostView(DeleteView): context['nav_overview'] = True context['hosts'] = Host.objects.filter(created_by=self.request.user) return context - - diff --git a/nsupdate/nsupdate/context_processors.py b/nsupdate/nsupdate/context_processors.py index ae06266..5e0069f 100644 --- a/nsupdate/nsupdate/context_processors.py +++ b/nsupdate/nsupdate/context_processors.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from django.conf import settings + def add_settings(request): context = {} context['WWW_IPV4_HOST'] = settings.WWW_IPV4_HOST context['WWW_IPV6_HOST'] = settings.WWW_IPV6_HOST return context - diff --git a/nsupdate/nsupdate/settings.py b/nsupdate/nsupdate/settings.py index cf89fe5..9311a10 100644 --- a/nsupdate/nsupdate/settings.py +++ b/nsupdate/nsupdate/settings.py @@ -14,13 +14,13 @@ MANAGERS = ADMINS DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'nsupdate.sqlite', # Or path to database file if using sqlite3. # The following settings are not used with sqlite3: 'USER': '', 'PASSWORD': '', - 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. - 'PORT': '', # Set to empty string for default. + 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. + 'PORT': '' # Set to empty string for default. } } @@ -101,7 +101,7 @@ STATICFILES_DIRS = ( STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -# 'django.contrib.staticfiles.finders.DefaultStorageFinder', + # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. @@ -111,7 +111,7 @@ SECRET_KEY = 'iwlqlh4mrwe6j+f(e8qb)^muiq2^=!v+h#_s9**6wghpd_&bg8' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', + # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( @@ -211,4 +211,3 @@ try: from .local_settings import * except ImportError: pass - diff --git a/nsupdate/nsupdate/urls.py b/nsupdate/nsupdate/urls.py index e97723d..26deeb8 100644 --- a/nsupdate/nsupdate/urls.py +++ b/nsupdate/nsupdate/urls.py @@ -4,7 +4,8 @@ from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^accounts/', include('registration.backends.default.urls')), url(r'^account/', include('accounts.urls')), url(r'^admin/', include(admin.site.urls)), @@ -15,5 +16,4 @@ from django.conf import settings if settings.DEBUG: urlpatterns += patterns('django.contrib.staticfiles.views', - url(r'^static/(?P.*)$', 'serve'), - ) + url(r'^static/(?P.*)$', 'serve'), ) diff --git a/setup.cfg b/setup.cfg index 163ca79..b5ca441 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,4 +30,5 @@ pep8ignore = *.py E124 # closing bracket does not match visual indentation (behaves strange!?) *.py E125 # continuation line does not distinguish itself from next logical line (difficult to avoid!) docs/conf.py ALL # sphinx stuff, automatically generated, don't check this + migrations/*.py ALL # autogenerated by South