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,
notified_serial INT 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);
@ -162,8 +163,8 @@ class DNSDomain(DomainBase):
# name is represented by domain
master = models.CharField(max_length=128, blank=True, null=True)
last_check = models.IntegerField(null=True)
domaintype = models.CharField(max_length=6, choices=DNS_DOMAIN_TYPES,
db_column='type')
domaintype = models.CharField(
max_length=6, choices=DNS_DOMAIN_TYPES, db_column='type')
notified_serial = models.IntegerField(null=True)
# account is represented by customer_id
# check constraint is added via RunSQL in migration
@ -200,20 +201,22 @@ class DNSRecord(models.Model):
CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id)
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 nametype_index ON records(name,type);
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')
name = models.CharField(max_length=255, blank=True, null=True,
db_index=True)
recordtype = models.CharField(max_length=10, blank=True, null=True,
db_column='type')
name = models.CharField(
max_length=255, blank=True, null=True, db_index=True)
recordtype = models.CharField(
max_length=10, blank=True, null=True, db_column='type')
content = models.CharField(max_length=65535, blank=True, null=True)
ttl = models.IntegerField(null=True)
prio = models.IntegerField(null=True)
@ -291,7 +294,8 @@ class DNSComment(models.Model):
CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id)
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);
@ -403,14 +407,16 @@ class DNSTSIGKey(models.Model):
name VARCHAR(255),
algorithm VARCHAR(50),
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);
"""
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)
# check constraint is added via RunSQL in migration

View file

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

View file

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

View file

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

View file

@ -27,7 +27,7 @@ def get_env_variable(var_name):
raise ImproperlyConfigured(error_msg)
########## PATH CONFIGURATION
# ######### PATH CONFIGURATION
# Absolute filesystem path to the Django project directory:
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
# name in our dotted import paths:
path.append(DJANGO_ROOT)
########## END PATH CONFIGURATION
# ######### END PATH CONFIGURATION
########## DEBUG CONFIGURATION
# ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
# ######### END DEBUG CONFIGURATION
########## MANAGER CONFIGURATION
# ######### MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = (
(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
MANAGERS = ADMINS
########## END MANAGER CONFIGURATION
# ######### END MANAGER CONFIGURATION
########## DATABASE CONFIGURATION
# ######### DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
@ -75,10 +75,10 @@ DATABASES = {
'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
TIME_ZONE = 'Europe/Berlin'
@ -98,7 +98,7 @@ USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True
########## END GENERAL CONFIGURATION
# ######### END GENERAL CONFIGURATION
LOCALE_PATHS = (
@ -106,59 +106,59 @@ LOCALE_PATHS = (
)
########## MEDIA CONFIGURATION
# ######### MEDIA CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = normpath(join(SITE_ROOT, 'media'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
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
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
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 = (
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 = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'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
# Note: This key should only be used for development and testing.
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
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []
########## END SITE CONFIGURATION
# ######### END SITE CONFIGURATION
########## FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
# ######### FIXTURE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS # noqa
FIXTURE_DIRS = (
normpath(join(SITE_ROOT, 'fixtures')),
)
########## END FIXTURE CONFIGURATION
# ######### END FIXTURE CONFIGURATION
########## TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
# ######### TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors # noqa
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
@ -186,10 +186,10 @@ TEMPLATE_LOADERS = (
TEMPLATE_DIRS = (
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
MIDDLEWARE_CLASSES = (
# Default Django middleware.
@ -202,7 +202,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
########## END MIDDLEWARE CONFIGURATION
# ######### END MIDDLEWARE CONFIGURATION
AUTHENTICATION_BACKENDS = (
@ -214,18 +214,18 @@ AUTHENTICATION_BACKENDS = (
)
########## URL CONFIGURATION
# ######### URL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
ROOT_URLCONF = '%s.urls' % SITE_NAME
########## END URL CONFIGURATION
# ######### END URL CONFIGURATION
########## TEST RUNNER CONFIGURATION
# ######### TEST RUNNER CONFIGURATION
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
########## END TEST RUNNER CONFIGURATION
# ######### END TEST RUNNER CONFIGURATION
########## APP CONFIGURATION
# ######### APP CONFIGURATION
DJANGO_APPS = (
# Default Django apps:
'django.contrib.auth',
@ -285,23 +285,23 @@ MESSAGE_TAGS = {
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
}
########## END APP CONFIGURATION
# ######### END APP CONFIGURATION
########## ALLAUTH CONFIGURATION
# ######### ALLAUTH CONFIGURATION
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True
########## END ALLAUTH CONFIGURATION
# ######### END ALLAUTH CONFIGURATION
########## CRISPY FORMS CONFIGURATION
# ######### CRISPY FORMS CONFIGURATION
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
# A sample logging configuration. The only tangible logging
# 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
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')
CELERY_RESULT_BACKEND = 'amqp'
CELERY_RESULT_PERSISTENT = True
@ -362,10 +362,10 @@ CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_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_MINGID = int(get_env_variable('GVA_MIN_OS_GID'))
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_PHPMYADMIN = get_env_variable('GVA_PHPMYADMIN_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 *
########## DEBUG CONFIGURATION
# ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-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
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
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
########## END CACHE CONFIGURATION
# ######### END CACHE CONFIGURATION
########## TOOLBAR CONFIGURATION
# See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup
# ######### TOOLBAR CONFIGURATION
# See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup # noqa
INSTALLED_APPS += (
'debug_toolbar',
)
@ -50,7 +50,7 @@ LOGGING['handlers'].update({
}
})
LOGGING['loggers'].update(dict(
[(key, {'handlers': ['console'], 'level': 'DEBUG', 'propagate': True,})
[(key, {'handlers': ['console'], 'level': 'DEBUG', 'propagate': True, })
for key in [
'dashboard', 'domains', 'fileservertasks', 'gvacommon',
'gvawebcore', 'hostingpackages', 'ldaptasks', 'managemails',
@ -61,4 +61,4 @@ DEBUG_TOOLBAR_PATCH_SETTINGS = False
# http://django-debug-toolbar.readthedocs.org/en/latest/installation.html
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 *
########## HOST CONFIGURATION
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production
# ######### HOST CONFIGURATION
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # noqa
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
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
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
#CACHES = {}
########## END CACHE CONFIGURATION
# CACHES = {}
# ######### END CACHE CONFIGURATION
########## ALLAUTH PRODUCTION CONFIGURATION
# ######### ALLAUTH PRODUCTION CONFIGURATION
ACCOUNT_EMAIL_SUBJECT_PREFIX = '[Jan Dittberner IT-Consulting & -Solutions] '
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):
from gnuviechadmin import wsgi
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
# mod_wsgi daemon mode with each site in its own daemon process, or use
# 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
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application # noqa
application = get_wsgi_application()
# Apply WSGI middleware here.

View file

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

View file

@ -80,7 +80,8 @@ class CreateCustomerHostingPackage(CreateHostingPackage):
get_user_model(), username=self.kwargs['user'])
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()
return context

View file

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

View file

@ -3,7 +3,8 @@ import os
import sys
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

View file

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

View file

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

View file

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

View file

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

View file

@ -98,7 +98,6 @@ class DatabaseUserManager(models.Manager):
return db_user
@python_2_unicode_compatible
class DatabaseUser(TimeStampedModel, models.Model):
osuser = models.ForeignKey(OsUser)
@ -204,7 +203,7 @@ class UserDatabaseManager(models.Manager):
@transaction.atomic
def create_userdatabase_with_user(
self, db_type, osuser, password=None, commit=True):
self, db_type, osuser, password=None, commit=True):
"""
Creates a new user database with a new user.

View file

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