Fixed delete related services from account, don't display unrelated objects that aren't services
This commit is contained in:
parent
020ba1c7c4
commit
5a8dfba893
6
TODO.md
6
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
|
||||
|
||||
|
|
|
@ -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?"),
|
||||
|
|
|
@ -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"), {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -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=[
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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',
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue