forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
64
app/forms/main/create_bug_report.py
Normal file
64
app/forms/main/create_bug_report.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- mode: python -*-
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# ScoDoc
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
"""
|
||||||
|
Formulaire création de ticket de bug
|
||||||
|
"""
|
||||||
|
|
||||||
|
from flask_wtf import FlaskForm
|
||||||
|
from wtforms import SubmitField, validators
|
||||||
|
from wtforms.fields.simple import StringField, TextAreaField, BooleanField
|
||||||
|
from app.scodoc import sco_preferences
|
||||||
|
|
||||||
|
|
||||||
|
class CreateBugReport(FlaskForm):
|
||||||
|
"""Formulaire permettant la création d'un ticket de bug"""
|
||||||
|
|
||||||
|
title = StringField(
|
||||||
|
label="Titre du ticket",
|
||||||
|
validators=[
|
||||||
|
validators.DataRequired("titre du ticket requis"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
message = TextAreaField(
|
||||||
|
label="Message",
|
||||||
|
id="ticket_message",
|
||||||
|
validators=[
|
||||||
|
validators.DataRequired("message du ticket requis"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
etab = StringField(label="Etablissement")
|
||||||
|
include_dump = BooleanField(
|
||||||
|
"Inclure une copie anonymisée de la base de données ? (ces données permettent aux développeur·euse·s de reproduire l'erreur rencontrée)",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
submit = SubmitField("Envoyer")
|
||||||
|
cancel = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(CreateBugReport, self).__init__(*args, **kwargs)
|
||||||
|
self.etab.data = sco_preferences.get_preference("InstituteName") or ""
|
19
app/templates/sco_bug_report.j2
Normal file
19
app/templates/sco_bug_report.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{# -*- mode: jinja-html -*- #}
|
||||||
|
{% extends 'base.j2' %}
|
||||||
|
{% import 'wtf.j2' as wtf %}
|
||||||
|
|
||||||
|
{% block app_content %}
|
||||||
|
<h2>Assistance technique</h2>
|
||||||
|
<p class="help">
|
||||||
|
Ce formulaire permet d'effectuer une demande d'assistance technique.<br>
|
||||||
|
Son <b>contenu sera accessible publiquement</b> sur scodoc.org, veuillez donc ne pas y inclure d'informations sensibles.<br>
|
||||||
|
L'adresse email associée à votre compte ScoDoc est automatiquement transmise avec votre demande mais ne sera pas
|
||||||
|
affichée publiquement.<br>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ wtf.quick_form(form) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock app_content %}
|
@ -110,6 +110,7 @@ from app.scodoc import (
|
|||||||
sco_up_to_date,
|
sco_up_to_date,
|
||||||
)
|
)
|
||||||
from app.tables import list_etuds
|
from app.tables import list_etuds
|
||||||
|
from app.forms.main.create_bug_report import CreateBugReport
|
||||||
|
|
||||||
|
|
||||||
def sco_publish(route, function, permission, methods=["GET"]):
|
def sco_publish(route, function, permission, methods=["GET"]):
|
||||||
@ -2562,77 +2563,42 @@ def sco_dump_and_send_db(message="", request_url="", traceback_str_base64=""):
|
|||||||
|
|
||||||
|
|
||||||
# --- Report form (assistance)
|
# --- Report form (assistance)
|
||||||
@bp.route("/sco_bug_report", methods=["GET"])
|
@bp.route("/sco_bug_report", methods=["GET", "POST"])
|
||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
def sco_bug_report_form():
|
def sco_bug_report_form():
|
||||||
"Formulaire de création d'un ticket d'assistance"
|
"Formulaire de création d'un ticket d'assistance"
|
||||||
|
|
||||||
H = [
|
form = CreateBugReport()
|
||||||
html_sco_header.sco_header(page_title="Assistance technique"),
|
if request.method == "POST" and form.cancel.data: # cancel button
|
||||||
"""<h2>Assistance technique</h2>
|
return redirect(url_for("scodoc.index"))
|
||||||
<p>
|
if form.validate_on_submit():
|
||||||
Ce formulaire permet d'effectuer une demande d'assistance technique.<br>
|
r = sco_bug_report.sco_bug_report(
|
||||||
Son <b>contenu sera accessible publiquement</b> sur scodoc.org, veuillez donc ne pas y inclure d'informations sensibles.<br>
|
form.title.data, form.message.data, form.etab.data, form.include_dump.data
|
||||||
L'adresse email associée à votre compte ScoDoc est automatiquement transmise avec votre demande mais ne sera pas
|
)
|
||||||
affichée publiquement.<br>
|
|
||||||
</p>
|
|
||||||
<form method="POST">
|
|
||||||
<label for="title">Titre du ticket</label><span style="color: red;">*</span><br>
|
|
||||||
<input type="text" name="title" id="title" required><br>
|
|
||||||
<label for="message">Message</label><span style="color: red;">*</span><br>
|
|
||||||
<textarea name="message" rows="10" cols="45" required></textarea><br>
|
|
||||||
<label for="etab" >Établissement</label><br>
|
|
||||||
""",
|
|
||||||
]
|
|
||||||
|
|
||||||
H.append(
|
status_code = r.status_code
|
||||||
'<input type="text" name="etab" value="'
|
try:
|
||||||
+ (sco_preferences.get_preference("InstituteName") or "")
|
r_msg = r.json()["message"]
|
||||||
+ '"><br>'
|
except (requests.exceptions.JSONDecodeError, KeyError):
|
||||||
|
r_msg = (
|
||||||
|
"Erreur: code <tt>"
|
||||||
|
+ str(status_code)
|
||||||
|
+ '</tt> Merci de contacter <a href="mailto:'
|
||||||
|
+ scu.SCO_DEV_MAIL
|
||||||
|
+ '">'
|
||||||
|
+ scu.SCO_DEV_MAIL
|
||||||
|
+ "</a>"
|
||||||
|
)
|
||||||
|
|
||||||
|
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
||||||
|
if r.status_code >= 200 and r.status_code < 300:
|
||||||
|
H.append(f"""<p>Opération effectuée.</p><p>{r_msg}</p>""")
|
||||||
|
else:
|
||||||
|
H.append(f"""<p class="warning">{r_msg}</p>""")
|
||||||
|
return "\n".join(H) + html_sco_header.sco_footer()
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"sco_bug_report.j2",
|
||||||
|
form=form,
|
||||||
)
|
)
|
||||||
|
|
||||||
H.append(
|
|
||||||
"""
|
|
||||||
<input type="checkbox" name="include_dump">
|
|
||||||
<label for="include_dump">Inclure une copie anonymisée des données ? (ces données permettent aux développeur·euse·s de reproduire l'erreur rencontrée)</label><br><br>
|
|
||||||
<input type="submit" value="Envoyer">
|
|
||||||
</form>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
return "\n".join(H) + html_sco_header.sco_footer()
|
|
||||||
|
|
||||||
|
|
||||||
# --- Report create (assistance)
|
|
||||||
@bp.route("/sco_bug_report", methods=["POST"])
|
|
||||||
@scodoc
|
|
||||||
@permission_required(Permission.ScoView)
|
|
||||||
@scodoc7func
|
|
||||||
def sco_bug_report_create(title=None, message=None, etab="", include_dump=False):
|
|
||||||
"Création d'un ticket d'assistance"
|
|
||||||
|
|
||||||
if not title or not message:
|
|
||||||
flash("Les champs titre et message sont obligatoires.")
|
|
||||||
return flask.redirect(url_for("scolar.sco_bug_report"))
|
|
||||||
|
|
||||||
r = sco_bug_report.sco_bug_report(title, message, etab, include_dump)
|
|
||||||
|
|
||||||
status_code = r.status_code
|
|
||||||
try:
|
|
||||||
r_msg = r.json()["message"]
|
|
||||||
except (requests.exceptions.JSONDecodeError, KeyError):
|
|
||||||
r_msg = "Erreur: code <tt>"
|
|
||||||
+status_code
|
|
||||||
+'</tt> Merci de contacter <a href="mailto:'
|
|
||||||
+scu.SCO_DEV_MAIL
|
|
||||||
+'">'
|
|
||||||
+scu.SCO_DEV_MAIL
|
|
||||||
+"</a>"
|
|
||||||
|
|
||||||
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
|
||||||
if r.status_code >= 200 and r.status_code < 300:
|
|
||||||
H.append(f"""<p>Opération effectuée.</p><p>{r_msg}</p>""")
|
|
||||||
else:
|
|
||||||
H.append(f"""<p class="warning">{r_msg}</p>""")
|
|
||||||
return "\n".join(H) + html_sco_header.sco_footer()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user