From 1924888b37f96679f71ceef8d60c847ce7d131e1 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 3 Oct 2013 19:26:39 +0200 Subject: [PATCH] reorder imports: stdlib, other libs, django, nsupdate stuff (views, etc.) --- nsupdate/accounts/urls.py | 3 ++- nsupdate/api/views.py | 7 ++++--- nsupdate/main/_tests/test_dnstools.py | 10 ++++++---- nsupdate/main/admin.py | 3 ++- nsupdate/main/dnstools.py | 4 ++-- nsupdate/main/forms.py | 1 + nsupdate/main/models.py | 10 ++++++---- nsupdate/main/urls.py | 2 ++ nsupdate/main/views.py | 5 ++++- nsupdate/manage.py | 3 +-- nsupdate/nsupdate/settings.py | 4 ++-- nsupdate/nsupdate/urls.py | 2 +- 12 files changed, 33 insertions(+), 21 deletions(-) diff --git a/nsupdate/accounts/urls.py b/nsupdate/accounts/urls.py index 0fa8893..476ec8c 100644 --- a/nsupdate/accounts/urls.py +++ b/nsupdate/accounts/urls.py @@ -1,7 +1,8 @@ from django.conf.urls import patterns, url +from django.contrib.auth.views import password_change + from accounts.views import UserProfileView -from django.contrib.auth.views import password_change urlpatterns = patterns( '', diff --git a/nsupdate/api/views.py b/nsupdate/api/views.py index 3b34094..1143224 100644 --- a/nsupdate/api/views.py +++ b/nsupdate/api/views.py @@ -1,8 +1,12 @@ # -*- coding: utf-8 -*- +import os + import logging logger = logging.getLogger(__name__) +import dns.inet + from django.http import HttpResponse from django.conf import settings from django.contrib.auth.hashers import check_password @@ -10,9 +14,6 @@ from django.contrib.auth.decorators import login_required from django.contrib.sessions.backends.db import SessionStore from main.models import Host -import dns.inet -import os - from main.dnstools import update, SameIpError diff --git a/nsupdate/main/_tests/test_dnstools.py b/nsupdate/main/_tests/test_dnstools.py index 1d6978e..186d6a5 100644 --- a/nsupdate/main/_tests/test_dnstools.py +++ b/nsupdate/main/_tests/test_dnstools.py @@ -4,12 +4,14 @@ Tests for dnstools module. import pytest -from ..dnstools import add, delete, update, query_ns, parse_name, update_ns, SameIpError -from django.conf import settings -BASEDOMAIN = settings.BASEDOMAIN - from dns.resolver import NXDOMAIN +from django.conf import settings + +from ..dnstools import add, delete, update, query_ns, parse_name, update_ns, SameIpError + +BASEDOMAIN = settings.BASEDOMAIN + class TestIntelligentUpdater(object): def test_double_update(self): diff --git a/nsupdate/main/admin.py b/nsupdate/main/admin.py index fbf02ed..8537305 100644 --- a/nsupdate/main/admin.py +++ b/nsupdate/main/admin.py @@ -1,6 +1,7 @@ -from main.models import Host, Domain, BlacklistedDomain from django.contrib import admin +from main.models import Host, Domain, BlacklistedDomain + admin.site.register(BlacklistedDomain) admin.site.register(Domain) admin.site.register(Host) diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index bb2dd65..83f3093 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -4,8 +4,6 @@ Misc. DNS related code: query, dynamic update, etc. Usually, higher level code wants to call the add/update/delete functions. """ -from django.conf import settings - import dns.inet import dns.name import dns.resolver @@ -14,6 +12,8 @@ import dns.update import dns.tsig import dns.tsigkeyring +from django.conf import settings + class SameIpError(ValueError): """ diff --git a/nsupdate/main/forms.py b/nsupdate/main/forms.py index e78872a..b1ae0a7 100644 --- a/nsupdate/main/forms.py +++ b/nsupdate/main/forms.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from django import forms + from main.models import Host diff --git a/nsupdate/main/models.py b/nsupdate/main/models.py index e84973a..094fa0c 100644 --- a/nsupdate/main/models.py +++ b/nsupdate/main/models.py @@ -1,3 +1,8 @@ +import re +from datetime import datetime + +import dns.resolver + from django.db import models from django.contrib.auth.models import User from django.core.exceptions import ValidationError @@ -5,11 +10,8 @@ from django.core.validators import RegexValidator from django.conf import settings from django.db.models.signals import post_delete from django.contrib.auth.hashers import make_password -from main import dnstools -import dns.resolver -from datetime import datetime -import re +from main import dnstools class BlacklistedDomain(models.Model): diff --git a/nsupdate/main/urls.py b/nsupdate/main/urls.py index 5366158..39138f6 100644 --- a/nsupdate/main/urls.py +++ b/nsupdate/main/urls.py @@ -1,11 +1,13 @@ from django.conf.urls import patterns, url from django.views.generic import TemplateView + from main.views import ( HomeView, OverviewView, HostView, DeleteHostView, AboutView, HelpView, GenerateSecretView, RobotsTxtView, ) from api.views import ( MyIpView, DetectIpView, NicUpdateView, AuthorizedNicUpdateView) + urlpatterns = patterns( '', url(r'^$', HomeView.as_view(), name="home"), diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index 741090b..4b655fa 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- + +import dns.inet + from django.views.generic import TemplateView, CreateView from django.views.generic.edit import UpdateView, DeleteView from django.http import HttpResponse, HttpResponseRedirect @@ -7,7 +10,7 @@ from django.contrib import messages from django.utils.decorators import method_decorator from django.core.urlresolvers import reverse from django.core.exceptions import PermissionDenied -import dns.inet + import dnstools from main.forms import CreateHostForm, EditHostForm diff --git a/nsupdate/manage.py b/nsupdate/manage.py index 06343a6..fdd3ca4 100755 --- a/nsupdate/manage.py +++ b/nsupdate/manage.py @@ -2,9 +2,8 @@ import os import sys + if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nsupdate.settings") - from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) diff --git a/nsupdate/nsupdate/settings.py b/nsupdate/nsupdate/settings.py index b9f94f0..ef44bf6 100644 --- a/nsupdate/nsupdate/settings.py +++ b/nsupdate/nsupdate/settings.py @@ -2,9 +2,9 @@ Django settings for nsupdate project """ -import django.conf.global_settings as DEFAULT_SETTINGS -import dns.tsig import os +import dns.tsig +import django.conf.global_settings as DEFAULT_SETTINGS DEBUG = True TEMPLATE_DEBUG = DEBUG diff --git a/nsupdate/nsupdate/urls.py b/nsupdate/nsupdate/urls.py index 0d9964e..1bf582a 100644 --- a/nsupdate/nsupdate/urls.py +++ b/nsupdate/nsupdate/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import patterns, include, url - from django.contrib import admin + admin.autodiscover() urlpatterns = patterns(