diff --git a/TODO.md b/TODO.md index ed996aea..f02e8e1a 100644 --- a/TODO.md +++ b/TODO.md @@ -467,3 +467,9 @@ with open(file) as handler: # SAVE INISTIAL PASSWORD from all services, and just use it to create the service, never update it + + +# Eliminar tots els serveis de l'account no elimina les factures, pero crec que queda pendent arreglar el missatge summary, perque allĂ  diu que s'eliminaran N factures, xo no surten llistades a la llista d'objectes oi? + +# Make owncloud quota backend more resilient to HTTP/connection errors + diff --git a/orchestra/contrib/accounts/actions.py b/orchestra/contrib/accounts/actions.py index f45a5484..f7f7ba91 100644 --- a/orchestra/contrib/accounts/actions.py +++ b/orchestra/contrib/accounts/actions.py @@ -171,7 +171,20 @@ def delete_related_services(modeladmin, request, queryset): else: objects_name = force_text(opts.verbose_name_plural) - model_count = {model._meta.verbose_name_plural: len(objs) for model, objs in collector.model_objs.items()} + model_count = {} + for model, objs in collector.model_objs.items(): + count = 0 + # discount main systemuser + if model is modeladmin.model.main_systemuser.field.rel.to: + count = len(objs) - 1 + # Discount account + elif model is not modeladmin.model and model in registered_services: + count = len(objs) + if count: + model_count[model._meta.verbose_name_plural] = count + if not model_count: + modeladmin.message_user(request, _("Nothing to delete"), messages.WARNING) + return None context = dict( admin_site.each_context(request), title=_("Are you sure?"), diff --git a/orchestra/contrib/accounts/admin.py b/orchestra/contrib/accounts/admin.py index 3214ccd4..ed40d19b 100644 --- a/orchestra/contrib/accounts/admin.py +++ b/orchestra/contrib/accounts/admin.py @@ -24,7 +24,6 @@ from orchestra.utils.apps import isinstalled from .actions import (list_contacts, service_report, delete_related_services, disable_selected, enable_selected) -from .filters import HasMainUserListFilter from .forms import AccountCreationForm from .models import Account @@ -32,7 +31,7 @@ from .models import Account class AccountAdmin(ChangePasswordAdminMixin, auth.UserAdmin, ExtendedModelAdmin): list_display = ('username', 'full_name', 'type', 'is_active') list_filter = ( - 'type', 'is_active', HasMainUserListFilter + 'type', 'is_active', ) add_fieldsets = ( (_("User"), { diff --git a/orchestra/contrib/accounts/filters.py b/orchestra/contrib/accounts/filters.py index e1ccfa85..d45ff8ff 100644 --- a/orchestra/contrib/accounts/filters.py +++ b/orchestra/contrib/accounts/filters.py @@ -3,24 +3,6 @@ from django.db.models import Q from django.utils.translation import ugettext_lazy as _ -class HasMainUserListFilter(SimpleListFilter): - """ Filter Nodes by group according to request.user """ - title = _("has main user") - parameter_name = 'mainuser' - - def lookups(self, request, model_admin): - return ( - ('True', _("Yes")), - ('False', _("No")), - ) - - def queryset(self, request, queryset): - if self.value() == 'True': - return queryset.filter(users__isnull=False).distinct() - if self.value() == 'False': - return queryset.filter(users__isnull=True).distinct() - - class IsActiveListFilter(SimpleListFilter): title = _("is active") parameter_name = 'active' diff --git a/orchestra/contrib/lists/migrations/0002_auto_20160912_1221.py b/orchestra/contrib/lists/migrations/0002_auto_20160912_1221.py new file mode 100644 index 00000000..60ec2bf9 --- /dev/null +++ b/orchestra/contrib/lists/migrations/0002_auto_20160912_1221.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-09-12 10:21 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import orchestra.core.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('lists', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='list', + name='address_domain', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='domains.Domain', verbose_name='address domain'), + ), + migrations.AlterField( + model_name='list', + name='address_name', + field=models.CharField(blank=True, max_length=52, validators=[orchestra.core.validators.validate_name], verbose_name='address name'), + ), + migrations.AlterField( + model_name='list', + name='name', + field=models.CharField(help_text='Default list address <name>@grups.pangea.org', max_length=52, unique=True, validators=[orchestra.core.validators.validate_name], verbose_name='name'), + ), + ] diff --git a/orchestra/contrib/lists/migrations/0003_auto_20160912_1241.py b/orchestra/contrib/lists/migrations/0003_auto_20160912_1241.py new file mode 100644 index 00000000..618e8b41 --- /dev/null +++ b/orchestra/contrib/lists/migrations/0003_auto_20160912_1241.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-09-12 10:41 +from __future__ import unicode_literals + +from django.db import migrations, models +import orchestra.core.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('lists', '0002_auto_20160912_1221'), + ] + + operations = [ + migrations.AlterField( + model_name='list', + name='address_name', + field=models.CharField(blank=True, max_length=64, validators=[orchestra.core.validators.validate_name], verbose_name='address name'), + ), + migrations.AlterField( + model_name='list', + name='name', + field=models.CharField(help_text='Default list address <name>@grups.pangea.org', max_length=64, unique=True, validators=[orchestra.core.validators.validate_name], verbose_name='name'), + ), + ] diff --git a/orchestra/contrib/lists/models.py b/orchestra/contrib/lists/models.py index bf20d4d4..8dc50912 100644 --- a/orchestra/contrib/lists/models.py +++ b/orchestra/contrib/lists/models.py @@ -20,11 +20,10 @@ class ListQuerySet(models.QuerySet): # TODO address and domain, perhaps allow only domain? - class List(models.Model): - name = models.CharField(_("name"), max_length=128, unique=True, validators=[validate_name], + name = models.CharField(_("name"), max_length=64, unique=True, validators=[validate_name], help_text=_("Default list address <name>@%s") % settings.LISTS_DEFAULT_DOMAIN) - address_name = models.CharField(_("address name"), max_length=128, + address_name = models.CharField(_("address name"), max_length=64, validators=[validate_name], blank=True) address_domain = models.ForeignKey(settings.LISTS_DOMAIN_MODEL, on_delete=models.SET_NULL, verbose_name=_("address domain"), blank=True, null=True) diff --git a/orchestra/contrib/mailboxes/models.py b/orchestra/contrib/mailboxes/models.py index 0c609107..265519c6 100644 --- a/orchestra/contrib/mailboxes/models.py +++ b/orchestra/contrib/mailboxes/models.py @@ -14,7 +14,8 @@ from . import validators, settings class Mailbox(models.Model): CUSTOM = 'CUSTOM' - name = models.CharField(_("name"), max_length=64, unique=True, db_index=True, + name = models.CharField(_("name"), unique=True, db_index=True, + max_length=settings.MAILBOXES_NAME_MAX_LENGTH, help_text=_("Required. %s characters or fewer. Letters, digits and ./-/_ only.") % settings.MAILBOXES_NAME_MAX_LENGTH, validators=[ diff --git a/orchestra/contrib/saas/services/phplist.py b/orchestra/contrib/saas/services/phplist.py index c7aa0524..7b265b18 100644 --- a/orchestra/contrib/saas/services/phplist.py +++ b/orchestra/contrib/saas/services/phplist.py @@ -1,4 +1,5 @@ from django import forms +from django.core import validators from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse from django.db.models import Q @@ -35,6 +36,8 @@ class PHPListForm(SaaSPasswordForm): domain = self.plugin.site_domain % context help_text = _("Admin URL http://{}/admin/").format(domain) self.fields['site_url'].help_text = help_text + validator = validators.MaxLengthValidator(settings.SAAS_PHPLIST_NAME_MAX_LENGTH) + self.fields['name'].validators.append(validator) class PHPListChangeForm(PHPListForm): diff --git a/orchestra/contrib/saas/settings.py b/orchestra/contrib/saas/settings.py index e842ad59..9535ace9 100644 --- a/orchestra/contrib/saas/settings.py +++ b/orchestra/contrib/saas/settings.py @@ -162,6 +162,11 @@ SAAS_PHPLIST_BOUNCES_MAILBOX_NAME = Setting('SAAS_PHPLIST_BOUNCES_MAILBOX_NAME', '%(site_name)s-list-bounces', ) +SAAS_PHPLIST_NAME_MAX_LENGTH = Setting('SAAS_PHPLIST_NAME_MAX_LENGTH', + 32-13, + help_text=_("Because of max system group name of the bounces mailbox is 32."), +) + SAAS_PHPLIST_BOUNCES_MAILBOX_PASSWORD = Setting('SAAS_PHPLIST_BOUNCES_MAILBOX_PASSWORD', 'secret', ) diff --git a/requirements.txt b/requirements.txt index b997d4dc..e53bb8f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Django==1.9.5 django-fluent-dashboard==0.6.1 django-admin-tools==0.7.2 -django-extensions==1.6.1 +django-extensions==1.7.4 django-celery==3.1.17 celery==3.1.23 kombu==3.0.35