mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Renomme le modèle des addresses mails
This commit is contained in:
parent
43fb83ec12
commit
bc0abb2c0a
15 changed files with 108 additions and 109 deletions
|
@ -596,12 +596,12 @@ class WhitelistSerializer(NamespacedHMSerializer):
|
||||||
fields = ('user', 'raison', 'date_start', 'date_end', 'active', 'api_url')
|
fields = ('user', 'raison', 'date_start', 'date_end', 'active', 'api_url')
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailAccountSerializer(NamespacedHMSerializer):
|
class EMailAddressSerializer(NamespacedHMSerializer):
|
||||||
"""Serialize `users.models.LocalEmailAccount` objects.
|
"""Serialize `users.models.EMailAddress` objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = users.LocalEmailAccount
|
model = users.EMailAddress
|
||||||
fields = ('user', 'local_part', 'complete_email_address', 'api_url')
|
fields = ('user', 'local_part', 'complete_email_address', 'api_url')
|
||||||
|
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ class ServiceRegenSerializer(NamespacedHMSerializer):
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailUsersSerializer(NamespacedHMSerializer):
|
class LocalEmailUsersSerializer(NamespacedHMSerializer):
|
||||||
local_email_accounts = LocalEmailAccountSerializer(
|
email_address = EMailAddressSerializer(
|
||||||
read_only=True,
|
read_only=True,
|
||||||
many=True
|
many=True
|
||||||
)
|
)
|
||||||
|
@ -635,7 +635,7 @@ class LocalEmailUsersSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = users.User
|
model = users.User
|
||||||
fields = ('local_email_enabled', 'local_email_redirect',
|
fields = ('local_email_enabled', 'local_email_redirect',
|
||||||
'local_email_accounts')
|
'email_address')
|
||||||
|
|
||||||
|
|
||||||
# DHCP
|
# DHCP
|
||||||
|
|
|
@ -93,7 +93,7 @@ router.register_viewset(r'users/listright', views.ListRightViewSet)
|
||||||
router.register_viewset(r'users/shell', views.ShellViewSet, base_name='shell')
|
router.register_viewset(r'users/shell', views.ShellViewSet, base_name='shell')
|
||||||
router.register_viewset(r'users/ban', views.BanViewSet)
|
router.register_viewset(r'users/ban', views.BanViewSet)
|
||||||
router.register_viewset(r'users/whitelist', views.WhitelistViewSet)
|
router.register_viewset(r'users/whitelist', views.WhitelistViewSet)
|
||||||
router.register_viewset(r'users/localemailaccount', views.LocalEmailAccountViewSet)
|
router.register_viewset(r'users/emailaddress', views.EMailAddressViewSet)
|
||||||
# SERVICE REGEN
|
# SERVICE REGEN
|
||||||
router.register_viewset(r'services/regen', views.ServiceRegenViewSet, base_name='serviceregen')
|
router.register_viewset(r'services/regen', views.ServiceRegenViewSet, base_name='serviceregen')
|
||||||
# DHCP
|
# DHCP
|
||||||
|
|
12
api/views.py
12
api/views.py
|
@ -469,19 +469,19 @@ class WhitelistViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
serializer_class = serializers.WhitelistSerializer
|
serializer_class = serializers.WhitelistSerializer
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailAccountViewSet(viewsets.ReadOnlyModelViewSet):
|
class EMailAddressViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
"""Exposes list and details of `users.models.LocalEmailAccount` objects.
|
"""Exposes list and details of `users.models.EMailAddress` objects.
|
||||||
"""
|
"""
|
||||||
serializer_class = serializers.LocalEmailAccountSerializer
|
serializer_class = serializers.EMailAddressSerializer
|
||||||
queryset = users.LocalEmailAccount.objects.none()
|
queryset = users.EMailAddress.objects.none()
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if preferences.OptionalUser.get_cached_value(
|
if preferences.OptionalUser.get_cached_value(
|
||||||
'local_email_accounts_enabled'):
|
'local_email_accounts_enabled'):
|
||||||
return (users.LocalEmailAccount.objects
|
return (users.EMailAddress.objects
|
||||||
.filter(user__local_email_enabled=True))
|
.filter(user__local_email_enabled=True))
|
||||||
else:
|
else:
|
||||||
return users.LocalEmailAccount.objects.none()
|
return users.EMailAddress.objects.none()
|
||||||
|
|
||||||
|
|
||||||
# SERVICE REGEN
|
# SERVICE REGEN
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='optionaluser',
|
model_name='optionaluser',
|
||||||
name='max_local_email_accounts',
|
name='max_email_address',
|
||||||
field=models.IntegerField(default=15, help_text='Maximum number of local email accounts for a standard user'),
|
field=models.IntegerField(default=15, help_text='Maximum number of local email address for a standard user'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -93,9 +93,9 @@ class OptionalUser(AclMixin, PreferencesModel):
|
||||||
default = "@example.org",
|
default = "@example.org",
|
||||||
help_text="Domain to use for local email accounts",
|
help_text="Domain to use for local email accounts",
|
||||||
)
|
)
|
||||||
max_local_email_accounts = models.IntegerField(
|
max_email_address = models.IntegerField(
|
||||||
default = 15,
|
default = 15,
|
||||||
help_text = "Maximum number of local email accounts for a standard user"
|
help_text = "Maximum number of local email address for a standard user"
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -66,8 +66,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<td>{{ useroptions.local_email_domain }}</td>
|
<td>{{ useroptions.local_email_domain }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Nombre de comptes maximum</th>
|
<th>Nombre d'alias mail max</th>
|
||||||
<td>{{ useroptions.max_local_email_accounts }}</td>
|
<td>{{ useroptions.max_email_address }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
User,
|
User,
|
||||||
LocalEmailAccount,
|
EMailAddress,
|
||||||
ServiceUser,
|
ServiceUser,
|
||||||
School,
|
School,
|
||||||
ListRight,
|
ListRight,
|
||||||
|
@ -109,7 +109,7 @@ class BanAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailAccountAdmin(VersionAdmin):
|
class EMailAddressAdmin(VersionAdmin):
|
||||||
"""Gestion des alias mail"""
|
"""Gestion des alias mail"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ admin.site.register(School, SchoolAdmin)
|
||||||
admin.site.register(ListRight, ListRightAdmin)
|
admin.site.register(ListRight, ListRightAdmin)
|
||||||
admin.site.register(ListShell, ListShellAdmin)
|
admin.site.register(ListShell, ListShellAdmin)
|
||||||
admin.site.register(Ban, BanAdmin)
|
admin.site.register(Ban, BanAdmin)
|
||||||
admin.site.register(LocalEmailAccount, LocalEmailAccountAdmin)
|
admin.site.register(EMailAddress, EMailAddressAdmin)
|
||||||
admin.site.register(Whitelist, WhitelistAdmin)
|
admin.site.register(Whitelist, WhitelistAdmin)
|
||||||
admin.site.register(Request, RequestAdmin)
|
admin.site.register(Request, RequestAdmin)
|
||||||
# Now register the new UserAdmin...
|
# Now register the new UserAdmin...
|
||||||
|
|
|
@ -53,7 +53,7 @@ from .models import (
|
||||||
School,
|
School,
|
||||||
ListRight,
|
ListRight,
|
||||||
Whitelist,
|
Whitelist,
|
||||||
LocalEmailAccount,
|
EMailAddress,
|
||||||
ListShell,
|
ListShell,
|
||||||
Ban,
|
Ban,
|
||||||
Adherent,
|
Adherent,
|
||||||
|
@ -591,16 +591,16 @@ class WhitelistForm(FormRevMixin, ModelForm):
|
||||||
widgets = {'date_end':DateTimePicker}
|
widgets = {'date_end':DateTimePicker}
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailAccountForm(FormRevMixin, ModelForm):
|
class EMailAddressForm(FormRevMixin, ModelForm):
|
||||||
"""Create and edit a local email account"""
|
"""Create and edit a local email address"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(LocalEmailAccountForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(EMailAddressForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['local_part'].label = "Local part of the email"
|
self.fields['local_part'].label = "Local part of the email"
|
||||||
self.fields['local_part'].help_text = "Can't contain @"
|
self.fields['local_part'].help_text = "Can't contain @"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = LocalEmailAccount
|
model = EMailAddress
|
||||||
exclude = ['user']
|
exclude = ['user']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,21 +10,21 @@ import re2o.mixins
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
def create_initial_local_email_account(apps, schema_editor):
|
def create_initial_email_address(apps, schema_editor):
|
||||||
db_alias = schema_editor.connection.alias
|
db_alias = schema_editor.connection.alias
|
||||||
User = apps.get_model("users", "User")
|
User = apps.get_model("users", "User")
|
||||||
LocalEmailAccount = apps.get_model("users", "LocalEmailAccount")
|
EMailAddress = apps.get_model("users", "EMailAddress")
|
||||||
users = User.objects.using(db_alias).all()
|
users = User.objects.using(db_alias).all()
|
||||||
for user in users:
|
for user in users:
|
||||||
LocalEmailAccount.objects.using(db_alias).create(
|
EMailAddress.objects.using(db_alias).create(
|
||||||
local_part=user.pseudo,
|
local_part=user.pseudo,
|
||||||
user=user
|
user=user
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete_all_local_email_accounts(apps, schema_editor):
|
def delete_all_email_address(apps, schema_editor):
|
||||||
db_alias = schema_editor.connection.alias
|
db_alias = schema_editor.connection.alias
|
||||||
LocalEmailAccount = apps.get_model("users", "LocalEmailAccount")
|
EMailAddress = apps.get_model("users", "EMailAddress")
|
||||||
LocalEmailAccount.objects.using(db_alias).delete()
|
EMailAddress.objects.using(db_alias).delete()
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('users', '0072_auto_20180426_2021'),
|
('users', '0072_auto_20180426_2021'),
|
||||||
|
@ -32,14 +32,14 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='LocalEmailAccount',
|
name='EMailAddress',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('local_part', models.CharField(help_text="Local part of the email address", max_length=128, unique=True)),
|
('local_part', models.CharField(help_text="Local part of the email address", max_length=128, unique=True)),
|
||||||
('user', models.ForeignKey(help_text='User of the local email', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
('user', models.ForeignKey(help_text='User of the local email', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model),
|
bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model),
|
||||||
options={'permissions': (('view_localemailaccount', 'Can see a local email account object'),), 'verbose_name': 'Local email account', 'verbose_name_plural': 'Local email accounts'},
|
options={'permissions': (('view_emailaddress', 'Can see a local email account object'),), 'verbose_name': 'Local email account', 'verbose_name_plural': 'Local email accounts'},
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='user',
|
model_name='user',
|
||||||
|
@ -51,8 +51,7 @@ class Migration(migrations.Migration):
|
||||||
name='local_email_redirect',
|
name='local_email_redirect',
|
||||||
field=models.BooleanField(default=False, help_text='Whether or not to redirect the local email messages to the main email.'),
|
field=models.BooleanField(default=False, help_text='Whether or not to redirect the local email messages to the main email.'),
|
||||||
),
|
),
|
||||||
migrations.RunPython(create_initial_local_email_account,
|
migrations.RunPython(create_initial_email_address,
|
||||||
delete_all_local_email_accounts),
|
delete_all_email_address),
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -683,11 +683,11 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
return
|
return
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def local_email_accounts(self):
|
def email_address(self):
|
||||||
if (OptionalUser.get_cached_value('local_email_accounts_enabled')
|
if (OptionalUser.get_cached_value('local_email_accounts_enabled')
|
||||||
and self.local_email_enabled):
|
and self.local_email_enabled):
|
||||||
return self.localemailaccount_set.all()
|
return self.emailaddress_set.all()
|
||||||
return LocalEmailAccount.objects.none()
|
return EMailAddress.objects.none()
|
||||||
|
|
||||||
def get_next_domain_name(self):
|
def get_next_domain_name(self):
|
||||||
"""Look for an available name for a new interface for
|
"""Look for an available name for a new interface for
|
||||||
|
@ -935,7 +935,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
"""Check if this pseudo is already used by any mailalias.
|
"""Check if this pseudo is already used by any mailalias.
|
||||||
Better than raising an error in post-save and catching it"""
|
Better than raising an error in post-save and catching it"""
|
||||||
if (LocalEmailAccount.objects
|
if (EMailAddress.objects
|
||||||
.filter(local_part=self.pseudo)
|
.filter(local_part=self.pseudo)
|
||||||
.exclude(user=self)):
|
.exclude(user=self)):
|
||||||
raise ValidationError("This pseudo is already in use.")
|
raise ValidationError("This pseudo is already in use.")
|
||||||
|
@ -1066,7 +1066,7 @@ def user_post_save(**kwargs):
|
||||||
Synchronise le ldap"""
|
Synchronise le ldap"""
|
||||||
is_created = kwargs['created']
|
is_created = kwargs['created']
|
||||||
user = kwargs['instance']
|
user = kwargs['instance']
|
||||||
LocalEmailAccount.objects.get_or_create(local_part=user.pseudo, user=user)
|
EMailAddress.objects.get_or_create(local_part=user.pseudo, user=user)
|
||||||
if is_created:
|
if is_created:
|
||||||
user.notif_inscription()
|
user.notif_inscription()
|
||||||
user.state_sync()
|
user.state_sync()
|
||||||
|
@ -1648,7 +1648,7 @@ class LdapServiceUserGroup(ldapdb.models.Model):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
class EMailAddress(RevMixin, AclMixin, models.Model):
|
||||||
"""Defines a local email account for a user
|
"""Defines a local email account for a user
|
||||||
"""
|
"""
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
|
@ -1664,7 +1664,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = (
|
permissions = (
|
||||||
("view_localemailaccount", "Can see a local email account object"),
|
("view_emailaddress", "Can see a local email account object"),
|
||||||
)
|
)
|
||||||
verbose_name = "Local email account"
|
verbose_name = "Local email account"
|
||||||
verbose_name_plural = "Local email accounts"
|
verbose_name_plural = "Local email accounts"
|
||||||
|
@ -1678,7 +1678,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_create(user_request, userid, *_args, **_kwargs):
|
def can_create(user_request, userid, *_args, **_kwargs):
|
||||||
"""Check if a user can create a `LocalEmailAccount` object.
|
"""Check if a user can create a `EMailAddress` object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_request: The user who wants to create the object.
|
user_request: The user who wants to create the object.
|
||||||
|
@ -1688,15 +1688,15 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
a message and a boolean which is True if the user can create
|
a message and a boolean which is True if the user can create
|
||||||
a local email account.
|
a local email account.
|
||||||
"""
|
"""
|
||||||
if user_request.has_perm('users.add_localemailaccount'):
|
if user_request.has_perm('users.add_emailaddress'):
|
||||||
return True, None
|
return True, None
|
||||||
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
||||||
return False, "The local email accounts are not enabled."
|
return False, "The local email accounts are not enabled."
|
||||||
if int(user_request.id) != int(userid):
|
if int(user_request.id) != int(userid):
|
||||||
return False, "You don't have the right to add a local email account to another user."
|
return False, "You don't have the right to add a local email account to another user."
|
||||||
elif user_request.local_email_accounts.count() >= OptionalUser.get_cached_value('max_local_email_accounts'):
|
elif user_request.email_address.count() >= OptionalUser.get_cached_value('max_email_address'):
|
||||||
return False, "You have reached the limit of {} local email account.".format(
|
return False, "You have reached the limit of {} local email account.".format(
|
||||||
OptionalUser.get_cached_value('max_local_email_accounts')
|
OptionalUser.get_cached_value('max_email_address')
|
||||||
)
|
)
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
|
@ -1710,7 +1710,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
a message and a boolean which is True if the user can see
|
a message and a boolean which is True if the user can see
|
||||||
the local email account.
|
the local email account.
|
||||||
"""
|
"""
|
||||||
if user_request.has_perm('users.view_localemailaccount'):
|
if user_request.has_perm('users.view_emailaddress'):
|
||||||
return True, None
|
return True, None
|
||||||
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
||||||
return False, "The local email accounts are not enabled."
|
return False, "The local email accounts are not enabled."
|
||||||
|
@ -1731,7 +1731,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
if self.local_part == self.user.pseudo:
|
if self.local_part == self.user.pseudo:
|
||||||
return False, ("You cannot delete a local email account whose "
|
return False, ("You cannot delete a local email account whose "
|
||||||
"local part is the same as the username.")
|
"local part is the same as the username.")
|
||||||
if user_request.has_perm('users.delete_localemailaccount'):
|
if user_request.has_perm('users.delete_emailaddress'):
|
||||||
return True, None
|
return True, None
|
||||||
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
||||||
return False, "The local email accounts are not enabled."
|
return False, "The local email accounts are not enabled."
|
||||||
|
@ -1753,7 +1753,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
if self.local_part == self.user.pseudo:
|
if self.local_part == self.user.pseudo:
|
||||||
return False, ("You cannot edit a local email account whose "
|
return False, ("You cannot edit a local email account whose "
|
||||||
"local part is the same as the username.")
|
"local part is the same as the username.")
|
||||||
if user_request.has_perm('users.change_localemailaccount'):
|
if user_request.has_perm('users.change_emailaddress'):
|
||||||
return True, None
|
return True, None
|
||||||
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
|
||||||
return False, "The local email accounts are not enabled."
|
return False, "The local email accounts are not enabled."
|
||||||
|
@ -1765,5 +1765,5 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
if "@" in self.local_part:
|
if "@" in self.local_part:
|
||||||
raise ValidationError("The local part cannot contain a @")
|
raise ValidationError("The local part cannot contain a @")
|
||||||
super(LocalEmailAccount, self).clean(*args, **kwargs)
|
super(EMailAddress, self).clean(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -25,32 +25,32 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% load acl %}
|
{% load acl %}
|
||||||
{% load logs_extra %}
|
{% load logs_extra %}
|
||||||
|
|
||||||
{% if localemailaccount_list.paginator %}
|
{% if emailaddress_list.paginator %}
|
||||||
{% include "pagination.html" with list=alias_list %}
|
{% include "pagination.html" with list=emailaddress_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Local email address</th>
|
<th>Email address</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for localemailaccount in localemailaccount_list %}
|
{% for emailaddress in emailaddress_list %}
|
||||||
<td>{{ localemailaccount.complete_email_address }}</td>
|
<td>{{ emailaddress.complete_email_address }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{% can_delete localemailaccount %}
|
{% can_delete emailaddress %}
|
||||||
{% include 'buttons/suppr.html' with href='users:del-localemailaccount' id=localemailaccount.id %}
|
{% include 'buttons/suppr.html' with href='users:del-emailaddress' id=emailaddress.id %}
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% can_edit localemailaccount %}
|
{% can_edit emailaddress %}
|
||||||
{% include 'buttons/edit.html' with href='users:edit-localemailaccount' id=localemailaccount.id %}
|
{% include 'buttons/edit.html' with href='users:edit-emailaddress' id=emailaddress.id %}
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% history_button localemailaccount %}
|
{% history_button emailaddress %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% if localemailaccount_list.paginator %}
|
{% if emailaddress_list.paginator %}
|
||||||
{% include "pagination.html" with list=alias_list %}
|
{% include "pagination.html" with list=emailaddress_list %}
|
||||||
{% endif %}
|
{% endif %}
|
|
@ -29,6 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Local email accounts</h2>
|
<h2>Local email accounts</h2>
|
||||||
{% include "users/aff_localemailaccounts.html" with localemailaccount_list=localemailaccount_list %}
|
{% include "users/aff_emailaddress.html" with emailaddress_list=emailaddress_list %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -433,18 +433,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<th>Enable the local email account</th>
|
<th>Enable the local email account</th>
|
||||||
<td>{{ users.local_email_enabled | tick }}</td>
|
<td>{{ users.local_email_enabled | tick }}</td>
|
||||||
<th>Enable the local email redirection</th>
|
<th>Enable the local email redirection</th>
|
||||||
<td>{{ users.local_email_redirect | tick }}</td>
|
<td>{{ users.local_email_redirect | tick }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% if users.local_email_enabled %}
|
{% if users.local_email_enabled %}
|
||||||
{% can_create LocalEmailAccount users.id %}
|
{% can_create EMailAddress users.id %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-localemailaccount' users.id %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-emailaddress' users.id %}">
|
||||||
<i class="fa fa-plus-square"></i> Add a local email account
|
<i class="fa fa-plus-square"></i> Add an email address
|
||||||
</a>
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% if localemailaccount_list %}
|
{% if emailaddress_list %}
|
||||||
{% include "users/aff_localemailaccounts.html" with localemailaccount_list=localemailaccount_list %}
|
{% include "users/aff_emailaddress.html" with emailaddress_list=emailaddress_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -64,15 +64,15 @@ urlpatterns = [
|
||||||
url(r'^del_whitelist/(?P<whitelistid>[0-9]+)$',
|
url(r'^del_whitelist/(?P<whitelistid>[0-9]+)$',
|
||||||
views.del_whitelist,
|
views.del_whitelist,
|
||||||
name='del-whitelist'),
|
name='del-whitelist'),
|
||||||
url(r'^add_localemailaccount/(?P<userid>[0-9]+)$',
|
url(r'^add_emailaddress/(?P<userid>[0-9]+)$',
|
||||||
views.add_localemailaccount,
|
views.add_emailaddress,
|
||||||
name='add-localemailaccount'),
|
name='add-emailaddress'),
|
||||||
url(r'^edit_localemailaccount/(?P<localemailaccountid>[0-9]+)$',
|
url(r'^edit_emailaddress/(?P<emailaddressid>[0-9]+)$',
|
||||||
views.edit_localemailaccount,
|
views.edit_emailaddress,
|
||||||
name='edit-localemailaccount'),
|
name='edit-emailaddress'),
|
||||||
url(r'^del_localemailaccount/(?P<localemailaccountid>[0-9]+)$',
|
url(r'^del_emailaddress/(?P<emailaddressid>[0-9]+)$',
|
||||||
views.del_localemailaccount,
|
views.del_emailaddress,
|
||||||
name='del-localemailaccount'),
|
name='del-emailaddress'),
|
||||||
url(r'^edit_email_settings/(?P<userid>[0-9]+)$',
|
url(r'^edit_email_settings/(?P<userid>[0-9]+)$',
|
||||||
views.edit_email_settings,
|
views.edit_email_settings,
|
||||||
name='edit-email-settings'),
|
name='edit-email-settings'),
|
||||||
|
|
|
@ -81,12 +81,12 @@ from .models import (
|
||||||
Adherent,
|
Adherent,
|
||||||
Club,
|
Club,
|
||||||
ListShell,
|
ListShell,
|
||||||
LocalEmailAccount,
|
EMailAddress,
|
||||||
)
|
)
|
||||||
from .forms import (
|
from .forms import (
|
||||||
BanForm,
|
BanForm,
|
||||||
WhitelistForm,
|
WhitelistForm,
|
||||||
LocalEmailAccountForm,
|
EMailAddressForm,
|
||||||
EmailSettingsForm,
|
EmailSettingsForm,
|
||||||
DelSchoolForm,
|
DelSchoolForm,
|
||||||
DelListRightForm,
|
DelListRightForm,
|
||||||
|
@ -496,24 +496,24 @@ def del_whitelist(request, whitelist, **_kwargs):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(LocalEmailAccount)
|
@can_create(EMailAddress)
|
||||||
@can_edit(User)
|
@can_edit(User)
|
||||||
def add_localemailaccount(request, user, userid):
|
def add_emailaddress(request, user, userid):
|
||||||
""" Create a new local email account"""
|
""" Create a new local email account"""
|
||||||
localemailaccount_instance = LocalEmailAccount(user=user)
|
emailaddress_instance = EMailAddress(user=user)
|
||||||
localemailaccount = LocalEmailAccountForm(
|
emailaddress = EMailAddressForm(
|
||||||
request.POST or None,
|
request.POST or None,
|
||||||
instance=localemailaccount_instance
|
instance=emailaddress_instance
|
||||||
)
|
)
|
||||||
if localemailaccount.is_valid():
|
if emailaddress.is_valid():
|
||||||
localemailaccount.save()
|
emailaddress.save()
|
||||||
messages.success(request, "Local email account created")
|
messages.success(request, "Local email account created")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'users:profil',
|
'users:profil',
|
||||||
kwargs={'userid': str(userid)}
|
kwargs={'userid': str(userid)}
|
||||||
))
|
))
|
||||||
return form(
|
return form(
|
||||||
{'userform': localemailaccount,
|
{'userform': emailaddress,
|
||||||
'showCGU': False,
|
'showCGU': False,
|
||||||
'action_name': 'Add a local email account'},
|
'action_name': 'Add a local email account'},
|
||||||
'users/user.html',
|
'users/user.html',
|
||||||
|
@ -522,23 +522,23 @@ def add_localemailaccount(request, user, userid):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(LocalEmailAccount)
|
@can_edit(EMailAddress)
|
||||||
def edit_localemailaccount(request, localemailaccount_instance, **_kwargs):
|
def edit_emailaddress(request, emailaddress_instance, **_kwargs):
|
||||||
""" Edit a local email account"""
|
""" Edit a local email account"""
|
||||||
localemailaccount = LocalEmailAccountForm(
|
emailaddress = EMailAddressForm(
|
||||||
request.POST or None,
|
request.POST or None,
|
||||||
instance=localemailaccount_instance
|
instance=emailaddress_instance
|
||||||
)
|
)
|
||||||
if localemailaccount.is_valid():
|
if emailaddress.is_valid():
|
||||||
if localemailaccount.changed_data:
|
if emailaddress.changed_data:
|
||||||
localemailaccount.save()
|
emailaddress.save()
|
||||||
messages.success(request, "Local email account modified")
|
messages.success(request, "Local email account modified")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'users:profil',
|
'users:profil',
|
||||||
kwargs={'userid': str(localemailaccount_instance.user.id)}
|
kwargs={'userid': str(emailaddress_instance.user.id)}
|
||||||
))
|
))
|
||||||
return form(
|
return form(
|
||||||
{'userform': localemailaccount,
|
{'userform': emailaddress,
|
||||||
'showCGU': False,
|
'showCGU': False,
|
||||||
'action_name': 'Edit a local email account'},
|
'action_name': 'Edit a local email account'},
|
||||||
'users/user.html',
|
'users/user.html',
|
||||||
|
@ -547,18 +547,18 @@ def edit_localemailaccount(request, localemailaccount_instance, **_kwargs):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_delete(LocalEmailAccount)
|
@can_delete(EMailAddress)
|
||||||
def del_localemailaccount(request, localemailaccount, **_kwargs):
|
def del_emailaddress(request, emailaddress, **_kwargs):
|
||||||
"""Delete a local email account"""
|
"""Delete a local email account"""
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
localemailaccount.delete()
|
emailaddress.delete()
|
||||||
messages.success(request, "Local email account deleted")
|
messages.success(request, "Local email account deleted")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'users:profil',
|
'users:profil',
|
||||||
kwargs={'userid': str(localemailaccount.user.id)}
|
kwargs={'userid': str(emailaddress.user.id)}
|
||||||
))
|
))
|
||||||
return form(
|
return form(
|
||||||
{'objet': localemailaccount, 'objet_name': 'localemailaccount'},
|
{'objet': emailaddress, 'objet_name': 'emailaddress'},
|
||||||
'users/delete.html',
|
'users/delete.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
@ -1013,7 +1013,7 @@ def profil(request, users, **_kwargs):
|
||||||
'user_solde': user_solde,
|
'user_solde': user_solde,
|
||||||
'solde_activated': Paiement.objects.filter(is_balance=True).exists(),
|
'solde_activated': Paiement.objects.filter(is_balance=True).exists(),
|
||||||
'asso_name': AssoOption.objects.first().name,
|
'asso_name': AssoOption.objects.first().name,
|
||||||
'localemailaccount_list': users.local_email_accounts,
|
'emailaddress_list': users.email_address,
|
||||||
'local_email_accounts_enabled': (
|
'local_email_accounts_enabled': (
|
||||||
OptionalUser.objects.first().local_email_accounts_enabled
|
OptionalUser.objects.first().local_email_accounts_enabled
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue