Clean PEP8 violations
This commit is contained in:
parent
be0531ec30
commit
b11055807f
20 changed files with 153 additions and 132 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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,7 +50,8 @@ 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',
|
||||
response = self.client.get(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': package.id}))
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
|
@ -60,7 +61,8 @@ 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',
|
||||
response = self.client.get(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': package.id}))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
@ -70,7 +72,8 @@ 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',
|
||||
response = self.client.get(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': package.id}))
|
||||
self.assertTemplateUsed(response, 'domains/hostingdomain_create.html')
|
||||
|
||||
|
@ -78,7 +81,8 @@ 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',
|
||||
response = self.client.get(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': 1}))
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
|
@ -100,7 +104,8 @@ 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',
|
||||
response = self.client.get(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': package.id}))
|
||||
self.assertIn('hostingpackage', response.context)
|
||||
self.assertEqual(response.context['hostingpackage'], package)
|
||||
|
@ -111,7 +116,8 @@ 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',
|
||||
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,7 +140,8 @@ 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',
|
||||
response = self.client.post(
|
||||
reverse('create_hosting_domain',
|
||||
kwargs={'package': package.id}), follow=True,
|
||||
data={'domain': 'example.org'})
|
||||
messages = list(response.context['messages'])
|
||||
|
|
|
@ -12,6 +12,7 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE',
|
|||
|
||||
app = Celery('gnuviechadmin')
|
||||
|
||||
|
||||
def get_installed_apps():
|
||||
return settings.INSTALLED_APPS
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ from gnuviechadmin import __version__ as gvaversion
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
def navigation(request):
|
||||
"""
|
||||
Add navigation items to the request context.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -122,12 +122,12 @@ 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',
|
||||
|
@ -150,7 +150,7 @@ ALLOWED_HOSTS = []
|
|||
|
||||
|
||||
# ######### 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 = (
|
||||
normpath(join(SITE_ROOT, 'fixtures')),
|
||||
)
|
||||
|
@ -158,7 +158,7 @@ FIXTURE_DIRS = (
|
|||
|
||||
|
||||
# ######### 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 = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
|
|
|
@ -33,7 +33,7 @@ CACHES = {
|
|||
|
||||
|
||||
# ######### 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 += (
|
||||
'debug_toolbar',
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ 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
|
||||
# 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
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ class WSGITest(TestCase):
|
|||
def test_wsgi_application(self):
|
||||
from gnuviechadmin import wsgi
|
||||
self.assertIsNotNone(wsgi.application)
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ from __future__ import absolute_import
|
|||
|
||||
from celery import shared_task
|
||||
|
||||
|
||||
@shared_task
|
||||
def create_ldap_group(groupname, gid, descr):
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 = _(
|
||||
|
|
|
@ -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)
|
||||
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -98,7 +98,6 @@ class DatabaseUserManager(models.Manager):
|
|||
return db_user
|
||||
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DatabaseUser(TimeStampedModel, models.Model):
|
||||
osuser = models.ForeignKey(OsUser)
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue