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! # mail system users group? which one is more convinient? if main group does not exists, backend will fail!
Bash/Python/PHPBackend Bash/Python/PHPBackend
# Gandi sync domains cancelled

View file

@ -34,7 +34,6 @@ class ChangeListDefaultFilter(object):
default_changelist_filters = () default_changelist_filters = ()
def changelist_view(self, request, extra_context=None): def changelist_view(self, request, extra_context=None):
""" Default filter as 'my_nodes=True' """
defaults = [] defaults = []
for key, value in self.default_changelist_filters: for key, value in self.default_changelist_filters:
set_url_query(request, key, value) set_url_query(request, key, value)
@ -47,6 +46,22 @@ class ChangeListDefaultFilter(object):
return response 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): class AtLeastOneRequiredInlineFormSet(BaseInlineFormSet):
def clean(self): def clean(self):
"""Check that at least one service has been entered.""" """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) 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 list_prefetch_related = None
def get_queryset(self, request): 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 django.utils.translation import ugettext_lazy as _
from markdown import markdown 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.admin.utils import admin_link, admin_colored, wrap_admin_view, admin_date
from orchestra.contrib.contacts.models import Contact from orchestra.contrib.contacts.models import Contact
@ -118,7 +118,7 @@ class TicketInline(admin.TabularInline):
ticket_id.allow_tags = True ticket_id.allow_tags = True
class TicketAdmin(ChangeListDefaultFilter, ExtendedModelAdmin): class TicketAdmin(ExtendedModelAdmin):
list_display = ( list_display = (
'unbold_id', 'bold_subject', 'display_creator', 'display_owner', 'unbold_id', 'bold_subject', 'display_creator', 'display_owner',
'display_queue', 'display_priority', 'display_state', 'updated' 'display_queue', 'display_priority', 'display_state', 'updated'

View file

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

View file

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

View file

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

View file

@ -205,8 +205,8 @@ class PHPBackend(WebAppServiceMixin, ServiceController):
# Format PHP init vars # Format PHP init vars
init_vars = opt.get_php_init_vars(merge=self.MERGE) init_vars = opt.get_php_init_vars(merge=self.MERGE)
if init_vars: if init_vars:
init_vars = [ "-d %s='%s'" % (k, v.replace("'", '"')) for k,v in init_vars.items() ] init_vars = [ " \\\n -d %s='%s'" % (k, v.replace("'", '"')) for k,v in init_vars.items() ]
init_vars = ' \\\n '.join(init_vars) init_vars = ''.join(init_vars)
context.update({ context.update({
'php_binary_path': os.path.normpath(settings.WEBAPPS_PHP_CGI_BINARY_PATH % context), '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), '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 PHPRC=%(php_rc)s
export PHP_INI_SCAN_DIR=%(php_ini_scan)s export PHP_INI_SCAN_DIR=%(php_ini_scan)s
export PHP_FCGI_MAX_REQUESTS=%(max_requests)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): def get_fcgid_cmd_options(self, webapp, context):
options = self.get_options(webapp) 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'); 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_CONTENT_DIR', 'wp-content/');
define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );

View file

@ -95,7 +95,7 @@ class Processes(AppOption):
class PHPEnableFunctions(PHPAppOption): class PHPEnableFunctions(PHPAppOption):
name = 'enable_functions' name = 'enable_functions'
verbose_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]) ','.join(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS[i:i+10])
for i in range(0, len(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS), 10) for i in range(0, len(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS), 10)
]) ])