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
|
||||
|
||||
|
||||
class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||
class ListAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||
list_display = (
|
||||
'name', 'address_name', 'address_domain_link', 'account_link', 'display_active'
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
|
|||
}),
|
||||
(_("Admin"), {
|
||||
'classes': ('wide',),
|
||||
'fields': ('admin_email', 'password1', 'password2'),
|
||||
'fields': ('admin_email',),
|
||||
}),
|
||||
)
|
||||
fieldsets = (
|
||||
|
@ -45,35 +45,15 @@ class ListAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModel
|
|||
) % settings.LISTS_DEFAULT_DOMAIN,
|
||||
'fields': (('address_name', 'address_domain'),)
|
||||
}),
|
||||
(_("Admin"), {
|
||||
'classes': ('wide',),
|
||||
'fields': ('password',),
|
||||
}),
|
||||
)
|
||||
search_fields = ('name', 'address_name', 'address_domain__name', 'account__username')
|
||||
list_filter = (IsActiveListFilter, HasCustomAddressListFilter)
|
||||
readonly_fields = ('account_link',)
|
||||
change_readonly_fields = ('name',)
|
||||
form = NonStoredUserChangeForm
|
||||
add_form = UserCreationForm
|
||||
list_select_related = ('account', 'address_domain',)
|
||||
filter_by_account_fields = ['address_domain']
|
||||
actions = (disable, enable, list_accounts)
|
||||
|
||||
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)
|
||||
|
|
|
@ -182,7 +182,6 @@ class MailmanController(MailmanVirtualDomainController):
|
|||
context.update({
|
||||
'banner': self.get_banner(mail_list),
|
||||
'name': mail_list.name,
|
||||
'password': mail_list.password,
|
||||
'domain': mail_list.address_domain or settings.LISTS_DEFAULT_DOMAIN,
|
||||
'address_name': mail_list.get_address_name(),
|
||||
'address_domain': mail_list.address_domain,
|
||||
|
|
34
orchestra/contrib/lists/migrations/0001_initial.py
Normal file
34
orchestra/contrib/lists/migrations/0001_initial.py
Normal file
|
@ -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')},
|
||||
},
|
||||
),
|
||||
]
|
0
orchestra/contrib/lists/migrations/__init__.py
Normal file
0
orchestra/contrib/lists/migrations/__init__.py
Normal file
|
@ -8,17 +8,6 @@ from orchestra.core.validators import validate_name
|
|||
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?
|
||||
class List(models.Model):
|
||||
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,
|
||||
help_text=_("Designates whether this account should be treated as active. "
|
||||
"Unselect this instead of deleting accounts."))
|
||||
password = None
|
||||
|
||||
objects = ListQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
unique_together = ('address_name', 'address_domain')
|
||||
|
@ -75,9 +61,6 @@ class List(models.Model):
|
|||
def get_username(self):
|
||||
return self.name
|
||||
|
||||
def set_password(self, password):
|
||||
self.password = password
|
||||
|
||||
def get_absolute_url(self):
|
||||
context = {
|
||||
'name': self.name
|
||||
|
|
|
@ -9,13 +9,14 @@ LISTS_DOMAIN_MODEL = Setting('LISTS_DOMAIN_MODEL',
|
|||
|
||||
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
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."
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue