mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
ajout du nombre d'alias max
This commit is contained in:
parent
b7977f493b
commit
cc2dcefa8f
5 changed files with 62 additions and 20 deletions
20
preferences/migrations/0037_optionaluser_max_mail_alias.py
Normal file
20
preferences/migrations/0037_optionaluser_max_mail_alias.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-06-30 12:32
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0036_optionaluser_mail_accounts'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='optionaluser',
|
||||||
|
name='max_mail_alias',
|
||||||
|
field=models.IntegerField(default=15, help_text="Nombre maximal d'alias pour un utilisateur lambda"),
|
||||||
|
),
|
||||||
|
]
|
|
@ -90,6 +90,10 @@ class OptionalUser(AclMixin, PreferencesModel):
|
||||||
default = "@example.org",
|
default = "@example.org",
|
||||||
help_text="Extension principale pour les mails internes",
|
help_text="Extension principale pour les mails internes",
|
||||||
)
|
)
|
||||||
|
max_mail_alias = models.IntegerField(
|
||||||
|
default = 15,
|
||||||
|
help_text = "Nombre maximal d'alias pour un utilisateur lambda"
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = (
|
permissions = (
|
||||||
|
|
|
@ -64,17 +64,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<th>Extension mail interne</th>
|
<th>Extension mail interne</th>
|
||||||
<td>{{ useroptions.mail_extension }}</td>
|
<td>{{ useroptions.mail_extension }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
<tr>
|
||||||
|
<th>Nombre d'alias maximum</th>
|
||||||
|
<td>{{ useroption.max_mail_alias }}<td>
|
||||||
<h4>Préférences machines</h4>
|
</tr>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalMachine' %}">
|
</table>
|
||||||
<i class="fa fa-edit"></i>
|
<h4>Préférences machines</h4>
|
||||||
Editer
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalMachine' %}">
|
||||||
</a>
|
<i class="fa fa-edit"></i>
|
||||||
<p>
|
Editer
|
||||||
</p>
|
</a>
|
||||||
<table class="table table-striped">
|
<p>
|
||||||
|
</p>
|
||||||
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Mot de passe par machine</th>
|
<th>Mot de passe par machine</th>
|
||||||
<td>{{ machineoptions.password_machine|tick }}</td>
|
<td>{{ machineoptions.password_machine|tick }}</td>
|
||||||
|
|
|
@ -1694,6 +1694,23 @@ class MailAlias(RevMixin, AclMixin, models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.valeur + OptionalUser.get_cached_value('mail_extension')
|
return self.valeur + OptionalUser.get_cached_value('mail_extension')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def can_create(user_request, userid, *_args, **_kwargs):
|
||||||
|
"""Check if an user can create an mailalias object.
|
||||||
|
|
||||||
|
:param user_request: The user who wants to create a mailalias object.
|
||||||
|
:return: a message and a boolean which is True if the user can create
|
||||||
|
an user or if the `options.all_can_create` is set.
|
||||||
|
"""
|
||||||
|
if not user_request.has_perm('users.add_mailalias'):
|
||||||
|
if int(user_request.id) != int(userid):
|
||||||
|
return False, 'Vous n\'avez pas le droit d\'ajouter un alias à une autre personne'
|
||||||
|
elif user_request.mailalias_set.all().count() >= OptionalUser.get_cached_value('max_mail_alias'):
|
||||||
|
return False, "Vous avez atteint la limite de {} alias".format(OptionalUser.get_cached_value('max_mail_alias'))
|
||||||
|
else:
|
||||||
|
return True, None
|
||||||
|
return True, None
|
||||||
|
|
||||||
def can_view(self, user_request, *_args, **_kwargs):
|
def can_view(self, user_request, *_args, **_kwargs):
|
||||||
"""
|
"""
|
||||||
Check if the user can view the aliases
|
Check if the user can view the aliases
|
||||||
|
|
|
@ -415,8 +415,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
<div id="collapse7" class="panel-collapse collapse">
|
<div id="collapse7" class="panel-collapse collapse">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% can_edit user.mail %}
|
{% can_edit users %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-mail' users.mail.id %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-mail' users.id %}">
|
||||||
<i class="fa fa-plus-square"></i>
|
<i class="fa fa-plus-square"></i>
|
||||||
Modifier les options mail
|
Modifier les options mail
|
||||||
</a>
|
</a>
|
||||||
|
@ -430,18 +430,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<th>Adresse mail de contact</th>
|
<th>Adresse mail de contact</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.external_mail }}</td>
|
<td>{{ users.external_mail }}</td>
|
||||||
<td>{{ user.internal_address|yesno:"Activé,Désactivé" }}</td>
|
<td>{{ users.internal_address|yesno:"Activé,Désactivé" }}</td>
|
||||||
<td>{{ user.get_mail }}</td>
|
<td>{{ users.get_mail }}</td>
|
||||||
</table>
|
</table>
|
||||||
<div class="alert alert-info" role="alert">
|
<div class="alert alert-info" role="alert">
|
||||||
Vous pouvez bénéficier d'une adresse mail {{ asso_name }}.
|
Vous pouvez bénéficier d'une adresse mail {{ asso_name }}.
|
||||||
Vous pouvez également la rediriger vers une adresse externe en modifiant les options mail.
|
Vous pouvez également la rediriger vers une adresse externe en modifiant les options mail.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if user.internal_address %}
|
{% if users.internal_address %}
|
||||||
|
{% can_create MailAlias users.id %}
|
||||||
{% can_create MailAlias %}
|
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-mailalias' users.id %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-mailalias' users.id %}">
|
||||||
<i class="fa fa-plus-square"></i>
|
<i class="fa fa-plus-square"></i>
|
||||||
Ajouter un alias mail
|
Ajouter un alias mail
|
||||||
|
@ -458,7 +457,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<th>Adresse mail</th>
|
<th>Adresse mail</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.external_mail }}</td>
|
<td>{{ users.external_mail }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue