Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
T
training_survey
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
training
training_survey
Validations
80323c12
Valider
80323c12
rédigé
Il y a 9 mois
par
Julien - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[UPD] use super in survey_start
parent
aeda5f94
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!2
[UPD] add student registration process
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
controllers/main.py
+23
-38
23 ajouts, 38 suppressions
controllers/main.py
avec
23 ajouts
et
38 suppressions
controllers/main.py
+
23
−
38
Voir le fichier @
80323c12
...
...
@@ -13,54 +13,39 @@ _logger = logging.getLogger(__name__)
class
TrainingSurvey
(
Survey
):
#
# ------------------------------------------------------------
# TAKING SURVEY ROUTES
# ------------------------------------------------------------
@http.route
(
'
/survey/start/<string:survey_token>
'
,
type
=
'
http
'
,
auth
=
'
public
'
,
website
=
True
)
@http.route
(
"
/survey/start/<string:survey_token>
"
,
type
=
"
http
"
,
auth
=
"
public
"
,
website
=
True
)
def
survey_start
(
self
,
survey_token
,
answer_token
=
None
,
email
=
False
,
**
post
):
"""
Start a survey by providing
* a token linked to a survey;
* a token linked to an answer or generate a new token if access is allowed;
"""
# Get the current answer token from cookie
answer_from_cookie
=
False
if
not
answer_token
:
answer_token
=
request
.
httprequest
.
cookies
.
get
(
'
survey_%s
'
%
survey_token
)
answer_from_cookie
=
bool
(
answer_token
)
access_data
=
self
.
_get_access_data
(
survey_token
,
answer_token
,
ensure_token
=
False
)
if
answer_from_cookie
and
access_data
[
'
validity_code
'
]
in
(
'
answer_wrong_user
'
,
'
token_wrong
'
):
# If the cookie had been generated for another user or does not correspond to any existing answer object
# (probably because it has been deleted), ignore it and redo the check.
# The cookie will be replaced by a legit value when resolving the URL, so we don't clean it further here.
access_data
=
self
.
_get_access_data
(
survey_token
,
None
,
ensure_token
=
False
)
if
access_data
[
'
validity_code
'
]
is
not
True
:
return
self
.
_redirect_with_error
(
access_data
,
access_data
[
'
validity_code
'
])
survey_sudo
,
answer_sudo
=
access_data
[
'
survey_sudo
'
],
access_data
[
'
answer_sudo
'
]
if
not
answer_sudo
:
try
:
answer_sudo
=
survey_sudo
.
_create_answer
(
user
=
request
.
env
.
user
,
email
=
email
)
except
UserError
:
answer_sudo
=
False
if
not
answer_sudo
:
try
:
survey_sudo
.
with_user
(
request
.
env
.
user
).
check_access_rights
(
'
read
'
)
survey_sudo
.
with_user
(
request
.
env
.
user
).
check_access_rule
(
'
read
'
)
except
:
return
request
.
redirect
(
"
/
"
)
else
:
return
request
.
render
(
"
survey.survey_403_page
"
,
{
'
survey
'
:
survey_sudo
})
page
=
super
().
survey_start
(
survey_token
=
survey_token
,
answer_token
=
None
,
email
=
False
,
**
post
)
answer_sudo
=
(
request
.
env
[
"
survey.user_input
"
]
.
sudo
()
.
search
([(
"
access_token
"
,
"
=
"
,
page
.
location
.
split
(
"
/
"
)[
-
1
])])
)
survey_sudo
=
(
request
.
env
[
"
survey.survey
"
]
.
sudo
()
.
search
([(
"
access_token
"
,
"
=
"
,
page
.
location
.
split
(
"
/
"
)[
-
2
])])
)
training_id
=
post
.
get
(
"
training_id
"
)
if
training_id
:
training
=
request
.
env
[
"
training.training
"
].
browse
(
int
(
training_id
))
if
training
and
training
.
registration_survey_id
==
survey_sudo
:
answer_sudo
.
training_id
=
training
return
request
.
redirect
(
'
/survey/%s/%s
'
%
(
survey_sudo
.
access_token
,
answer_sudo
.
access_token
))
return
page
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter