delete fields password in lists
This commit is contained in:
parent
631c27cd14
commit
638c1ceb44
|
@ -16,7 +16,7 @@ from .filters import HasCustomAddressListFilter
|
||||||
from .models import List
|
from .models import List
|
||||||
|
|
||||||
|
|
||||||
class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModelAdmin):
|
class ListAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'name', 'address_name', 'address_domain_link', 'account_link', 'display_active'
|
'name', 'address_name', 'address_domain_link', 'account_link', 'display_active'
|
||||||
)
|
)
|
||||||
|
@ -31,7 +31,7 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
|
||||||
}),
|
}),
|
||||||
(_("Admin"), {
|
(_("Admin"), {
|
||||||
'classes': ('wide',),
|
'classes': ('wide',),
|
||||||
'fields': ('admin_email', 'password1', 'password2'),
|
'fields': ('admin_email',),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
|
@ -45,35 +45,15 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
|
||||||
) % settings.LISTS_DEFAULT_DOMAIN,
|
) % settings.LISTS_DEFAULT_DOMAIN,
|
||||||
'fields': (('address_name', 'address_domain'),)
|
'fields': (('address_name', 'address_domain'),)
|
||||||
}),
|
}),
|
||||||
(_("Admin"), {
|
|
||||||
'classes': ('wide',),
|
|
||||||
'fields': ('password',),
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
search_fields = ('name', 'address_name', 'address_domain__name', 'account__username')
|
search_fields = ('name', 'address_name', 'address_domain__name', 'account__username')
|
||||||
list_filter = (IsActiveListFilter, HasCustomAddressListFilter)
|
list_filter = (IsActiveListFilter, HasCustomAddressListFilter)
|
||||||
readonly_fields = ('account_link',)
|
readonly_fields = ('account_link',)
|
||||||
change_readonly_fields = ('name',)
|
change_readonly_fields = ('name',)
|
||||||
form = NonStoredUserChangeForm
|
|
||||||
add_form = UserCreationForm
|
|
||||||
list_select_related = ('account', 'address_domain',)
|
list_select_related = ('account', 'address_domain',)
|
||||||
filter_by_account_fields = ['address_domain']
|
filter_by_account_fields = ['address_domain']
|
||||||
actions = (disable, enable, list_accounts)
|
actions = (disable, enable, list_accounts)
|
||||||
|
|
||||||
address_domain_link = admin_link('address_domain', order='address_domain__name')
|
address_domain_link = admin_link('address_domain', order='address_domain__name')
|
||||||
|
|
||||||
def get_urls(self):
|
|
||||||
useradmin = UserAdmin(List, self.admin_site)
|
|
||||||
return [
|
|
||||||
url(r'^(\d+)/password/$',
|
|
||||||
self.admin_site.admin_view(useradmin.user_change_password))
|
|
||||||
] + super(ListAdmin, self).get_urls()
|
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
|
||||||
""" set password """
|
|
||||||
if not change:
|
|
||||||
obj.set_password(form.cleaned_data["password1"])
|
|
||||||
super(ListAdmin, self).save_model(request, obj, form, change)
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(List, ListAdmin)
|
admin.site.register(List, ListAdmin)
|
||||||
|
|
|
@ -182,7 +182,6 @@ class MailmanController(MailmanVirtualDomainController):
|
||||||
context.update({
|
context.update({
|
||||||
'banner': self.get_banner(mail_list),
|
'banner': self.get_banner(mail_list),
|
||||||
'name': mail_list.name,
|
'name': mail_list.name,
|
||||||
'password': mail_list.password,
|
|
||||||
'domain': mail_list.address_domain or settings.LISTS_DEFAULT_DOMAIN,
|
'domain': mail_list.address_domain or settings.LISTS_DEFAULT_DOMAIN,
|
||||||
'address_name': mail_list.get_address_name(),
|
'address_name': mail_list.get_address_name(),
|
||||||
'address_domain': mail_list.address_domain,
|
'address_domain': mail_list.address_domain,
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 2.2.28 on 2023-09-01 14:59
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import orchestra.core.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('domains', '__first__'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='List',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', 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')),
|
||||||
|
('address_name', models.CharField(blank=True, max_length=64, validators=[orchestra.core.validators.validate_name], verbose_name='address name')),
|
||||||
|
('admin_email', models.EmailField(help_text='Administration email address', max_length=254, verbose_name='admin email')),
|
||||||
|
('is_active', models.BooleanField(default=True, help_text='Designates whether this account should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||||
|
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lists', to=settings.AUTH_USER_MODEL, verbose_name='Account')),
|
||||||
|
('address_domain', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='domains.Domain', verbose_name='address domain')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('address_name', 'address_domain')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -8,17 +8,6 @@ from orchestra.core.validators import validate_name
|
||||||
from . import settings
|
from . import settings
|
||||||
|
|
||||||
|
|
||||||
class ListQuerySet(models.QuerySet):
|
|
||||||
def create(self, **kwargs):
|
|
||||||
""" Sets password if provided, all within a single DB operation """
|
|
||||||
password = kwargs.pop('password')
|
|
||||||
instance = self.model(**kwargs)
|
|
||||||
if password:
|
|
||||||
instance.set_password(password)
|
|
||||||
instance.save()
|
|
||||||
return instance
|
|
||||||
|
|
||||||
|
|
||||||
# TODO address and domain, perhaps allow only domain?
|
# TODO address and domain, perhaps allow only domain?
|
||||||
class List(models.Model):
|
class List(models.Model):
|
||||||
name = models.CharField(_("name"), max_length=64, unique=True, validators=[validate_name],
|
name = models.CharField(_("name"), max_length=64, unique=True, validators=[validate_name],
|
||||||
|
@ -35,9 +24,6 @@ class List(models.Model):
|
||||||
is_active = models.BooleanField(_("active"), default=True,
|
is_active = models.BooleanField(_("active"), default=True,
|
||||||
help_text=_("Designates whether this account should be treated as active. "
|
help_text=_("Designates whether this account should be treated as active. "
|
||||||
"Unselect this instead of deleting accounts."))
|
"Unselect this instead of deleting accounts."))
|
||||||
password = None
|
|
||||||
|
|
||||||
objects = ListQuerySet.as_manager()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('address_name', 'address_domain')
|
unique_together = ('address_name', 'address_domain')
|
||||||
|
@ -75,9 +61,6 @@ class List(models.Model):
|
||||||
def get_username(self):
|
def get_username(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def set_password(self, password):
|
|
||||||
self.password = password
|
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
context = {
|
context = {
|
||||||
'name': self.name
|
'name': self.name
|
||||||
|
|
|
@ -9,13 +9,14 @@ LISTS_DOMAIN_MODEL = Setting('LISTS_DOMAIN_MODEL',
|
||||||
|
|
||||||
|
|
||||||
LISTS_DEFAULT_DOMAIN = Setting('LISTS_DEFAULT_DOMAIN',
|
LISTS_DEFAULT_DOMAIN = Setting('LISTS_DEFAULT_DOMAIN',
|
||||||
'lists.{}'.format(ORCHESTRA_BASE_DOMAIN),
|
'grups.{}'.format(ORCHESTRA_BASE_DOMAIN),
|
||||||
help_text="Uses <tt>ORCHESTRA_BASE_DOMAIN</tt> by default."
|
help_text="Uses <tt>ORCHESTRA_BASE_DOMAIN</tt> by default."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
LISTS_LIST_URL = Setting('LISTS_LIST_URL',
|
LISTS_LIST_URL = Setting('LISTS_LIST_URL',
|
||||||
'https://lists.{}/mailman/listinfo/%(name)s'.format(ORCHESTRA_BASE_DOMAIN),
|
# 'https://lists.{}/mailman/listinfo/%(name)s'.format(ORCHESTRA_BASE_DOMAIN),
|
||||||
|
'https://www.{0}/mailman3/lists/%(name)s.{0}'.format(LISTS_DEFAULT_DOMAIN),
|
||||||
help_text="Uses <tt>ORCHESTRA_BASE_DOMAIN</tt> by default."
|
help_text="Uses <tt>ORCHESTRA_BASE_DOMAIN</tt> by default."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue