Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
intranet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nounous-archives
intranet
Commits
db0b48f3
Commit
db0b48f3
authored
Sep 17, 2015
by
Gabriel Detraz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Création d'une vue à part pour la redirection
parent
1949f042
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
24 deletions
+57
-24
apps/compte/forms.py
apps/compte/forms.py
+3
-4
apps/compte/urls.py
apps/compte/urls.py
+2
-1
apps/compte/views.py
apps/compte/views.py
+23
-11
templates/compte/affichage.html
templates/compte/affichage.html
+5
-8
templates/compte/redirection.html
templates/compte/redirection.html
+24
-0
No files found.
apps/compte/forms.py
View file @
db0b48f3
...
...
@@ -15,8 +15,10 @@ class CompteForm(forms.Form):
annetudes
=
forms
.
CharField
(
label
=
u
"Année d'étude"
,
max_length
=
100
,
required
=
False
)
dometudes
=
forms
.
CharField
(
label
=
u
'Domaine'
,
max_length
=
100
,
required
=
False
)
mailAlias
=
forms
.
EmailField
(
label
=
u
'Nouvel alias Mail'
,
max_length
=
40
,
required
=
False
)
mailredirect
=
forms
.
CharField
(
label
=
u
'Redirection des mails'
,
max_length
=
40
,
required
=
False
)
contourneGreylist
=
forms
.
CharField
(
label
=
u
'Contournement du greylisting'
,
max_length
=
10
,
widget
=
widgets
.
CheckboxInput
,
required
=
False
)
class
RedirectionForm
(
forms
.
Form
):
mailredirect
=
forms
.
CharField
(
label
=
u
'Redirection des mails'
,
max_length
=
40
,
required
=
False
)
def
clean_mailredirect
(
self
):
mailredirect
=
self
.
cleaned_data
[
'mailredirect'
]
if
"@crans.org"
in
mailredirect
:
...
...
@@ -28,9 +30,6 @@ class CompteForm(forms.Form):
raise
forms
.
ValidationError
(
"Ce champ doit être une adresse mail ou l'execution d'un programme type procmail"
)
return
mailredirect
contourneGreylist
=
forms
.
CharField
(
label
=
u
'Contournement du greylisting'
,
max_length
=
10
,
widget
=
widgets
.
CheckboxInput
,
required
=
False
)
class
PassForm
(
forms
.
Form
):
passwdexists
=
forms
.
CharField
(
label
=
u
'Ancien mot de passe'
,
max_length
=
255
,
widget
=
widgets
.
PasswordInput
,
required
=
False
)
newpasswd1
=
forms
.
CharField
(
label
=
u
'Nouveau mot de passe'
,
max_length
=
255
,
widget
=
widgets
.
PasswordInput
,
required
=
False
)
...
...
apps/compte/urls.py
View file @
db0b48f3
...
...
@@ -5,5 +5,6 @@ import views
urlpatterns
=
patterns
(
''
,
url
(
'^$'
,
views
.
afficher
,
name
=
'afficher'
),
url
(
'chgpass'
,
views
.
chgpass
,
name
=
'chgpass'
)
url
(
'chgpass'
,
views
.
chgpass
,
name
=
'chgpass'
),
url
(
'redirection'
,
views
.
redirection
,
name
=
'redirection'
)
)
apps/compte/views.py
View file @
db0b48f3
...
...
@@ -24,6 +24,7 @@ from gestion import config
from
forms
import
CompteForm
from
forms
import
PassForm
from
forms
import
RedirectionForm
from
django.forms.util
import
ErrorList
# Vue d'affichage seulement des infos pour l'adh
...
...
@@ -53,10 +54,6 @@ def afficher(request):
annetudes
=
_etudes
[
1
]
dometudes
=
_etudes
[
2
]
# On récupère la redirection
redirect
=
subprocess
.
Popen
([
"sudo"
,
"/usr/scripts/utils/forward.py"
,
"--read"
,
"--name=%s"
%
luser
[
'uid'
][
0
]],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
mailredirect
=
redirect
.
stdout
.
readlines
()[
0
]
initial_data
=
{
'nom'
:
luser
[
'nom'
][
0
],
'prenom'
:
luser
[
'prenom'
][
0
],
...
...
@@ -65,7 +62,6 @@ def afficher(request):
'annetudes'
:
annetudes
,
'etabetudes'
:
etabetudes
,
'dometudes'
:
dometudes
,
'mailredirect'
:
mailredirect
,
}
else
:
...
...
@@ -77,12 +73,6 @@ def afficher(request):
if
request
.
method
==
"POST"
:
form
=
CompteForm
(
request
.
POST
,
initial
=
initial_data
)
if
form
.
is_valid
():
# La redirection n'est pas un champ ldap
if
'mailredirect'
in
form
.
changed_data
:
mailredirect
=
unicode
(
form
.
cleaned_data
[
'mailredirect'
])
redirect
=
subprocess
.
Popen
([
"sudo"
,
"/usr/scripts/utils/forward.py"
,
"--write"
,
"--mail=%s"
%
mailredirect
,
"--name=%s"
%
luser
[
'uid'
][
0
]])
_
=
form
.
changed_data
.
remove
(
'mailredirect'
)
# On ouvre une connexion
luserconn
=
conn_pool
.
get_user
(
request
.
user
,
mode
=
'w'
)
with
luserconn
as
luser
:
...
...
@@ -185,3 +175,25 @@ def chgpass(request):
else
:
form
=
PassForm
()
return
render
(
request
,
"compte/chgpass.html"
,
{
'form'
:
form
})
@
login_required
def
redirection
(
request
):
luser
=
conn_pool
.
get_user
(
request
.
user
)
redirection_mail
=
subprocess
.
Popen
([
"sudo"
,
"/usr/scripts/utils/forward.py"
,
"--read"
,
"--name=%s"
%
luser
[
'uid'
][
0
]],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
mailredirect
=
redirection_mail
.
stdout
.
readlines
()[
0
]
initial_data
=
{
'mailredirect'
:
mailredirect
,
}
if
request
.
method
==
"POST"
:
form
=
RedirectionForm
(
request
.
POST
,
initial
=
initial_data
)
if
form
.
is_valid
():
# La redirection n'est pas un champ ldap
if
'mailredirect'
in
form
.
changed_data
:
mailredirect
=
unicode
(
form
.
cleaned_data
[
'mailredirect'
])
redirection_mail
=
subprocess
.
Popen
([
"sudo"
,
"/usr/scripts/utils/forward.py"
,
"--write"
,
"--mail=%s"
%
mailredirect
,
"--name=%s"
%
luser
[
'uid'
][
0
]])
messages
.
success
(
request
,
u
"""Votre redirection a bien été changée"""
)
return
redirect
(
"/compte/"
)
else
:
form
=
RedirectionForm
(
initial
=
initial_data
)
return
render
(
request
,
"compte/redirection.html"
,
{
'form'
:
form
})
templates/compte/affichage.html
View file @
db0b48f3
...
...
@@ -95,14 +95,6 @@
</div>
<h2>
Mail
</h2>
<div
class=
"row"
>
<div
class=
"four columns{% if form.mailredirect.errors %} error{% endif %}"
>
{{ form.mailredirect.label_tag}}
{{ form.mailredirect }}
{{ form.mailredirect.errors }}
</div>
</div>
<div
class=
"row"
>
<div
class=
"six columns"
>
<label>
Mail de contact :
</label>
...
...
@@ -133,6 +125,11 @@
</div>
</div>
<div
class=
"row"
>
<a
class=
"button"
href=
"{% url 'compte:redirection' %}"
>
Changer la redirection mail
</a>
</div>
<footer>
<div
class=
"row"
>
<div
class=
"six columns"
>
...
...
templates/compte/redirection.html
0 → 100644
View file @
db0b48f3
{% extends "template.html" %}
{% block title %} Redirection {% endblock %}
{% block h1 %} Changement de la redirection de mes emails Cr@ns {% endblock %}
{% block content %}
<form
class=
"form-full-width"
method=
"post"
>
{% csrf_token %}
<div
class=
"error-container"
>
{{ form.non_field_errors }}
</div>
<div
class=
"row"
>
<div
class=
"six columns{% if form.mailredirect.errors %} error{% endif %}"
>
{{ form.mailredirect.label_tag}}
{{ form.mailredirect }}
{{ form.mailredirect.errors }}
</div>
</div>
<footer>
<a
href=
"{% url 'compte:afficher' %}"
class=
"button-cancel"
>
Retour à mon compte
</a>
<input
type=
"submit"
value=
"Enregistrer"
>
</footer>
</form>
{% endblock %}
Write
Preview
Markdown
is supported
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