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
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
7aa69ab6
Commit
7aa69ab6
authored
Aug 26, 2017
by
Gabriel Detraz
Committed by
root
Aug 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reglages nom du site et emailfrom dans preferences
parent
0719e89a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
107 additions
and
29 deletions
+107
-29
machines/models.py
machines/models.py
+0
-2
preferences/migrations/0012_generaloption_req_expire_hrs.py
preferences/migrations/0012_generaloption_req_expire_hrs.py
+20
-0
preferences/migrations/0013_generaloption_site_name.py
preferences/migrations/0013_generaloption_site_name.py
+20
-0
preferences/migrations/0014_generaloption_email_from.py
preferences/migrations/0014_generaloption_email_from.py
+20
-0
preferences/models.py
preferences/models.py
+3
-0
preferences/templates/preferences/display_preferences.html
preferences/templates/preferences/display_preferences.html
+8
-0
re2o/context_processors.py
re2o/context_processors.py
+3
-2
re2o/settings_local.example.py
re2o/settings_local.example.py
+0
-15
topologie/migrations/0023_auto_20170826_1530.py
topologie/migrations/0023_auto_20170826_1530.py
+20
-0
users/models.py
users/models.py
+4
-3
users/views.py
users/views.py
+9
-7
No files found.
machines/models.py
View file @
7aa69ab6
...
...
@@ -33,8 +33,6 @@ import re
from
reversion
import
revisions
as
reversion
from
datetime
import
timedelta
from
re2o.settings
import
MAIN_EXTENSION
class
Machine
(
models
.
Model
):
""" Class définissant une machine, object parent user, objets fils interfaces"""
...
...
preferences/migrations/0012_generaloption_req_expire_hrs.py
0 → 100644
View file @
7aa69ab6
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-26 13:30
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0011_auto_20170825_2307'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'generaloption'
,
name
=
'req_expire_hrs'
,
field
=
models
.
IntegerField
(
default
=
48
),
),
]
preferences/migrations/0013_generaloption_site_name.py
0 → 100644
View file @
7aa69ab6
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-26 13:40
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0012_generaloption_req_expire_hrs'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'generaloption'
,
name
=
'site_name'
,
field
=
models
.
CharField
(
default
=
'Re2o'
,
max_length
=
32
),
),
]
preferences/migrations/0014_generaloption_email_from.py
0 → 100644
View file @
7aa69ab6
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-26 13:58
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0013_generaloption_site_name'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'generaloption'
,
name
=
'email_from'
,
field
=
models
.
EmailField
(
default
=
'www-data@serveur.net'
,
max_length
=
254
),
),
]
preferences/models.py
View file @
7aa69ab6
...
...
@@ -56,6 +56,9 @@ class GeneralOption(models.Model):
search_display_page
=
models
.
IntegerField
(
default
=
15
)
pagination_number
=
models
.
IntegerField
(
default
=
25
)
pagination_large_number
=
models
.
IntegerField
(
default
=
8
)
req_expire_hrs
=
models
.
IntegerField
(
default
=
48
)
site_name
=
models
.
CharField
(
max_length
=
32
,
default
=
"Re2o"
)
email_from
=
models
.
EmailField
(
default
=
"www-data@serveur.net"
)
class
Service
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
32
)
...
...
preferences/templates/preferences/display_preferences.html
View file @
7aa69ab6
...
...
@@ -97,6 +97,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<p>
</p>
<table
class=
"table table-striped"
>
<tr>
<th>
Nom du site web
</th>
<td>
{{ generaloptions.site_name }}
</td>
<th>
Adresse mail d'expedition automatique
</th>
<td>
{{ generaloptions.email_from }}
</td>
</tr>
<tr>
<th>
Affichage de résultats dans le champ de recherche
</th>
<td>
{{ generaloptions.search_display_page }}
</td>
...
...
@@ -106,6 +112,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<th>
Nombre d'items affichés en liste (taille élevée)
</th>
<td>
{{ generaloptions.pagination_large_number }}
</td>
<th>
Temps avant expiration du lien de reinitialisation de mot de passe (en heures)
</th>
<td>
{{ generaloptions.req_expire_hrs }}
</td>
</tr>
</table>
<h4>
Données de l'association
</h4>
...
...
re2o/context_processors.py
View file @
7aa69ab6
...
...
@@ -21,9 +21,10 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from
machines.models
import
Interface
,
Machine
from
.settings
import
SITE_NAME
from
preferences.models
import
GeneralOption
def
context_user
(
request
):
general_options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
user
=
request
.
user
if
user
.
is_authenticated
():
interfaces
=
user
.
user_interfaces
()
...
...
@@ -50,5 +51,5 @@ def context_user(request):
'is_infra'
:
is_infra
,
'is_admin'
:
is_admin
,
'interfaces'
:
interfaces
,
'site_name'
:
SITE_NAME
,
'site_name'
:
general_options
.
site_name
,
}
re2o/settings_local.example.py
View file @
7aa69ab6
...
...
@@ -59,23 +59,8 @@ CSRF_COOKIE_HTTPONLY = True
X_FRAME_OPTIONS
=
'DENY'
SESSION_COOKIE_AGE
=
60
*
60
*
3
# Association information
SITE_NAME
=
"Re2o.rez"
# Main extension used in asso
MAIN_EXTENSION
=
".rez"
LOGO_PATH
=
"static_files/logo.png"
# Number of hours a token remains valid after having been created. Numeric and string
# versions should have the same meaning.
REQ_EXPIRE_HRS
=
48
REQ_EXPIRE_STR
=
'48 heures'
# Email `From` field
EMAIL_FROM
=
'www-data@serveur.net'
EMAIL_HOST
=
'smtp.example.org'
# Reglages pour la bdd ldap
...
...
topologie/migrations/0023_auto_20170826_1530.py
0 → 100644
View file @
7aa69ab6
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-26 13:30
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'topologie'
,
'0022_auto_20161211_1622'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'port'
,
name
=
'radius'
,
field
=
models
.
CharField
(
choices
=
[(
'NO'
,
'NO'
),
(
'STRICT'
,
'STRICT'
),
(
'BLOQ'
,
'BLOQ'
),
(
'COMMON'
,
'COMMON'
),
(
'3'
,
'3'
),
(
'7'
,
'7'
),
(
'8'
,
'8'
),
(
'13'
,
'13'
),
(
'20'
,
'20'
),
(
'42'
,
'42'
),
(
'69'
,
'69'
)],
default
=
'NO'
,
max_length
=
32
),
),
]
users/models.py
View file @
7aa69ab6
...
...
@@ -33,7 +33,7 @@ from django.db import transaction
import
ldapdb.models
import
ldapdb.models.fields
from
re2o.settings
import
RIGHTS_LINK
,
REQ_EXPIRE_HRS
,
LDAP
,
GID_RANGES
,
UID_RANGES
from
re2o.settings
import
RIGHTS_LINK
,
LDAP
,
GID_RANGES
,
UID_RANGES
import
re
,
uuid
import
datetime
...
...
@@ -44,7 +44,7 @@ from django.core.validators import MinLengthValidator
from
topologie.models
import
Room
from
cotisations.models
import
Cotisation
,
Facture
,
Paiement
,
Vente
from
machines.models
import
Interface
,
Machine
from
preferences.models
import
OptionalUser
from
preferences.models
import
GeneralOption
,
OptionalUser
now
=
timezone
.
now
()
...
...
@@ -622,8 +622,9 @@ class Request(models.Model):
def
save
(
self
):
if
not
self
.
expires_at
:
options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
self
.
expires_at
=
timezone
.
now
()
\
+
datetime
.
timedelta
(
hours
=
REQ_EXPIRE_HRS
)
+
datetime
.
timedelta
(
hours
=
options
.
req_expire_hrs
)
if
not
self
.
token
:
self
.
token
=
str
(
uuid
.
uuid4
()).
replace
(
'-'
,
''
)
# remove hyphens
super
(
Request
,
self
).
save
()
...
...
users/views.py
View file @
7aa69ab6
...
...
@@ -47,7 +47,6 @@ from users.forms import MassArchiveForm, PassForm, ResetPasswordForm
from
preferences.models
import
OptionalUser
,
AssoOption
,
GeneralOption
from
re2o.login
import
hashNT
from
re2o.settings
import
REQ_EXPIRE_STR
,
EMAIL_FROM
,
SITE_NAME
def
form
(
ctx
,
template
,
request
):
...
...
@@ -74,21 +73,23 @@ def password_change_action(u_form, user, request, req=False):
def
reset_passwd_mail
(
req
,
request
):
""" Prend en argument un request, envoie un mail de réinitialisation de mot de pass """
t
=
loader
.
get_template
(
'users/email_passwd_request'
)
options
,
created
=
AssoOption
.
objects
.
get_or_create
()
options
,
created
=
AssoOption
.
objects
.
get_or_create
()
general_options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
c
=
{
'name'
:
str
(
req
.
user
.
name
)
+
' '
+
str
(
req
.
user
.
surname
),
'asso'
:
options
.
name
,
'asso_mail'
:
options
.
contact
,
'site_name'
:
SITE_NAME
,
'site_name'
:
general_options
.
site_name
,
'url'
:
request
.
build_absolute_uri
(
reverse
(
'users:process'
,
kwargs
=
{
'token'
:
req
.
token
})),
'expire_in'
:
REQ_EXPIRE_STR
,
'expire_in'
:
str
(
general_options
.
req_expire_hrs
)
+
' heures'
,
}
send_mail
(
'Changement de mot de passe du Rézo Metz / Password renewal for Rézo Metz'
,
t
.
render
(
c
),
EMAIL_FROM
,
[
req
.
user
.
email
],
fail_silently
=
False
)
general_options
.
email_from
,
[
req
.
user
.
email
],
fail_silently
=
False
)
return
def
notif_ban
(
ban
):
general_options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
""" Prend en argument un objet ban, envoie un mail de notification """
t
=
loader
.
get_template
(
'users/email_ban_notif'
)
c
=
Context
({
...
...
@@ -97,13 +98,14 @@ def notif_ban(ban):
'date_end'
:
ban
.
date_end
,
})
send_mail
(
'Deconnexion disciplinaire'
,
t
.
render
(
c
),
EMAIL_FROM
,
[
ban
.
user
.
email
],
fail_silently
=
False
)
general_options
.
email_from
,
[
ban
.
user
.
email
],
fail_silently
=
False
)
return
def
notif_inscription
(
user
):
""" Prend en argument un objet user, envoie un mail de bienvenue """
t
=
loader
.
get_template
(
'users/email_welcome'
)
options
,
created
=
AssoOption
.
objects
.
get_or_create
()
general_options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
c
=
Context
({
'nom'
:
str
(
user
.
name
)
+
' '
+
str
(
user
.
surname
),
'asso_name'
:
options
.
name
,
...
...
@@ -111,7 +113,7 @@ def notif_inscription(user):
'pseudo'
:
user
.
pseudo
,
})
send_mail
(
'Bienvenue au Rézo / Welcome to Rézo Metz'
,
''
,
EMAIL_FROM
,
[
user
.
email
],
html_message
=
t
.
render
(
c
))
general_options
.
email_from
,
[
user
.
email
],
html_message
=
t
.
render
(
c
))
return
...
...
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