diff --git a/TODO.md b/TODO.md
index 12e80b51..a16e0a27 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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
diff --git a/orchestra/admin/options.py b/orchestra/admin/options.py
index c6bab447..692a3da7 100644
--- a/orchestra/admin/options.py
+++ b/orchestra/admin/options.py
@@ -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)
@@ -45,6 +44,22 @@ class ChangeListDefaultFilter(object):
if hasattr(response, 'context_data') and 'cl' in response.context_data:
response.context_data['cl'].default_changelist_filters = defaults
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):
@@ -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):
diff --git a/orchestra/contrib/issues/admin.py b/orchestra/contrib/issues/admin.py
index b6d702ac..eac2b7c9 100644
--- a/orchestra/contrib/issues/admin.py
+++ b/orchestra/contrib/issues/admin.py
@@ -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'
diff --git a/orchestra/contrib/mailboxes/backends.py b/orchestra/contrib/mailboxes/backends.py
index fe3bb983..ccb77011 100644
--- a/orchestra/contrib/mailboxes/backends.py
+++ b/orchestra/contrib/mailboxes/backends.py
@@ -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 PostfixAddressVirtualDomainBackend.
"""
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
diff --git a/orchestra/contrib/orchestration/backends.py b/orchestra/contrib/orchestration/backends.py
index 02d62422..aa498d70 100644
--- a/orchestra/contrib/orchestration/backends.py
+++ b/orchestra/contrib/orchestration/backends.py
@@ -217,8 +217,8 @@ class ServiceBackend(plugins.Plugin, metaclass=ServiceMount):
def commit(self):
"""
hook for executing something at the end
- apply the configuration, usually reloading a service
- reloading a service is done in a separated method in order to reload
+ apply the configuration, usually reloading a service
+ reloading a service is done in a separated method in order to reload
the service once in bulk operations
"""
self.append('exit $exit_code')
diff --git a/orchestra/contrib/services/helpers.py b/orchestra/contrib/services/helpers.py
index 71f35298..3146dbb3 100644
--- a/orchestra/contrib/services/helpers.py
+++ b/orchestra/contrib/services/helpers.py
@@ -54,7 +54,7 @@ class Interval(object):
return remaining
def __repr__(self):
- return "Start: {ini} End: {end}".format(
+ return "".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):
diff --git a/orchestra/contrib/settings/templates/admin/settings/change_form.html b/orchestra/contrib/settings/templates/admin/settings/change_form.html
index 930ee8cc..c144c1e3 100644
--- a/orchestra/contrib/settings/templates/admin/settings/change_form.html
+++ b/orchestra/contrib/settings/templates/admin/settings/change_form.html
@@ -55,7 +55,7 @@
{% regroup form.forms by app as formlist %}
{% for app in formlist %}