pep8 fixes
This commit is contained in:
parent
0093aab667
commit
ac4860f54a
@ -3,8 +3,8 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class UserProfileForm(forms.ModelForm):
|
class UserProfileForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['first_name', 'last_name', ]
|
fields = ['first_name', 'last_name', ]
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import patterns, include, url
|
||||||
from accounts.views import (
|
from accounts.views import UserProfileView
|
||||||
UserProfileView
|
|
||||||
)
|
|
||||||
from django.contrib.auth.views import password_change
|
from django.contrib.auth.views import password_change
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns(
|
||||||
|
'',
|
||||||
url(r'^profile/', UserProfileView.as_view(), name="account_profile"),
|
url(r'^profile/', UserProfileView.as_view(), name="account_profile"),
|
||||||
url(r'^change_pw/', password_change, {
|
url(r'^change_pw/', password_change, {
|
||||||
'template_name': 'registration/password_change.html',
|
'template_name': 'registration/password_change.html',
|
||||||
'post_change_redirect': '/account/profile/',
|
'post_change_redirect': '/account/profile/', },
|
||||||
},
|
name="password_change"), )
|
||||||
name="password_change"),
|
|
||||||
)
|
|
||||||
|
@ -31,4 +31,3 @@ class PasswordChangeView(TemplateView):
|
|||||||
context = super(PasswordChangeView, self).get_context_data(*args, **kwargs)
|
context = super(PasswordChangeView, self).get_context_data(*args, **kwargs)
|
||||||
context['nav_change_password'] = True
|
context['nav_change_password'] = True
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from main.models import *
|
from main.models import *
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
admin.site.register(Host)
|
|
||||||
|
admin.site.register(Host)
|
||||||
|
@ -93,7 +93,7 @@ def update_ns(fqdn, rdtype='A', ipaddr=None, origin=None, action='upd', ttl=60):
|
|||||||
assert action in ['add', 'del', 'upd', ]
|
assert action in ['add', 'del', 'upd', ]
|
||||||
origin, name = parse_name(fqdn, origin)
|
origin, name = parse_name(fqdn, origin)
|
||||||
upd = dns.update.Update(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)
|
keyalgorithm=settings.UPDATE_ALGO)
|
||||||
if action == 'add':
|
if action == 'add':
|
||||||
assert ipaddr is not None
|
assert ipaddr is not None
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from main.models import Host
|
from main.models import Host
|
||||||
|
|
||||||
|
|
||||||
class HostForm(forms.ModelForm):
|
class HostForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Host
|
model = Host
|
||||||
fields = ['fqdn', 'comment', 'update_secret']
|
fields = ['fqdn', 'comment', 'update_secret']
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ from django.forms import ModelForm
|
|||||||
|
|
||||||
class Host(models.Model):
|
class Host(models.Model):
|
||||||
"""TODO: hash update_secret"""
|
"""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)
|
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)
|
last_update = models.DateTimeField(auto_now=True)
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
@ -17,8 +17,7 @@ class Host(models.Model):
|
|||||||
return u"%s - %s" % (self.fqdn, self.comment)
|
return u"%s - %s" % (self.fqdn, self.comment)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HostForm(ModelForm):
|
class HostForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Host
|
model = Host
|
||||||
fields = ['fqdn', 'update_secret','comment']
|
fields = ['fqdn', 'update_secret', 'comment']
|
||||||
|
@ -55,6 +55,7 @@ class OverviewView(CreateView):
|
|||||||
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 HostView(UpdateView):
|
class HostView(UpdateView):
|
||||||
model = Host
|
model = Host
|
||||||
template_name = "main/host.html"
|
template_name = "main/host.html"
|
||||||
@ -63,7 +64,7 @@ class HostView(UpdateView):
|
|||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
return super(HostView, self).dispatch(*args, **kwargs)
|
return super(HostView, self).dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('overview')
|
return reverse('overview')
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ class HostView(UpdateView):
|
|||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
obj = super(HostView, self).get_object(*args, **kwargs)
|
obj = super(HostView, self).get_object(*args, **kwargs)
|
||||||
if obj.created_by != self.request.user:
|
if obj.created_by != self.request.user:
|
||||||
raise PermissionDenied() #or Http404
|
raise PermissionDenied() # or Http404
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
@ -87,6 +88,7 @@ class HostView(UpdateView):
|
|||||||
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 DeleteHostView(DeleteView):
|
class DeleteHostView(DeleteView):
|
||||||
model = Host
|
model = Host
|
||||||
template_name = "main/delete_host.html"
|
template_name = "main/delete_host.html"
|
||||||
@ -95,11 +97,11 @@ class DeleteHostView(DeleteView):
|
|||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
return super(DeleteHostView, self).dispatch(*args, **kwargs)
|
return super(DeleteHostView, self).dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
obj = super(DeleteHostView, self).get_object(*args, **kwargs)
|
obj = super(DeleteHostView, self).get_object(*args, **kwargs)
|
||||||
if obj.created_by != self.request.user:
|
if obj.created_by != self.request.user:
|
||||||
raise PermissionDenied() #or Http404
|
raise PermissionDenied() # or Http404
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@ -110,5 +112,3 @@ class DeleteHostView(DeleteView):
|
|||||||
context['nav_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
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def add_settings(request):
|
def add_settings(request):
|
||||||
context = {}
|
context = {}
|
||||||
context['WWW_IPV4_HOST'] = settings.WWW_IPV4_HOST
|
context['WWW_IPV4_HOST'] = settings.WWW_IPV4_HOST
|
||||||
context['WWW_IPV6_HOST'] = settings.WWW_IPV6_HOST
|
context['WWW_IPV6_HOST'] = settings.WWW_IPV6_HOST
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -14,13 +14,13 @@ MANAGERS = ADMINS
|
|||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'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.
|
'NAME': 'nsupdate.sqlite', # Or path to database file if using sqlite3.
|
||||||
# The following settings are not used with sqlite3:
|
# The following settings are not used with sqlite3:
|
||||||
'USER': '',
|
'USER': '',
|
||||||
'PASSWORD': '',
|
'PASSWORD': '',
|
||||||
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||||
'PORT': '', # Set to empty string for default.
|
'PORT': '' # Set to empty string for default.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ STATICFILES_DIRS = (
|
|||||||
STATICFILES_FINDERS = (
|
STATICFILES_FINDERS = (
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
'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.
|
# 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 = (
|
TEMPLATE_LOADERS = (
|
||||||
'django.template.loaders.filesystem.Loader',
|
'django.template.loaders.filesystem.Loader',
|
||||||
'django.template.loaders.app_directories.Loader',
|
'django.template.loaders.app_directories.Loader',
|
||||||
# 'django.template.loaders.eggs.Loader',
|
# 'django.template.loaders.eggs.Loader',
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
@ -211,4 +211,3 @@ try:
|
|||||||
from .local_settings import *
|
from .local_settings import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ from django.views.generic import TemplateView
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns(
|
||||||
|
'',
|
||||||
url(r'^accounts/', include('registration.backends.default.urls')),
|
url(r'^accounts/', include('registration.backends.default.urls')),
|
||||||
url(r'^account/', include('accounts.urls')),
|
url(r'^account/', include('accounts.urls')),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
@ -15,5 +16,4 @@ from django.conf import settings
|
|||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += patterns('django.contrib.staticfiles.views',
|
urlpatterns += patterns('django.contrib.staticfiles.views',
|
||||||
url(r'^static/(?P<path>.*)$', 'serve'),
|
url(r'^static/(?P<path>.*)$', 'serve'), )
|
||||||
)
|
|
||||||
|
@ -30,4 +30,5 @@ pep8ignore =
|
|||||||
*.py E124 # closing bracket does not match visual indentation (behaves strange!?)
|
*.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!)
|
*.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
|
docs/conf.py ALL # sphinx stuff, automatically generated, don't check this
|
||||||
|
migrations/*.py ALL # autogenerated by South
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user