Clean PEP8 violations

This commit is contained in:
Jan Dittberner 2015-11-22 14:03:47 +00:00
parent be0531ec30
commit b11055807f
20 changed files with 153 additions and 132 deletions

View file

@ -153,7 +153,8 @@ class DNSDomain(DomainBase):
type VARCHAR(6) NOT NULL, type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL, notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL, account VARCHAR(40) DEFAULT NULL,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (
((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE UNIQUE INDEX name_index ON domains(name); CREATE UNIQUE INDEX name_index ON domains(name);
@ -162,8 +163,8 @@ class DNSDomain(DomainBase):
# name is represented by domain # name is represented by domain
master = models.CharField(max_length=128, blank=True, null=True) master = models.CharField(max_length=128, blank=True, null=True)
last_check = models.IntegerField(null=True) last_check = models.IntegerField(null=True)
domaintype = models.CharField(max_length=6, choices=DNS_DOMAIN_TYPES, domaintype = models.CharField(
db_column='type') max_length=6, choices=DNS_DOMAIN_TYPES, db_column='type')
notified_serial = models.IntegerField(null=True) notified_serial = models.IntegerField(null=True)
# account is represented by customer_id # account is represented by customer_id
# check constraint is added via RunSQL in migration # check constraint is added via RunSQL in migration
@ -200,20 +201,22 @@ class DNSRecord(models.Model):
CONSTRAINT domain_exists CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id) FOREIGN KEY(domain_id) REFERENCES domains(id)
ON DELETE CASCADE, ON DELETE CASCADE,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (
((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE INDEX rec_name_index ON records(name); CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type); CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id); CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX recordorder ON records (domain_id, ordername text_pattern_ops); CREATE INDEX recordorder ON records (
domain_id, ordername text_pattern_ops);
""" """
domain = models.ForeignKey('DNSDomain') domain = models.ForeignKey('DNSDomain')
name = models.CharField(max_length=255, blank=True, null=True, name = models.CharField(
db_index=True) max_length=255, blank=True, null=True, db_index=True)
recordtype = models.CharField(max_length=10, blank=True, null=True, recordtype = models.CharField(
db_column='type') max_length=10, blank=True, null=True, db_column='type')
content = models.CharField(max_length=65535, blank=True, null=True) content = models.CharField(max_length=65535, blank=True, null=True)
ttl = models.IntegerField(null=True) ttl = models.IntegerField(null=True)
prio = models.IntegerField(null=True) prio = models.IntegerField(null=True)
@ -291,7 +294,8 @@ class DNSComment(models.Model):
CONSTRAINT domain_exists CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id) FOREIGN KEY(domain_id) REFERENCES domains(id)
ON DELETE CASCADE, ON DELETE CASCADE,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (
((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE INDEX comments_domain_id_idx ON comments (domain_id); CREATE INDEX comments_domain_id_idx ON comments (domain_id);
@ -403,14 +407,16 @@ class DNSTSIGKey(models.Model):
name VARCHAR(255), name VARCHAR(255),
algorithm VARCHAR(50), algorithm VARCHAR(50),
secret VARCHAR(255), secret VARCHAR(255),
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) CONSTRAINT c_lowercase_name CHECK (
((name)::TEXT = LOWER((name)::TEXT)))
); );
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm); CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
""" """
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
algorithm = models.CharField(max_length=50, choices=DNS_TSIG_KEY_ALGORITHMS) algorithm = models.CharField(
max_length=50, choices=DNS_TSIG_KEY_ALGORITHMS)
secret = models.CharField(max_length=255) secret = models.CharField(max_length=255)
# check constraint is added via RunSQL in migration # check constraint is added via RunSQL in migration

View file

@ -41,8 +41,8 @@ class CreateHostingDomainTest(TestCase):
return package return package
def test_get_anonymous(self): def test_get_anonymous(self):
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
kwargs={'package': 1})) reverse('create_hosting_domain', kwargs={'package': 1}))
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
def test_get_regular_user(self): def test_get_regular_user(self):
@ -50,7 +50,8 @@ class CreateHostingDomainTest(TestCase):
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
package = self._setup_hosting_package(customer) package = self._setup_hosting_package(customer)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': package.id})) kwargs={'package': package.id}))
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
@ -60,7 +61,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': package.id})) kwargs={'package': package.id}))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@ -70,7 +72,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': package.id})) kwargs={'package': package.id}))
self.assertTemplateUsed(response, 'domains/hostingdomain_create.html') self.assertTemplateUsed(response, 'domains/hostingdomain_create.html')
@ -78,7 +81,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': 1})) kwargs={'package': 1}))
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
@ -90,7 +94,7 @@ class CreateHostingDomainTest(TestCase):
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
view = CreateHostingDomain( view = CreateHostingDomain(
request=MagicMock(), kwargs={'package': str(package.id)}) request=MagicMock(), kwargs={'package': str(package.id)})
the_kwargs= view.get_form_kwargs() the_kwargs = view.get_form_kwargs()
self.assertIn('hostingpackage', the_kwargs) self.assertIn('hostingpackage', the_kwargs)
self.assertEqual(the_kwargs['hostingpackage'], package) self.assertEqual(the_kwargs['hostingpackage'], package)
@ -100,7 +104,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': package.id})) kwargs={'package': package.id}))
self.assertIn('hostingpackage', response.context) self.assertIn('hostingpackage', response.context)
self.assertEqual(response.context['hostingpackage'], package) self.assertEqual(response.context['hostingpackage'], package)
@ -111,7 +116,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.get(reverse('create_hosting_domain', response = self.client.get(
reverse('create_hosting_domain',
kwargs={'package': package.id})) kwargs={'package': package.id}))
self.assertIn('customer', response.context) self.assertIn('customer', response.context)
self.assertEqual(response.context['customer'], customer) self.assertEqual(response.context['customer'], customer)
@ -122,8 +128,10 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.post(reverse('create_hosting_domain', response = self.client.post(
kwargs={'package': package.id}), data={'domain': 'example.org'}) reverse('create_hosting_domain',
kwargs={'package': package.id}),
data={'domain': 'example.org'})
self.assertRedirects(response, package.get_absolute_url()) self.assertRedirects(response, package.get_absolute_url())
def test_form_valid_message(self): def test_form_valid_message(self):
@ -132,7 +140,8 @@ class CreateHostingDomainTest(TestCase):
admin = User.objects.create_superuser( admin = User.objects.create_superuser(
TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD) TEST_USER, email=TEST_EMAIL, password=TEST_PASSWORD)
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
response = self.client.post(reverse('create_hosting_domain', response = self.client.post(
reverse('create_hosting_domain',
kwargs={'package': package.id}), follow=True, kwargs={'package': package.id}), follow=True,
data={'domain': 'example.org'}) data={'domain': 'example.org'})
messages = list(response.context['messages']) messages = list(response.context['messages'])

