Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
cc2dcefa
Commit
cc2dcefa
authored
Jun 30, 2018
by
grisel-davy
Committed by
Maël Kervella
Jul 30, 2018
Browse files
ajout du nombre d'alias max
parent
b7977f49
Changes
5
Hide whitespace changes
Inline
Side-by-side
preferences/migrations/0037_optionaluser_max_mail_alias.py
0 → 100644
View file @
cc2dcefa
# -*- 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"
),
),
]
preferences/models.py
View file @
cc2dcefa
...
...
@@ -90,6 +90,10 @@ class OptionalUser(AclMixin, PreferencesModel):
default
=
"@example.org"
,
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
:
permissions
=
(
...
...
preferences/templates/preferences/display_preferences.html
View file @
cc2dcefa
...
...
@@ -64,17 +64,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Extension mail interne
</th>
<td>
{{ useroptions.mail_extension }}
</td>
</tr>
</table>
<h4>
Préférences machines
</h4>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'preferences:edit-options' 'OptionalMachine' %}"
>
<i
class=
"fa fa-edit"
></i>
Editer
</a>
<p>
</p>
<table
class=
"table table-striped"
>
<tr>
<th>
Nombre d'alias maximum
</th>
<td>
{{ useroption.max_mail_alias }}
<td>
</tr>
</table>
<h4>
Préférences machines
</h4>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'preferences:edit-options' 'OptionalMachine' %}"
>
<i
class=
"fa fa-edit"
></i>
Editer
</a>
<p>
</p>
<table
class=
"table table-striped"
>
<tr>
<th>
Mot de passe par machine
</th>
<td>
{{ machineoptions.password_machine|tick }}
</td>
...
...
users/models.py
View file @
cc2dcefa
...
...
@@ -1694,6 +1694,23 @@ class MailAlias(RevMixin, AclMixin, models.Model):
def
__str__
(
self
):
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
):
"""
Check if the user can view the aliases
...
...
users/templates/users/profil.html
View file @
cc2dcefa
...
...
@@ -415,8 +415,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
<div
id=
"collapse7"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
{% can_edit user
.mail
%}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:edit-mail' users.
mail.
id %}"
>
{% can_edit user
s
%}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:edit-mail' users.id %}"
>
<i
class=
"fa fa-plus-square"
></i>
Modifier les options mail
</a>
...
...
@@ -430,18 +430,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Adresse mail de contact
</th>
</tr>
<tr>
<td>
{{ user.external_mail }}
</td>
<td>
{{ user.internal_address|yesno:"Activé,Désactivé" }}
</td>
<td>
{{ user.get_mail }}
</td>
<td>
{{ user
s
.external_mail }}
</td>
<td>
{{ user
s
.internal_address|yesno:"Activé,Désactivé" }}
</td>
<td>
{{ user
s
.get_mail }}
</td>
</table>
<div
class=
"alert alert-info"
role=
"alert"
>
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.
</div>
</div>
{% if user.internal_address %}
{% can_create MailAlias %}
{% if users.internal_address %}
{% can_create 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>
Ajouter un alias mail
...
...
@@ -458,7 +457,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Adresse mail
</th>
</tr>
<tr>
<td>
{{ user.external_mail }}
</td>
<td>
{{ user
s
.external_mail }}
</td>
</tr>
</table>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment