pep8 fixes

This commit is contained in:
Thomas Waldmann 2013-09-29 01:21:44 +02:00
parent 0093aab667
commit ac4860f54a
12 changed files with 31 additions and 34 deletions

View File

@ -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', ]

View File

@ -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"), )

View File

@ -31,4 +31,3 @@ class PasswordChangeView(TemplateView):
context = super(PasswordChangeView, self).get_context_data(*args, **kwargs)
context['nav_change_password'] = True
return context

View File

@ -1,4 +1,5 @@
from main.models import *
from django.contrib import admin
admin.site.register(Host)
admin.site.register(Host)

View File

@ -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

View File

@ -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']

View File

@ -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']
fields = ['fqdn', 'update_secret', 'comment']

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<path>.*)$', 'serve'),
)
url(r'^static/(?P<path>.*)$', 'serve'), )

View File

@ -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