diff --git a/api/serializers.py b/api/serializers.py
index d07cb9fe..398f2b19 100644
--- a/api/serializers.py
+++ b/api/serializers.py
@@ -596,12 +596,12 @@ class WhitelistSerializer(NamespacedHMSerializer):
fields = ('user', 'raison', 'date_start', 'date_end', 'active', 'api_url')
-class LocalEmailAccountSerializer(NamespacedHMSerializer):
- """Serialize `users.models.LocalEmailAccount` objects.
+class EMailAddressSerializer(NamespacedHMSerializer):
+ """Serialize `users.models.EMailAddress` objects.
"""
class Meta:
- model = users.LocalEmailAccount
+ model = users.EMailAddress
fields = ('user', 'local_part', 'complete_email_address', 'api_url')
@@ -627,7 +627,7 @@ class ServiceRegenSerializer(NamespacedHMSerializer):
class LocalEmailUsersSerializer(NamespacedHMSerializer):
- local_email_accounts = LocalEmailAccountSerializer(
+ email_address = EMailAddressSerializer(
read_only=True,
many=True
)
@@ -635,7 +635,7 @@ class LocalEmailUsersSerializer(NamespacedHMSerializer):
class Meta:
model = users.User
fields = ('local_email_enabled', 'local_email_redirect',
- 'local_email_accounts')
+ 'email_address')
# DHCP
diff --git a/api/urls.py b/api/urls.py
index 88211c4b..7ee36073 100644
--- a/api/urls.py
+++ b/api/urls.py
@@ -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/ban', views.BanViewSet)
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
router.register_viewset(r'services/regen', views.ServiceRegenViewSet, base_name='serviceregen')
# DHCP
diff --git a/api/views.py b/api/views.py
index 04c7a461..ef083edf 100644
--- a/api/views.py
+++ b/api/views.py
@@ -469,19 +469,19 @@ class WhitelistViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = serializers.WhitelistSerializer
-class LocalEmailAccountViewSet(viewsets.ReadOnlyModelViewSet):
- """Exposes list and details of `users.models.LocalEmailAccount` objects.
+class EMailAddressViewSet(viewsets.ReadOnlyModelViewSet):
+ """Exposes list and details of `users.models.EMailAddress` objects.
"""
- serializer_class = serializers.LocalEmailAccountSerializer
- queryset = users.LocalEmailAccount.objects.none()
+ serializer_class = serializers.EMailAddressSerializer
+ queryset = users.EMailAddress.objects.none()
def get_queryset(self):
if preferences.OptionalUser.get_cached_value(
'local_email_accounts_enabled'):
- return (users.LocalEmailAccount.objects
+ return (users.EMailAddress.objects
.filter(user__local_email_enabled=True))
else:
- return users.LocalEmailAccount.objects.none()
+ return users.EMailAddress.objects.none()
# SERVICE REGEN
diff --git a/preferences/migrations/0046_optionaluser_mail_extension.py b/preferences/migrations/0046_optionaluser_mail_extension.py
index 5fc6c5e0..9de1608a 100644
--- a/preferences/migrations/0046_optionaluser_mail_extension.py
+++ b/preferences/migrations/0046_optionaluser_mail_extension.py
@@ -24,7 +24,7 @@ class Migration(migrations.Migration):
),
migrations.AddField(
model_name='optionaluser',
- name='max_local_email_accounts',
- field=models.IntegerField(default=15, help_text='Maximum number of local email accounts for a standard user'),
+ name='max_email_address',
+ field=models.IntegerField(default=15, help_text='Maximum number of local email address for a standard user'),
),
]
diff --git a/preferences/models.py b/preferences/models.py
index 5f13bc4b..c2d6aa74 100644
--- a/preferences/models.py
+++ b/preferences/models.py
@@ -93,9 +93,9 @@ class OptionalUser(AclMixin, PreferencesModel):
default = "@example.org",
help_text="Domain to use for local email accounts",
)
- max_local_email_accounts = models.IntegerField(
+ max_email_address = models.IntegerField(
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:
diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html
index c6f11734..a3f2dbc3 100644
--- a/preferences/templates/preferences/display_preferences.html
+++ b/preferences/templates/preferences/display_preferences.html
@@ -66,8 +66,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{{ useroptions.local_email_domain }} |
- Nombre de comptes maximum |
- {{ useroptions.max_local_email_accounts }} |
+ Nombre d'alias mail max |
+ {{ useroptions.max_email_address }} |
diff --git a/users/admin.py b/users/admin.py
index bc1670a7..e7dd3240 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -34,7 +34,7 @@ from reversion.admin import VersionAdmin
from .models import (
User,
- LocalEmailAccount,
+ EMailAddress,
ServiceUser,
School,
ListRight,
@@ -109,7 +109,7 @@ class BanAdmin(VersionAdmin):
pass
-class LocalEmailAccountAdmin(VersionAdmin):
+class EMailAddressAdmin(VersionAdmin):
"""Gestion des alias mail"""
pass
@@ -219,7 +219,7 @@ admin.site.register(School, SchoolAdmin)
admin.site.register(ListRight, ListRightAdmin)
admin.site.register(ListShell, ListShellAdmin)
admin.site.register(Ban, BanAdmin)
-admin.site.register(LocalEmailAccount, LocalEmailAccountAdmin)
+admin.site.register(EMailAddress, EMailAddressAdmin)
admin.site.register(Whitelist, WhitelistAdmin)
admin.site.register(Request, RequestAdmin)
# Now register the new UserAdmin...
diff --git a/users/forms.py b/users/forms.py
index 7b17a5ec..cbffd961 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -53,7 +53,7 @@ from .models import (
School,
ListRight,
Whitelist,
- LocalEmailAccount,
+ EMailAddress,
ListShell,
Ban,
Adherent,
@@ -591,16 +591,16 @@ class WhitelistForm(FormRevMixin, ModelForm):
widgets = {'date_end':DateTimePicker}
-class LocalEmailAccountForm(FormRevMixin, ModelForm):
- """Create and edit a local email account"""
+class EMailAddressForm(FormRevMixin, ModelForm):
+ """Create and edit a local email address"""
def __init__(self, *args, **kwargs):
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'].help_text = "Can't contain @"
class Meta:
- model = LocalEmailAccount
+ model = EMailAddress
exclude = ['user']
diff --git a/users/migrations/0073_auto_20180629_1614.py b/users/migrations/0073_auto_20180629_1614.py
index 6b976f88..72ebffe6 100644
--- a/users/migrations/0073_auto_20180629_1614.py
+++ b/users/migrations/0073_auto_20180629_1614.py
@@ -10,21 +10,21 @@ import re2o.mixins
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
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()
for user in users:
- LocalEmailAccount.objects.using(db_alias).create(
+ EMailAddress.objects.using(db_alias).create(
local_part=user.pseudo,
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
- LocalEmailAccount = apps.get_model("users", "LocalEmailAccount")
- LocalEmailAccount.objects.using(db_alias).delete()
+ EMailAddress = apps.get_model("users", "EMailAddress")
+ EMailAddress.objects.using(db_alias).delete()
dependencies = [
('users', '0072_auto_20180426_2021'),
@@ -32,14 +32,14 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
- name='LocalEmailAccount',
+ name='EMailAddress',
fields=[
('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)),
('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),
- 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(
model_name='user',
@@ -51,8 +51,7 @@ class Migration(migrations.Migration):
name='local_email_redirect',
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,
- delete_all_local_email_accounts),
- ),
+ migrations.RunPython(create_initial_email_address,
+ delete_all_email_address),
]
diff --git a/users/models.py b/users/models.py
index f7e51703..bdc37142 100755
--- a/users/models.py
+++ b/users/models.py
@@ -683,11 +683,11 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
return
@cached_property
- def local_email_accounts(self):
+ def email_address(self):
if (OptionalUser.get_cached_value('local_email_accounts_enabled')
and self.local_email_enabled):
- return self.localemailaccount_set.all()
- return LocalEmailAccount.objects.none()
+ return self.emailaddress_set.all()
+ return EMailAddress.objects.none()
def get_next_domain_name(self):
"""Look for an available name for a new interface for
@@ -935,7 +935,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
def clean(self, *args, **kwargs):
"""Check if this pseudo is already used by any mailalias.
Better than raising an error in post-save and catching it"""
- if (LocalEmailAccount.objects
+ if (EMailAddress.objects
.filter(local_part=self.pseudo)
.exclude(user=self)):
raise ValidationError("This pseudo is already in use.")
@@ -1066,7 +1066,7 @@ def user_post_save(**kwargs):
Synchronise le ldap"""
is_created = kwargs['created']
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:
user.notif_inscription()
user.state_sync()
@@ -1648,7 +1648,7 @@ class LdapServiceUserGroup(ldapdb.models.Model):
return self.name
-class LocalEmailAccount(RevMixin, AclMixin, models.Model):
+class EMailAddress(RevMixin, AclMixin, models.Model):
"""Defines a local email account for a user
"""
user = models.ForeignKey(
@@ -1664,7 +1664,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
class Meta:
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_plural = "Local email accounts"
@@ -1678,7 +1678,7 @@ class LocalEmailAccount(RevMixin, AclMixin, models.Model):
@staticmethod
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:
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 local email account.
"""
- if user_request.has_perm('users.add_localemailaccount'):
+ if user_request.has_perm('users.add_emailaddress'):
return True, None
if not OptionalUser.get_cached_value('local_email_accounts_enabled'):
return False, "The local email accounts are not enabled."
if int(user_request.id) != int(userid):
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(
- OptionalUser.get_cached_value('max_local_email_accounts')
+ OptionalUser.get_cached_value('max_email_address')
)
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
the local email account.
"""
- if user_request.has_perm('users.view_localemailaccount'):
+ if user_request.has_perm('users.view_emailaddress'):
return True, None
if not OptionalUser.get_cached_value('local_email_accounts_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:
return False, ("You cannot delete a local email account whose "
"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
if not OptionalUser.get_cached_value('local_email_accounts_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:
return False, ("You cannot edit a local email account whose "
"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
if not OptionalUser.get_cached_value('local_email_accounts_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):
if "@" in self.local_part:
raise ValidationError("The local part cannot contain a @")
- super(LocalEmailAccount, self).clean(*args, **kwargs)
+ super(EMailAddress, self).clean(*args, **kwargs)
diff --git a/users/templates/users/aff_localemailaccounts.html b/users/templates/users/aff_emailaddress.html
similarity index 71%
rename from users/templates/users/aff_localemailaccounts.html
rename to users/templates/users/aff_emailaddress.html
index f129d8ab..14156ac9 100644
--- a/users/templates/users/aff_localemailaccounts.html
+++ b/users/templates/users/aff_emailaddress.html
@@ -25,32 +25,32 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load acl %}
{% load logs_extra %}
-{% if localemailaccount_list.paginator %}
-{% include "pagination.html" with list=alias_list %}
+{% if emailaddress_list.paginator %}
+{% include "pagination.html" with list=emailaddress_list %}
{% endif %}
- Local email address |
+ Email address |
|
- {% for localemailaccount in localemailaccount_list %}
- {{ localemailaccount.complete_email_address }} |
+ {% for emailaddress in emailaddress_list %}
+ {{ emailaddress.complete_email_address }} |
- {% can_delete localemailaccount %}
- {% include 'buttons/suppr.html' with href='users:del-localemailaccount' id=localemailaccount.id %}
+ {% can_delete emailaddress %}
+ {% include 'buttons/suppr.html' with href='users:del-emailaddress' id=emailaddress.id %}
{% acl_end %}
- {% can_edit localemailaccount %}
- {% include 'buttons/edit.html' with href='users:edit-localemailaccount' id=localemailaccount.id %}
+ {% can_edit emailaddress %}
+ {% include 'buttons/edit.html' with href='users:edit-emailaddress' id=emailaddress.id %}
{% acl_end %}
- {% history_button localemailaccount %}
+ {% history_button emailaddress %}
|
{% endfor %}
-{% if localemailaccount_list.paginator %}
-{% include "pagination.html" with list=alias_list %}
+{% if emailaddress_list.paginator %}
+{% include "pagination.html" with list=emailaddress_list %}
{% endif %}
diff --git a/users/templates/users/index_localemailaccount.html b/users/templates/users/index_emailaddress.html
similarity index 91%
rename from users/templates/users/index_localemailaccount.html
rename to users/templates/users/index_emailaddress.html
index 8ebdb9ec..6976e168 100644
--- a/users/templates/users/index_localemailaccount.html
+++ b/users/templates/users/index_emailaddress.html
@@ -29,6 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
Local email accounts
- {% include "users/aff_localemailaccounts.html" with localemailaccount_list=localemailaccount_list %}
+ {% include "users/aff_emailaddress.html" with emailaddress_list=emailaddress_list %}
{% endblock %}
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
index 450494af..1e1926cc 100644
--- a/users/templates/users/profil.html
+++ b/users/templates/users/profil.html
@@ -433,18 +433,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Enable the local email account |
{{ users.local_email_enabled | tick }} |
Enable the local email redirection |
- {{ users.local_email_redirect | tick }} |
-
-
-
- {% if users.local_email_enabled %}
- {% can_create LocalEmailAccount users.id %}
-
- Add a local email account
+ {{ users.local_email_redirect | tick }} |
+
+
+
+ {% if users.local_email_enabled %}
+ {% can_create EMailAddress users.id %}
+
+ Add an email address
{% acl_end %}
- {% if localemailaccount_list %}
- {% include "users/aff_localemailaccounts.html" with localemailaccount_list=localemailaccount_list %}
+ {% if emailaddress_list %}
+ {% include "users/aff_emailaddress.html" with emailaddress_list=emailaddress_list %}
{% endif %}
{% endif %}
{% else %}
diff --git a/users/urls.py b/users/urls.py
index 0dd4e246..f5114600 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -64,15 +64,15 @@ urlpatterns = [
url(r'^del_whitelist/(?P[0-9]+)$',
views.del_whitelist,
name='del-whitelist'),
- url(r'^add_localemailaccount/(?P[0-9]+)$',
- views.add_localemailaccount,
- name='add-localemailaccount'),
- url(r'^edit_localemailaccount/(?P[0-9]+)$',
- views.edit_localemailaccount,
- name='edit-localemailaccount'),
- url(r'^del_localemailaccount/(?P[0-9]+)$',
- views.del_localemailaccount,
- name='del-localemailaccount'),
+ url(r'^add_emailaddress/(?P[0-9]+)$',
+ views.add_emailaddress,
+ name='add-emailaddress'),
+ url(r'^edit_emailaddress/(?P[0-9]+)$',
+ views.edit_emailaddress,
+ name='edit-emailaddress'),
+ url(r'^del_emailaddress/(?P[0-9]+)$',
+ views.del_emailaddress,
+ name='del-emailaddress'),
url(r'^edit_email_settings/(?P[0-9]+)$',
views.edit_email_settings,
name='edit-email-settings'),
diff --git a/users/views.py b/users/views.py
index 402cee08..a4f4ea83 100644
--- a/users/views.py
+++ b/users/views.py
@@ -81,12 +81,12 @@ from .models import (
Adherent,
Club,
ListShell,
- LocalEmailAccount,
+ EMailAddress,
)
from .forms import (
BanForm,
WhitelistForm,
- LocalEmailAccountForm,
+ EMailAddressForm,
EmailSettingsForm,
DelSchoolForm,
DelListRightForm,
@@ -496,24 +496,24 @@ def del_whitelist(request, whitelist, **_kwargs):
@login_required
-@can_create(LocalEmailAccount)
+@can_create(EMailAddress)
@can_edit(User)
-def add_localemailaccount(request, user, userid):
+def add_emailaddress(request, user, userid):
""" Create a new local email account"""
- localemailaccount_instance = LocalEmailAccount(user=user)
- localemailaccount = LocalEmailAccountForm(
+ emailaddress_instance = EMailAddress(user=user)
+ emailaddress = EMailAddressForm(
request.POST or None,
- instance=localemailaccount_instance
+ instance=emailaddress_instance
)
- if localemailaccount.is_valid():
- localemailaccount.save()
+ if emailaddress.is_valid():
+ emailaddress.save()
messages.success(request, "Local email account created")
return redirect(reverse(
'users:profil',
kwargs={'userid': str(userid)}
))
return form(
- {'userform': localemailaccount,
+ {'userform': emailaddress,
'showCGU': False,
'action_name': 'Add a local email account'},
'users/user.html',
@@ -522,23 +522,23 @@ def add_localemailaccount(request, user, userid):
@login_required
-@can_edit(LocalEmailAccount)
-def edit_localemailaccount(request, localemailaccount_instance, **_kwargs):
+@can_edit(EMailAddress)
+def edit_emailaddress(request, emailaddress_instance, **_kwargs):
""" Edit a local email account"""
- localemailaccount = LocalEmailAccountForm(
+ emailaddress = EMailAddressForm(
request.POST or None,
- instance=localemailaccount_instance
+ instance=emailaddress_instance
)
- if localemailaccount.is_valid():
- if localemailaccount.changed_data:
- localemailaccount.save()
+ if emailaddress.is_valid():
+ if emailaddress.changed_data:
+ emailaddress.save()
messages.success(request, "Local email account modified")
return redirect(reverse(
'users:profil',
- kwargs={'userid': str(localemailaccount_instance.user.id)}
+ kwargs={'userid': str(emailaddress_instance.user.id)}
))
return form(
- {'userform': localemailaccount,
+ {'userform': emailaddress,
'showCGU': False,
'action_name': 'Edit a local email account'},
'users/user.html',
@@ -547,18 +547,18 @@ def edit_localemailaccount(request, localemailaccount_instance, **_kwargs):
@login_required
-@can_delete(LocalEmailAccount)
-def del_localemailaccount(request, localemailaccount, **_kwargs):
+@can_delete(EMailAddress)
+def del_emailaddress(request, emailaddress, **_kwargs):
"""Delete a local email account"""
if request.method == "POST":
- localemailaccount.delete()
+ emailaddress.delete()
messages.success(request, "Local email account deleted")
return redirect(reverse(
'users:profil',
- kwargs={'userid': str(localemailaccount.user.id)}
+ kwargs={'userid': str(emailaddress.user.id)}
))
return form(
- {'objet': localemailaccount, 'objet_name': 'localemailaccount'},
+ {'objet': emailaddress, 'objet_name': 'emailaddress'},
'users/delete.html',
request
)
@@ -1013,7 +1013,7 @@ def profil(request, users, **_kwargs):
'user_solde': user_solde,
'solde_activated': Paiement.objects.filter(is_balance=True).exists(),
'asso_name': AssoOption.objects.first().name,
- 'localemailaccount_list': users.local_email_accounts,
+ 'emailaddress_list': users.email_address,
'local_email_accounts_enabled': (
OptionalUser.objects.first().local_email_accounts_enabled
)