Random fixes

This commit is contained in:
Marc Aymerich 2014-11-10 15:40:51 +00:00
parent aa34f09fdd
commit 42c696c6ec
6 changed files with 27 additions and 11 deletions

View File

@ -54,7 +54,7 @@ class Domain(models.Model):
def get_subdomains(self):
""" proxy method, needed for input validation, see helpers.domain_for_validation """
return self.origin.subdomain_set.all()
return self.origin.subdomain_set.all().prefetch_related('records')
def get_top(self):
return type(self).get_top_domain(self.name)
@ -62,7 +62,7 @@ class Domain(models.Model):
def render_zone(self):
origin = self.origin
zone = origin.render_records()
for subdomain in origin.get_subdomains().prefetch_related('records'):
for subdomain in origin.get_subdomains():
zone += subdomain.render_records()
return zone

View File

@ -17,7 +17,7 @@ class ResourceForm(forms.ModelForm):
self.resource = kwargs.pop('resource', None)
super(ResourceForm, self).__init__(*args, **kwargs)
if self.resource:
self.fields['verbose_name'].initial = self.resource.verbose_name
self.fields['verbose_name'].initial = self.resource.get_verbose_name()
self.fields['unit'].initial = self.resource.unit
if self.resource.on_demand:
self.fields['allocated'].required = False

View File

@ -121,6 +121,9 @@ class Resource(models.Model):
def get_scale(self):
return eval(self.scale)
def get_verbose_name(self):
return self.verbose_name or self.name
class ResourceData(models.Model):

View File

@ -22,7 +22,9 @@ class PlanAdmin(ExtendedModelAdmin):
list_display = ('name', 'is_default', 'is_combinable', 'allow_multiple')
list_filter = ('is_default', 'is_combinable', 'allow_multiple')
fields = ('verbose_name', 'name', 'is_default', 'is_combinable', 'allow_multiple')
prepopulated_fields = {'name': ('verbose_name',)}
prepopulated_fields = {
'name': ('verbose_name',)
}
change_readonly_fields = ('name',)
inlines = [RateInline]

View File

@ -84,6 +84,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
return '<br>'.join(domains)
display_domains.short_description = _("domains")
display_domains.allow_tags = True
display_domains.admin_order_field = 'domains'
def display_webapps(self, website):
webapps = []

View File

@ -26,11 +26,11 @@ WEBSITES_OPTIONS = getattr(settings, 'WEBSITES_OPTIONS', {
),
'redirect': (
_("HTTPD - Redirection"),
_("[permanent] &lt;website path&gt; &lt;destination URL&gt;"),
_("<tt>[permanent] &lt;website path&gt; &lt;destination URL&gt;</tt>"),
r'^(permanent\s[^ ]+|[^ ]+)\s[^ ]+$',
),
'ssl_ca': (
_("HTTPD - SSL CA"),
"HTTPD - SSL CA",
_("Filesystem path of the CA certificate file."),
r'^[^ ]+$'
),
@ -45,21 +45,31 @@ WEBSITES_OPTIONS = getattr(settings, 'WEBSITES_OPTIONS', {
r'^[^ ]+$',
),
'sec_rule_remove': (
_("HTTPD - SecRuleRemoveById"),
"HTTPD - SecRuleRemoveById",
_("Space separated ModSecurity rule IDs."),
r'^[0-9\s]+$',
),
'sec_engine': (
_("HTTPD - Modsecurity engine"),
_("On or Off, defaults to On"),
"HTTPD - Modsecurity engine",
_("<tt>On</tt> or <tt>Off</tt>, defaults to On"),
r'^(On|Off)$',
),
'user_group': (
_("HTTPD - SuexecUserGroup"),
_("Username and optional groupname (user [group])"),
"HTTPD - SuexecUserGroup",
_("<tt>user [group]</tt>, username and optional groupname."),
# TODO validate existing user/group
r'^[\w/_]+(\s[\w/_]+)*$',
),
# TODO backend support
'error_document': (
"HTTPD - ErrorDocumentRoot",
_("&lt;error code&gt; &lt;URL/path/message&gt;<br>"
"<tt>&nbsp;500 http://foo.example.com/cgi-bin/tester</tt><br>"
"<tt>&nbsp;404 /cgi-bin/bad_urls.pl</tt><br>"
"<tt>&nbsp;401 /subscription_info.html</tt><br>"
"<tt>&nbsp;403 \"Sorry can't allow you access today\"</tt>"),
r'[45]0[0-9]\s.*',
)
})