forked from ScoDoc/ScoDoc
Compare commits
6 Commits
e90f3077f8
...
c0363f6bd1
Author | SHA1 | Date | |
---|---|---|---|
c0363f6bd1 | |||
86ef24586d | |||
c5904d75a8 | |||
7010aefab3 | |||
|
6e72f35334 | ||
7866743eb8 |
|
@ -16,15 +16,32 @@ def departements():
|
||||||
"""
|
"""
|
||||||
Retourne la liste des ids de départements visibles
|
Retourne la liste des ids de départements visibles
|
||||||
|
|
||||||
Exemple de résultat : [2, 5, 8, 1, 4, 18]
|
Exemple de résultat :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"acronym": "TAPI",
|
||||||
|
"description": null,
|
||||||
|
"visible": true,
|
||||||
|
"date_creation": "Fri, 15 Apr 2022 12:19:28 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"acronym": "MMI",
|
||||||
|
"description": null,
|
||||||
|
"visible": false,
|
||||||
|
"date_creation": "Fri, 18 Apr 2022 11:20:8 GMT"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
# Récupération de tous les départements
|
# Récupération de tous les départements
|
||||||
depts = models.Departement.query.filter_by(visible=True)
|
depts = models.Departement.query.all()
|
||||||
|
|
||||||
# Mise en place de la liste avec tous les ids de départements
|
# Mise en place de la liste avec tous les départements
|
||||||
depts_ids = [d.id for d in depts]
|
data = [d.to_dict() for d in depts]
|
||||||
|
|
||||||
return jsonify(depts_ids)
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departements/<string:dept>/etudiants/liste", methods=["GET"])
|
@bp.route("/departements/<string:dept>/etudiants/liste", methods=["GET"])
|
||||||
|
|
|
@ -50,6 +50,7 @@ from app.entreprises.models import (
|
||||||
Entreprise,
|
Entreprise,
|
||||||
EntrepriseCorrespondant,
|
EntrepriseCorrespondant,
|
||||||
EntreprisePreferences,
|
EntreprisePreferences,
|
||||||
|
EntrepriseSite,
|
||||||
)
|
)
|
||||||
from app.models import Identite, Departement
|
from app.models import Identite, Departement
|
||||||
from app.auth.models import User
|
from app.auth.models import User
|
||||||
|
@ -171,6 +172,7 @@ class EntrepriseModificationForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class SiteCreationForm(FlaskForm):
|
class SiteCreationForm(FlaskForm):
|
||||||
|
hidden_entreprise_id = HiddenField()
|
||||||
nom = _build_string_field("Nom du site (*)")
|
nom = _build_string_field("Nom du site (*)")
|
||||||
adresse = _build_string_field("Adresse (*)")
|
adresse = _build_string_field("Adresse (*)")
|
||||||
codepostal = _build_string_field("Code postal (*)")
|
codepostal = _build_string_field("Code postal (*)")
|
||||||
|
@ -178,6 +180,49 @@ class SiteCreationForm(FlaskForm):
|
||||||
pays = _build_string_field("Pays", required=False)
|
pays = _build_string_field("Pays", required=False)
|
||||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
validate = True
|
||||||
|
if not FlaskForm.validate(self):
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
site = EntrepriseSite.query.filter_by(
|
||||||
|
entreprise_id=self.hidden_entreprise_id.data, nom=self.nom.data
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if site is not None:
|
||||||
|
self.nom.errors.append("Ce site existe déjà (même nom)")
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
|
|
||||||
|
class SiteModificationForm(FlaskForm):
|
||||||
|
hidden_entreprise_id = HiddenField()
|
||||||
|
hidden_site_id = HiddenField()
|
||||||
|
nom = _build_string_field("Nom du site (*)")
|
||||||
|
adresse = _build_string_field("Adresse (*)")
|
||||||
|
codepostal = _build_string_field("Code postal (*)")
|
||||||
|
ville = _build_string_field("Ville (*)")
|
||||||
|
pays = _build_string_field("Pays", required=False)
|
||||||
|
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
validate = True
|
||||||
|
if not FlaskForm.validate(self):
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
site = EntrepriseSite.query.filter(
|
||||||
|
EntrepriseSite.entreprise_id == self.hidden_entreprise_id.data,
|
||||||
|
EntrepriseSite.id != self.hidden_site_id.data,
|
||||||
|
EntrepriseSite.nom == self.nom.data,
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if site is not None:
|
||||||
|
self.nom.errors.append("Ce site existe déjà (même nom)")
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
|
|
||||||
class MultiCheckboxField(SelectMultipleField):
|
class MultiCheckboxField(SelectMultipleField):
|
||||||
widget = ListWidget(prefix_label=False)
|
widget = ListWidget(prefix_label=False)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from app.entreprises.forms import (
|
||||||
EntrepriseCreationForm,
|
EntrepriseCreationForm,
|
||||||
EntrepriseModificationForm,
|
EntrepriseModificationForm,
|
||||||
SiteCreationForm,
|
SiteCreationForm,
|
||||||
|
SiteModificationForm,
|
||||||
SuppressionConfirmationForm,
|
SuppressionConfirmationForm,
|
||||||
OffreCreationForm,
|
OffreCreationForm,
|
||||||
OffreModificationForm,
|
OffreModificationForm,
|
||||||
|
@ -110,8 +111,9 @@ def correspondants():
|
||||||
Permet d'afficher une page avec la liste des correspondants des entreprises visibles et une liste des dernières opérations
|
Permet d'afficher une page avec la liste des correspondants des entreprises visibles et une liste des dernières opérations
|
||||||
"""
|
"""
|
||||||
correspondants = (
|
correspondants = (
|
||||||
db.session.query(EntrepriseCorrespondant, Entreprise)
|
db.session.query(EntrepriseCorrespondant, EntrepriseSite)
|
||||||
.join(Entreprise, EntrepriseCorrespondant.entreprise_id == Entreprise.id)
|
.join(EntrepriseSite, EntrepriseCorrespondant.site_id == EntrepriseSite.id)
|
||||||
|
.join(Entreprise, EntrepriseSite.entreprise_id == Entreprise.id)
|
||||||
.filter_by(visible=True, active=True)
|
.filter_by(visible=True, active=True)
|
||||||
)
|
)
|
||||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
||||||
|
@ -700,7 +702,7 @@ def add_site(id):
|
||||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
||||||
description=f"entreprise {id} inconnue"
|
description=f"entreprise {id} inconnue"
|
||||||
)
|
)
|
||||||
form = SiteCreationForm()
|
form = SiteCreationForm(hidden_entreprise_id=id)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
site = EntrepriseSite(
|
site = EntrepriseSite(
|
||||||
entreprise_id=entreprise.id,
|
entreprise_id=entreprise.id,
|
||||||
|
@ -721,6 +723,38 @@ def add_site(id):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route(
|
||||||
|
"/fiche_entreprise/<int:id_entreprise>/edit_site/<int:id_site>",
|
||||||
|
methods=["GET", "POST"],
|
||||||
|
)
|
||||||
|
def edit_site(id_entreprise, id_site):
|
||||||
|
site = EntrepriseSite.query.filter_by(
|
||||||
|
id=id_site, entreprise_id=id_entreprise
|
||||||
|
).first_or_404(description=f"site {id_site} inconnu")
|
||||||
|
form = SiteModificationForm(
|
||||||
|
hidden_entreprise_id=id_entreprise, hidden_site_id=id_site
|
||||||
|
)
|
||||||
|
if form.validate_on_submit():
|
||||||
|
site.nom = form.nom.data.strip()
|
||||||
|
site.adresse = form.adresse.data.strip()
|
||||||
|
site.codepostal = form.codepostal.data.strip()
|
||||||
|
site.ville = form.ville.data.strip()
|
||||||
|
site.pays = (form.pays.data.strip() if form.pays.data.strip() else "FRANCE",)
|
||||||
|
db.session.commit()
|
||||||
|
return redirect(url_for("entreprises.fiche_entreprise", id=site.entreprise_id))
|
||||||
|
elif request.method == "GET":
|
||||||
|
form.nom.data = site.nom
|
||||||
|
form.adresse.data = site.adresse
|
||||||
|
form.codepostal.data = site.codepostal
|
||||||
|
form.ville.data = site.ville
|
||||||
|
form.pays.data = site.pays
|
||||||
|
return render_template(
|
||||||
|
"entreprises/form.html",
|
||||||
|
title="Modification site",
|
||||||
|
form=form,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
"/fiche_entreprise/<int:id_entreprise>/add_correspondant/<int:id_site>",
|
"/fiche_entreprise/<int:id_entreprise>/add_correspondant/<int:id_site>",
|
||||||
methods=["GET", "POST"],
|
methods=["GET", "POST"],
|
||||||
|
|
|
@ -423,17 +423,19 @@ def list_abs_date(etudid, beg_date=None, end_date=None):
|
||||||
print("On rentre")
|
print("On rentre")
|
||||||
cnx = ndb.GetDBConnexion()
|
cnx = ndb.GetDBConnexion()
|
||||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||||
print("Juste avant le SQL")
|
|
||||||
|
|
||||||
cursor.execute(
|
req = """SELECT jour, matin, estabs, estjust, description
|
||||||
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
|
FROM ABSENCES A
|
||||||
WHERE A.ETUDID = %(etudid)s"""
|
WHERE A.ETUDID = %(etudid)s""" + (
|
||||||
+ ""
|
""
|
||||||
if beg_date is None
|
if beg_date is None
|
||||||
else """
|
else """
|
||||||
AND A.jour >= %(beg_date)s
|
AND A.jour >= %(beg_date)s
|
||||||
AND A.jour <= %(end_date)s
|
AND A.jour <= %(end_date)s
|
||||||
""",
|
"""
|
||||||
|
)
|
||||||
|
cursor.execute(
|
||||||
|
req,
|
||||||
vars(),
|
vars(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<td>{{ correspondant[0].mail }}</td>
|
<td>{{ correspondant[0].mail }}</td>
|
||||||
<td>{{ correspondant[0].poste}}</td>
|
<td>{{ correspondant[0].poste}}</td>
|
||||||
<td>{{ correspondant[0].service}}</td>
|
<td>{{ correspondant[0].service}}</td>
|
||||||
<td><a href="{{ url_for('entreprises.fiche_entreprise', id=correspondant[1].id) }}">{{ correspondant[1].nom }}</a></td>
|
<td><a href="{{ url_for('entreprises.fiche_entreprise', id=correspondant[1].entreprise_id) }}">{{ correspondant[1].nom }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -61,7 +61,10 @@
|
||||||
Ville : {{ site.ville }}<br>
|
Ville : {{ site.ville }}<br>
|
||||||
Pays : {{ site.pays }}
|
Pays : {{ site.pays }}
|
||||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||||
<br><a class="btn btn-primary" href="{{ url_for('entreprises.add_correspondant', id_entreprise=entreprise.id, id_site=site.id) }}">Ajouter correspondant</a>
|
<div>
|
||||||
|
<a class="btn btn-primary" href="{{ url_for('entreprises.edit_site', id_entreprise=entreprise.id, id_site=site.id) }}">Modifier</a>
|
||||||
|
<a class="btn btn-primary" href="{{ url_for('entreprises.add_correspondant', id_entreprise=entreprise.id, id_site=site.id) }}">Ajouter correspondant</a>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesCorrespondants, None) %}
|
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesCorrespondants, None) %}
|
||||||
{% for correspondant in site.correspondants %}
|
{% for correspondant in site.correspondants %}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.2.13"
|
SCOVERSION = "9.2.14"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user