Minor improvements

This commit is contained in:
Marc Aymerich 2016-03-04 10:04:29 +00:00
parent 6caf838549
commit d3caeeea2a
2 changed files with 27 additions and 17 deletions

View File

@ -32,10 +32,19 @@ INSTALLED_APPS = [
# django-orchestra apps # django-orchestra apps
'orchestra', 'orchestra',
'orchestra.contrib.accounts', 'orchestra.contrib.accounts',
'orchestra.contrib.systemusers',
'orchestra.contrib.contacts', 'orchestra.contrib.contacts',
'orchestra.contrib.orchestration', 'orchestra.contrib.orchestration',
'orchestra.contrib.bills',
'orchestra.contrib.payments',
'orchestra.contrib.tasks',
'orchestra.contrib.mailer',
'orchestra.contrib.history',
'orchestra.contrib.issues',
'orchestra.contrib.services',
'orchestra.contrib.plans',
'orchestra.contrib.orders',
'orchestra.contrib.domains', 'orchestra.contrib.domains',
'orchestra.contrib.systemusers',
'orchestra.contrib.mailboxes', 'orchestra.contrib.mailboxes',
'orchestra.contrib.lists', 'orchestra.contrib.lists',
'orchestra.contrib.webapps', 'orchestra.contrib.webapps',
@ -43,16 +52,7 @@ INSTALLED_APPS = [
'orchestra.contrib.databases', 'orchestra.contrib.databases',
'orchestra.contrib.vps', 'orchestra.contrib.vps',
'orchestra.contrib.saas', 'orchestra.contrib.saas',
'orchestra.contrib.issues',
'orchestra.contrib.services',
'orchestra.contrib.plans',
'orchestra.contrib.orders',
'orchestra.contrib.miscellaneous', 'orchestra.contrib.miscellaneous',
'orchestra.contrib.bills',
'orchestra.contrib.payments',
'orchestra.contrib.tasks',
'orchestra.contrib.mailer',
'orchestra.contrib.history',
# Third-party apps # Third-party apps
'django_extensions', 'django_extensions',

View File

@ -1,3 +1,4 @@
import logging
from collections import OrderedDict from collections import OrderedDict
from django import forms from django import forms
@ -11,6 +12,9 @@ from . import settings
from .models import Account from .models import Account
logger = logging.getLogger(__name__)
def create_account_creation_form(): def create_account_creation_form():
fields = OrderedDict(**{ fields = OrderedDict(**{
'enable_systemuser': forms.BooleanField(initial=True, required=False, 'enable_systemuser': forms.BooleanField(initial=True, required=False,
@ -18,12 +22,18 @@ def create_account_creation_form():
help_text=_("Designates whether to creates an enabled or disabled related system user. " help_text=_("Designates whether to creates an enabled or disabled related system user. "
"Notice that a related system user will be always created.")) "Notice that a related system user will be always created."))
}) })
for model, __, kwargs, help_text in settings.ACCOUNTS_CREATE_RELATED: create_related = []
model = apps.get_model(model) for model, key, kwargs, help_text in settings.ACCOUNTS_CREATE_RELATED:
field_name = 'create_%s' % model._meta.model_name try:
label = _("Create %s") % model._meta.verbose_name model = apps.get_model(model)
fields[field_name] = forms.BooleanField( except LookupError:
initial=True, required=False, label=label, help_text=help_text) logger.error("%s not installed." % model)
else:
field_name = 'create_%s' % model._meta.model_name
label = _("Create %s") % model._meta.verbose_name
fields[field_name] = forms.BooleanField(
initial=True, required=False, label=label, help_text=help_text)
create_related.append((model, key, kwargs, help_text))
def clean(self): def clean(self):
""" unique usernames between accounts and system users """ """ unique usernames between accounts and system users """
@ -40,7 +50,7 @@ def create_account_creation_form():
systemuser_model = Account.main_systemuser.field.rel.to systemuser_model = Account.main_systemuser.field.rel.to
if systemuser_model.objects.filter(username=account.username).exists(): if systemuser_model.objects.filter(username=account.username).exists():
errors['username'] = _("A system user with this name already exists.") errors['username'] = _("A system user with this name already exists.")
for model, key, related_kwargs, __ in settings.ACCOUNTS_CREATE_RELATED: for model, key, related_kwargs, __ in create_related:
model = apps.get_model(model) model = apps.get_model(model)
kwargs = { kwargs = {
key: eval(related_kwargs[key], {'account': account}) key: eval(related_kwargs[key], {'account': account})