View file

@ -12,6 +12,7 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE',
app = Celery('gnuviechadmin') app = Celery('gnuviechadmin')
def get_installed_apps(): def get_installed_apps():
return settings.INSTALLED_APPS return settings.INSTALLED_APPS

View file

@ -13,7 +13,6 @@ from gnuviechadmin import __version__ as gvaversion
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
def navigation(request): def navigation(request):
""" """
Add navigation items to the request context. Add navigation items to the request context.

View file

@ -27,7 +27,7 @@ def get_env_variable(var_name):
raise ImproperlyConfigured(error_msg) raise ImproperlyConfigured(error_msg)
########## PATH CONFIGURATION # ######### PATH CONFIGURATION
# Absolute filesystem path to the Django project directory: # Absolute filesystem path to the Django project directory:
DJANGO_ROOT = dirname(dirname(abspath(__file__))) DJANGO_ROOT = dirname(dirname(abspath(__file__)))
@ -40,19 +40,19 @@ SITE_NAME = basename(DJANGO_ROOT)
# Add our project to our pythonpath, this way we don't need to type our project # Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths: # name in our dotted import paths:
path.append(DJANGO_ROOT) path.append(DJANGO_ROOT)
########## END PATH CONFIGURATION # ######### END PATH CONFIGURATION
########## DEBUG CONFIGURATION # ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False DEBUG = False
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION # ######### END DEBUG CONFIGURATION
########## MANAGER CONFIGURATION # ######### MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = ( ADMINS = (
(get_env_variable('GVA_ADMIN_NAME'), get_env_variable('GVA_ADMIN_EMAIL')), (get_env_variable('GVA_ADMIN_NAME'), get_env_variable('GVA_ADMIN_EMAIL')),
@ -60,10 +60,10 @@ ADMINS = (
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS MANAGERS = ADMINS
########## END MANAGER CONFIGURATION # ######### END MANAGER CONFIGURATION
########## DATABASE CONFIGURATION # ######### DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = { DATABASES = {
'default': { 'default': {
@ -75,10 +75,10 @@ DATABASES = {
'PORT': get_env_variable('GVA_PGSQL_PORT'), 'PORT': get_env_variable('GVA_PGSQL_PORT'),
} }
} }
########## END DATABASE CONFIGURATION # ######### END DATABASE CONFIGURATION
########## GENERAL CONFIGURATION # ######### GENERAL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
TIME_ZONE = 'Europe/Berlin' TIME_ZONE = 'Europe/Berlin'
@ -98,7 +98,7 @@ USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True USE_TZ = True
########## END GENERAL CONFIGURATION # ######### END GENERAL CONFIGURATION
LOCALE_PATHS = ( LOCALE_PATHS = (
@ -106,59 +106,59 @@ LOCALE_PATHS = (
) )
########## MEDIA CONFIGURATION # ######### MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = normpath(join(SITE_ROOT, 'media')) MEDIA_ROOT = normpath(join(SITE_ROOT, 'media'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
########## END MEDIA CONFIGURATION # ######### END MEDIA CONFIGURATION
########## STATIC FILE CONFIGURATION # ######### STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets')) STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/' STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS # noqa
STATICFILES_DIRS = ( STATICFILES_DIRS = (
normpath(join(SITE_ROOT, 'static')), normpath(join(SITE_ROOT, 'static')),
) )
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders # noqa
STATICFILES_FINDERS = ( STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
) )
########## END STATIC FILE CONFIGURATION # ######### END STATIC FILE CONFIGURATION
########## SECRET CONFIGURATION # ######### SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# Note: This key should only be used for development and testing. # Note: This key should only be used for development and testing.
SECRET_KEY = get_env_variable('GVA_SITE_SECRET') SECRET_KEY = get_env_variable('GVA_SITE_SECRET')
########## END SECRET CONFIGURATION # ######### END SECRET CONFIGURATION
########## SITE CONFIGURATION # ######### SITE CONFIGURATION
# Hosts/domain names that are valid for this site # Hosts/domain names that are valid for this site
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
########## END SITE CONFIGURATION # ######### END SITE CONFIGURATION
########## FIXTURE CONFIGURATION # ######### FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS # noqa
FIXTURE_DIRS = ( FIXTURE_DIRS = (
normpath(join(SITE_ROOT, 'fixtures')), normpath(join(SITE_ROOT, 'fixtures')),
) )
########## END FIXTURE CONFIGURATION # ######### END FIXTURE CONFIGURATION
########## TEMPLATE CONFIGURATION # ######### TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors # noqa
TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug', 'django.core.context_processors.debug',
@ -186,10 +186,10 @@ TEMPLATE_LOADERS = (
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
normpath(join(SITE_ROOT, 'templates')), normpath(join(SITE_ROOT, 'templates')),
) )
########## END TEMPLATE CONFIGURATION # ######### END TEMPLATE CONFIGURATION
########## MIDDLEWARE CONFIGURATION # ######### MIDDLEWARE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes # See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
# Default Django middleware. # Default Django middleware.
@ -202,7 +202,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.locale.LocaleMiddleware', 'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )
########## END MIDDLEWARE CONFIGURATION # ######### END MIDDLEWARE CONFIGURATION
AUTHENTICATION_BACKENDS = ( AUTHENTICATION_BACKENDS = (
@ -214,18 +214,18 @@ AUTHENTICATION_BACKENDS = (
) )
########## URL CONFIGURATION # ######### URL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
ROOT_URLCONF = '%s.urls' % SITE_NAME ROOT_URLCONF = '%s.urls' % SITE_NAME
########## END URL CONFIGURATION # ######### END URL CONFIGURATION
########## TEST RUNNER CONFIGURATION # ######### TEST RUNNER CONFIGURATION
TEST_RUNNER = 'django.test.runner.DiscoverRunner' TEST_RUNNER = 'django.test.runner.DiscoverRunner'
########## END TEST RUNNER CONFIGURATION # ######### END TEST RUNNER CONFIGURATION
########## APP CONFIGURATION # ######### APP CONFIGURATION
DJANGO_APPS = ( DJANGO_APPS = (
# Default Django apps: # Default Django apps:
'django.contrib.auth', 'django.contrib.auth',
@ -285,23 +285,23 @@ MESSAGE_TAGS = {
messages.SUCCESS: 'alert-success', messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning', messages.WARNING: 'alert-warning',
} }
########## END APP CONFIGURATION # ######### END APP CONFIGURATION
########## ALLAUTH CONFIGURATION # ######### ALLAUTH CONFIGURATION
ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory' ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True SOCIALACCOUNT_QUERY_EMAIL = True
########## END ALLAUTH CONFIGURATION # ######### END ALLAUTH CONFIGURATION
########## CRISPY FORMS CONFIGURATION # ######### CRISPY FORMS CONFIGURATION
CRISPY_TEMPLATE_PACK = 'bootstrap3' CRISPY_TEMPLATE_PACK = 'bootstrap3'
########## END CRISPY_FORMS CONFIGURATION # ######### END CRISPY_FORMS CONFIGURATION
########## LOGGING CONFIGURATION # ######### LOGGING CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
# A sample logging configuration. The only tangible logging # A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to # performed by this configuration is to send an email to
@ -340,16 +340,16 @@ LOGGING = {
}, },
} }
} }
########## END LOGGING CONFIGURATION # ######### END LOGGING CONFIGURATION
########## WSGI CONFIGURATION # ######### WSGI CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME
########## END WSGI CONFIGURATION # ######### END WSGI CONFIGURATION
########## CELERY CONFIGURATION # ######### CELERY CONFIGURATION
BROKER_URL = get_env_variable('GVA_BROKER_URL') BROKER_URL = get_env_variable('GVA_BROKER_URL')
CELERY_RESULT_BACKEND = 'amqp' CELERY_RESULT_BACKEND = 'amqp'
CELERY_RESULT_PERSISTENT = True CELERY_RESULT_PERSISTENT = True
@ -362,10 +362,10 @@ CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['json'] CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
########## END CELERY CONFIGURATION # ######### END CELERY CONFIGURATION
########## CUSTOM APP CONFIGURATION # ######### CUSTOM APP CONFIGURATION
OSUSER_MINUID = int(get_env_variable('GVA_MIN_OS_UID')) OSUSER_MINUID = int(get_env_variable('GVA_MIN_OS_UID'))
OSUSER_MINGID = int(get_env_variable('GVA_MIN_OS_GID')) OSUSER_MINGID = int(get_env_variable('GVA_MIN_OS_GID'))
OSUSER_USERNAME_PREFIX = get_env_variable('GVA_OSUSER_PREFIX') OSUSER_USERNAME_PREFIX = get_env_variable('GVA_OSUSER_PREFIX')
@ -379,4 +379,4 @@ OSUSER_UPLOAD_SERVER = get_env_variable('GVA_OSUSER_UPLOADSERVER')
GVA_LINK_WEBMAIL = get_env_variable('GVA_WEBMAIL_URL') GVA_LINK_WEBMAIL = get_env_variable('GVA_WEBMAIL_URL')
GVA_LINK_PHPMYADMIN = get_env_variable('GVA_PHPMYADMIN_URL') GVA_LINK_PHPMYADMIN = get_env_variable('GVA_PHPMYADMIN_URL')
GVA_LINK_PHPPGADMIN = get_env_variable('GVA_PHPPGADMIN_URL') GVA_LINK_PHPPGADMIN = get_env_variable('GVA_PHPPGADMIN_URL')
########## END CUSTOM APP CONFIGURATION # ######### END CUSTOM APP CONFIGURATION

View file

@ -7,33 +7,33 @@ from __future__ import absolute_import
from .base import * from .base import *
########## DEBUG CONFIGURATION # ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION # ######### END DEBUG CONFIGURATION
########## EMAIL CONFIGURATION # ######### EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
########## END EMAIL CONFIGURATION # ######### END EMAIL CONFIGURATION
########## CACHE CONFIGURATION # ######### CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
} }
} }
########## END CACHE CONFIGURATION # ######### END CACHE CONFIGURATION
########## TOOLBAR CONFIGURATION # ######### TOOLBAR CONFIGURATION
# See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup # See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup # noqa
INSTALLED_APPS += ( INSTALLED_APPS += (
'debug_toolbar', 'debug_toolbar',
) )
@ -50,7 +50,7 @@ LOGGING['handlers'].update({
} }
}) })
LOGGING['loggers'].update(dict( LOGGING['loggers'].update(dict(
[(key, {'handlers': ['console'], 'level': 'DEBUG', 'propagate': True,}) [(key, {'handlers': ['console'], 'level': 'DEBUG', 'propagate': True, })
for key in [ for key in [
'dashboard', 'domains', 'fileservertasks', 'gvacommon', 'dashboard', 'domains', 'fileservertasks', 'gvacommon',
'gvawebcore', 'hostingpackages', 'ldaptasks', 'managemails', 'gvawebcore', 'hostingpackages', 'ldaptasks', 'managemails',
@ -61,4 +61,4 @@ DEBUG_TOOLBAR_PATCH_SETTINGS = False
# http://django-debug-toolbar.readthedocs.org/en/latest/installation.html # http://django-debug-toolbar.readthedocs.org/en/latest/installation.html
INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') INTERNAL_IPS = ('127.0.0.1', '10.0.2.2')
########## END TOOLBAR CONFIGURATION # ######### END TOOLBAR CONFIGURATION

View file

@ -6,12 +6,12 @@ from __future__ import absolute_import
from .base import * from .base import *
########## HOST CONFIGURATION # ######### HOST CONFIGURATION
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # noqa
ALLOWED_HOSTS = [SITES_DOMAIN_NAME] ALLOWED_HOSTS = [SITES_DOMAIN_NAME]
########## END HOST CONFIGURATION # ######### END HOST CONFIGURATION
########## EMAIL CONFIGURATION # ######### EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
@ -23,14 +23,14 @@ DEFAULT_FROM_EMAIL = get_env_variable('GVA_SITE_ADMINMAIL')
# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = get_env_variable('GVA_SITE_ADMINMAIL') SERVER_EMAIL = get_env_variable('GVA_SITE_ADMINMAIL')
########## END EMAIL CONFIGURATION # ######### END EMAIL CONFIGURATION
########## CACHE CONFIGURATION # ######### CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
#CACHES = {} # CACHES = {}
########## END CACHE CONFIGURATION # ######### END CACHE CONFIGURATION
########## ALLAUTH PRODUCTION CONFIGURATION # ######### ALLAUTH PRODUCTION CONFIGURATION
ACCOUNT_EMAIL_SUBJECT_PREFIX = '[Jan Dittberner IT-Consulting & -Solutions] ' ACCOUNT_EMAIL_SUBJECT_PREFIX = '[Jan Dittberner IT-Consulting & -Solutions] '
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https' ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
########## END ALLAUTH PRODUCTION CONFIGURATION # ######### END ALLAUTH PRODUCTION CONFIGURATION

View file

@ -8,4 +8,3 @@ class WSGITest(TestCase):
def test_wsgi_application(self): def test_wsgi_application(self):
from gnuviechadmin import wsgi from gnuviechadmin import wsgi
self.assertIsNotNone(wsgi.application) self.assertIsNotNone(wsgi.application)

View file

@ -24,12 +24,13 @@ path.append(SITE_ROOT)
# if running multiple sites in the same mod_wsgi process. To fix this, use # if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use # mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "jajaja.settings" # os.environ["DJANGO_SETTINGS_MODULE"] = "jajaja.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gnuviechadmin.settings.production") os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "gnuviechadmin.settings.production")
# This application object is used by any WSGI server configured to use this # This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION # file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here. # setting points here.
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application # noqa
application = get_wsgi_application() application = get_wsgi_application()
# Apply WSGI middleware here. # Apply WSGI middleware here.

View file

@ -362,8 +362,7 @@ class CustomerHostingPackage(HostingPackageBase):
def may_add_database(self): def may_add_database(self):
return ( return (
CustomerUserDatabaseOption.objects.filter( CustomerUserDatabaseOption.objects.filter(
hosting_package=self).count() hosting_package=self).count() >
>
UserDatabase.objects.filter( UserDatabase.objects.filter(
db_user__osuser=self.osuser).count() db_user__osuser=self.osuser).count()
) )

View file

@ -80,7 +80,8 @@ class CreateCustomerHostingPackage(CreateHostingPackage):
get_user_model(), username=self.kwargs['user']) get_user_model(), username=self.kwargs['user'])
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(CreateCustomerHostingPackage, self).get_context_data(**kwargs) context = super(
CreateCustomerHostingPackage, self).get_context_data(**kwargs)
context['customer'] = self.get_customer_object() context['customer'] = self.get_customer_object()
return context return context

View file

@ -7,6 +7,7 @@ from __future__ import absolute_import
from celery import shared_task from celery import shared_task
@shared_task @shared_task
def create_ldap_group(groupname, gid, descr): def create_ldap_group(groupname, gid, descr):
""" """

View file

@ -3,7 +3,8 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gnuviechadmin.settings.local") os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "gnuviechadmin.settings.local")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line

View file

@ -200,12 +200,12 @@ class MailAddress(ActivateAbleMixin, TimeStampedModel, models.Model):
forwards = MailAddressForward.objects.filter( forwards = MailAddressForward.objects.filter(
mailaddress=self).all() mailaddress=self).all()
for item in forwards: for item in forwards:
if not item.target in addresses: if item.target not in addresses:
item.delete() item.delete()
else: else:
retval.append(item) retval.append(item)
for target in addresses: for target in addresses:
if not target in [item.target for item in forwards]: if target not in [item.target for item in forwards]:
mafwd = MailAddressForward(mailaddress=self, target=target) mafwd = MailAddressForward(mailaddress=self, target=target)
if commit: if commit:
mafwd.save() mafwd.save()

View file

@ -349,10 +349,10 @@ class SshPublicKeyAdmin(admin.ModelAdmin):
for user in users: for user in users:
TaskResult.objects.create_task_result( TaskResult.objects.create_task_result(
set_file_ssh_authorized_keys.delay( set_file_ssh_authorized_keys.delay(
User.objects.get(uid=user).username, [ User.objects.get(uid=user).username,
str(key) for key in SshPublicKey.objects.filter( [str(key) for key in SshPublicKey.objects.filter(
user_id=user) user_id=user)]
]), ),
'set_file_ssh_authorized_keys' 'set_file_ssh_authorized_keys'
) )
perform_delete_selected.short_description = _( perform_delete_selected.short_description = _(

View file

@ -55,8 +55,8 @@ def handle_user_password_set(sender, instance, password, **kwargs):
taskresult.task_id) taskresult.task_id)
#@receiver(post_save) # @receiver(post_save)
#def handle_post_save(sender, **kwargs): # def handle_post_save(sender, **kwargs):
# _LOGGER.debug( # _LOGGER.debug(
# 'handling post_save signal for %s with args %s', # 'handling post_save signal for %s with args %s',
# sender, kwargs) # sender, kwargs)
@ -82,7 +82,8 @@ def handle_user_created(sender, instance, created, **kwargs):
chain = create_ldap_user.s( chain = create_ldap_user.s(
instance.username, instance.uid, instance.group.gid, instance.username, instance.uid, instance.group.gid,
instance.gecos, instance.homedir, instance.shell, None instance.gecos, instance.homedir, instance.shell, None
) | setup_file_sftp_userdir.s(instance.username ) | setup_file_sftp_userdir.s(
instance.username
) | setup_file_mail_userdir.s(instance.username) ) | setup_file_mail_userdir.s(instance.username)
taskresult = TaskResult.objects.create_task_result( taskresult = TaskResult.objects.create_task_result(
'handle_user_created', chain) 'handle_user_created', chain)
@ -119,8 +120,8 @@ def handle_ssh_keys_changed(sender, instance, **kwargs):
taskresult.task_id) taskresult.task_id)
#@receiver(post_delete) # @receiver(post_delete)
#def handle_post_delete(sender, **kwargs): # def handle_post_delete(sender, **kwargs):
# _LOGGER.debug( # _LOGGER.debug(
# 'handling post_delete signal for %s with args %s', # 'handling post_delete signal for %s with args %s',
# sender, kwargs) # sender, kwargs)
@ -138,8 +139,10 @@ def handle_group_deleted(sender, instance, **kwargs):
@receiver(post_delete, sender=User) @receiver(post_delete, sender=User)
def handle_user_deleted(sender, instance, **kwargs): def handle_user_deleted(sender, instance, **kwargs):
chain = delete_file_mail_userdir.s(instance.username chain = delete_file_mail_userdir.s(
) | delete_file_sftp_userdir.s(instance.username instance.username
) | delete_file_sftp_userdir.s(
instance.username
) | delete_ldap_user.s(instance.username) ) | delete_ldap_user.s(instance.username)
_LOGGER.debug('chain signature %s', chain) _LOGGER.debug('chain signature %s', chain)
taskresult = TaskResult.objects.create_task_result( taskresult = TaskResult.objects.create_task_result(

View file

@ -56,10 +56,10 @@ sY29ouezv4Xz2PuMch5VGPP+CDqzCM4loWgV
---- END SSH2 PUBLIC KEY ----""" ---- END SSH2 PUBLIC KEY ----"""
EXAMPLE_KEY_4_OPENSSH = "".join(( EXAMPLE_KEY_4_OPENSSH = "".join((
"ssh-rsa ", "ssh-rsa ",
"AAAAB3NzaC1yc2EAAAABIwAAAIEA1on8gxCGJJWSRT4uOrR13mUaUk0hRf4RzxSZ1zRb", "AAAAB3NzaC1yc2EAAAABIwAAAIEA1on8gxCGJJWSRT4uOrR13mUaUk0hRf4RzxSZ1zRb",
"YYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ", "YYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ",
"5TT4SfsUu/iKy9lUcCfXzwre4WWZSXXcPff+EHtWshahu3WzBdnGxm5Xoi89zcE=" "5TT4SfsUu/iKy9lUcCfXzwre4WWZSXXcPff+EHtWshahu3WzBdnGxm5Xoi89zcE="
)) ))
EXAMPLE_KEY_5_RFC4716_MULTILINE = """---- BEGIN SSH2 PUBLIC KEY ---- EXAMPLE_KEY_5_RFC4716_MULTILINE = """---- BEGIN SSH2 PUBLIC KEY ----
@ -392,7 +392,8 @@ class UserTest(TestCaseWithCeleryTasks):
self.assertEqual(len(taskres), 5) self.assertEqual(len(taskres), 5)
creators = [t.creator for t in taskres] creators = [t.creator for t in taskres]
for tcount, tcreator in [ for tcount, tcreator in [
(2, 'handle_user_removed_from_group'), (2, 'handle_user_deleted'), (2, 'handle_user_removed_from_group'),
(2, 'handle_user_deleted'),
(1, 'handle_group_deleted')]: (1, 'handle_group_deleted')]:
self.assertEqual(creators.count(tcreator), tcount) self.assertEqual(creators.count(tcreator), tcount)
self.assertEqual(len(User.objects.all()), 0) self.assertEqual(len(User.objects.all()), 0)

View file

@ -98,7 +98,6 @@ class DatabaseUserManager(models.Manager):
return db_user return db_user
@python_2_unicode_compatible @python_2_unicode_compatible
class DatabaseUser(TimeStampedModel, models.Model): class DatabaseUser(TimeStampedModel, models.Model):
osuser = models.ForeignKey(OsUser) osuser = models.ForeignKey(OsUser)

View file

@ -47,6 +47,7 @@ def enable_web_vhost(sitename):
""" """
@shared_task @shared_task
def delete_web_vhost_config(sitename): def delete_web_vhost_config(sitename):
""" """
@ -70,6 +71,7 @@ def create_web_php_fpm_pool_config(username):
""" """
@shared_task @shared_task
def delete_web_php_fpm_pool_config(username): def delete_web_php_fpm_pool_config(username):
""" """