Random fixes

This commit is contained in:
Marc Aymerich 2015-05-22 13:15:06 +00:00
parent c6a687736b
commit f38eaa6ac8
10 changed files with 42 additions and 20 deletions

View File

@ -384,3 +384,6 @@ http://wiki2.dovecot.org/Pigeonhole/Sieve/Examples
# mail system users group? which one is more convinient? if main group does not exists, backend will fail!
Bash/Python/PHPBackend
# Gandi sync domains cancelled

View File

@ -34,7 +34,6 @@ class ChangeListDefaultFilter(object):
default_changelist_filters = ()
def changelist_view(self, request, extra_context=None):
""" Default filter as 'my_nodes=True' """
defaults = []
for key, value in self.default_changelist_filters:
set_url_query(request, key, value)
@ -47,6 +46,22 @@ class ChangeListDefaultFilter(object):
return response
defaults = []
querystring = request.META['QUERY_STRING']
redirect = False
for field, value in self.default_changelist_filters:
if field not in queryseting:
redirect = True
querystring[field] = value
if redirect:
raise
if not request.META.get('HTTP_REFERER', '').startswith(request.build_absolute_uri()):
querystring = '&'.join('%s=%s' % filed, value in querystring.items())
from django.http import HttpResponseRedirect
return HttpResponseRedirect(request.path + '?%s' % querystring)
return super(ChangeListDefaultFilter, self).changelist_view(request, extra_context=extra_context)
class AtLeastOneRequiredInlineFormSet(BaseInlineFormSet):
def clean(self):
"""Check that at least one service has been entered."""
@ -162,7 +177,7 @@ class ChangeAddFieldsMixin(object):
return super(ChangeAddFieldsMixin, self).get_form(request, obj, **defaults)
class ExtendedModelAdmin(ChangeViewActionsMixin, ChangeAddFieldsMixin, admin.ModelAdmin):
class ExtendedModelAdmin(ChangeViewActionsMixin, ChangeAddFieldsMixin, ChangeListDefaultFilter, admin.ModelAdmin):
list_prefetch_related = None
def get_queryset(self, request):

View File

@ -9,7 +9,7 @@ from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from markdown import markdown
from orchestra.admin import ChangeListDefaultFilter, ExtendedModelAdmin#, ChangeViewActions
from orchestra.admin import ExtendedModelAdmin
from orchestra.admin.utils import admin_link, admin_colored, wrap_admin_view, admin_date
from orchestra.contrib.contacts.models import Contact
@ -118,7 +118,7 @@ class TicketInline(admin.TabularInline):
ticket_id.allow_tags = True
class TicketAdmin(ChangeListDefaultFilter, ExtendedModelAdmin):
class TicketAdmin(ExtendedModelAdmin):
list_display = (
'unbold_id', 'bold_subject', 'display_creator', 'display_owner',
'display_queue', 'display_priority', 'display_state', 'updated'

View File

@ -91,7 +91,9 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
self.generate_filter(mailbox, context)
def set_quota(self, mailbox, context):
context['quota'] = mailbox.resources.disk.allocated * mailbox.resources.disk.resource.get_scale()
allocated = mailbox.resources.disk.allocated
scale = mailbox.resources.disk.resource.get_scale()
context['quota'] = allocated * scale
#unit_to_bytes(mailbox.resources.disk.unit)
self.append(textwrap.dedent("""
# Set Maildir quota for %(user)s
@ -121,9 +123,10 @@ class UNIXUserMaildirBackend(SieveFilteringMixin, ServiceController):
super(UNIXUserMaildirBackend, self).commit()
def get_context(self, mailbox):
account_as_group = settings.MAILBOXES_USE_ACCOUNT_AS_GROUP
context = {
'user': mailbox.name,
'group': mailbox.account.username if settings.MAILBOXES_USE_ACCOUNT_AS_GROUP else mailbox.name,
'group': mailbox.account.username if account_as_group else mailbox.name,
'name': mailbox.name,
'password': mailbox.password if mailbox.active else '*%s' % mailbox.password,
'home': mailbox.get_home(),
@ -311,9 +314,11 @@ class PostfixAddressBackend(PostfixAddressVirtualDomainBackend):
Addresses based on Postfix virtual alias domains, includes <tt>PostfixAddressVirtualDomainBackend</tt>.
"""
verbose_name = _("Postfix address")
doc_settings = (settings,
('MAILBOXES_LOCAL_DOMAIN', 'MAILBOXES_VIRTUAL_ALIAS_DOMAINS_PATH', 'MAILBOXES_VIRTUAL_ALIAS_MAPS_PATH')
)
doc_settings = (settings, (
'MAILBOXES_LOCAL_DOMAIN',
'MAILBOXES_VIRTUAL_ALIAS_DOMAINS_PATH',
'MAILBOXES_VIRTUAL_ALIAS_MAPS_PATH'
))
def update_virtual_alias_maps(self, address, context):
destination = address.destination

View File

@ -54,7 +54,7 @@ class Interval(object):
return remaining
def __repr__(self):
return "Start: {ini} End: {end}".format(
return "<ini:{ini}/end:{end}>".format(
ini=self.ini.strftime('%Y-%-m-%-d'),
end=self.end.strftime('%Y-%-m-%-d')
)
@ -87,8 +87,7 @@ def get_intersections(order_intervals, compensations):
for intersection_interval in intersection:
length += len(intersection_interval)
intersections.append((length, compensation))
intersections.sort()
return intersections
return sorted(intersections, key=lambda i: i[0])
def intersect(compensation, order_intervals):

View File

@ -55,7 +55,7 @@
{% regroup form.forms by app as formlist %}
{% for app in formlist %}
<fieldset class="module">
<h2>{{ app.grouper|lower|capfirst }}</h2>
<h2 id="{{ app.grouper|lower}}">{{ app.grouper|lower|capfirst }}</h2>
<table id="formset" class="form" style="width:100%">
{% for form in app.list %}
{{ form.non_field_errors }}

View File

@ -205,8 +205,8 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
# Format PHP init vars
init_vars = opt.get_php_init_vars(merge=self.MERGE)
if init_vars:
init_vars = [ "-d %s='%s'" % (k, v.replace("'", '"')) for k,v in init_vars.items() ]
init_vars = ' \\\n '.join(init_vars)
init_vars = [ " \\\n -d %s='%s'" % (k, v.replace("'", '"')) for k,v in init_vars.items() ]
init_vars = ''.join(init_vars)
context.update({
'php_binary_path': os.path.normpath(settings.WEBAPPS_PHP_CGI_BINARY_PATH % context),
'php_rc': os.path.normpath(settings.WEBAPPS_PHP_CGI_RC_DIR % context),
@ -220,7 +220,7 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
export PHPRC=%(php_rc)s
export PHP_INI_SCAN_DIR=%(php_ini_scan)s
export PHP_FCGI_MAX_REQUESTS=%(max_requests)s
exec %(php_binary_path)s %(php_init_vars)s""") % context
exec %(php_binary_path)s%(php_init_vars)s""") % context
def get_fcgid_cmd_options(self, webapp, context):
options = self.get_options(webapp)

View File

@ -95,7 +95,7 @@ class WordPressBackend(WebAppServiceMixin, ServiceController):
}
exc('chown -R %(user)s:%(group)s %(app_path)s');
// Execute wordpress installation process
// Run wordpress installation process
define('WP_CONTENT_DIR', 'wp-content/');
define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );

View File

@ -95,7 +95,7 @@ class Processes(AppOption):
class PHPEnableFunctions(PHPAppOption):
name = 'enable_functions'
verbose_name = _("Enable functions")
help_text = '<tt>%s</tt>' % '<br>'.join([
help_text = '<tt>%s</tt>' % ',<br>'.join([
','.join(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS[i:i+10])
for i in range(0, len(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS), 10)
])