1
0
Fork 0

Merge branch 'entreprises' of https://scodoc.org/git/arthur.zhu/ScoDoc into entreprises

This commit is contained in:
Emmanuel Viennet 2022-09-14 23:03:26 +02:00
commit 0657bf0cb2
14 changed files with 504 additions and 311 deletions

View File

@ -29,6 +29,7 @@ from config import Config
import re import re
import requests import requests
import glob import glob
from datetime import date
from flask import flash from flask import flash
from flask_login import current_user from flask_login import current_user
@ -117,6 +118,9 @@ def get_dept_id_by_acronym(acronym: str):
def get_dept_acronym_by_id(id: int): def get_dept_acronym_by_id(id: int):
"""
Retourne l'acronym d'un departement a l'aide de son id
"""
dept = Departement.query.filter_by(id=id).first() dept = Departement.query.filter_by(id=id).first()
if dept is not None: if dept is not None:
return dept.acronym return dept.acronym
@ -137,7 +141,7 @@ def check_offre_depts(depts: list, offre_depts: list):
def get_offre_files_and_depts(offre: EntrepriseOffre, depts: list): def get_offre_files_and_depts(offre: EntrepriseOffre, depts: list):
""" """
Retourne l'offre, les fichiers attachés a l'offre et les département liés Retourne l'offre, les fichiers attachés a l'offre, les département liés a l'offre et le correspondant
""" """
offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all() offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all()
correspondant = EntrepriseCorrespondant.query.filter_by( correspondant = EntrepriseCorrespondant.query.filter_by(
@ -162,6 +166,42 @@ def get_offre_files_and_depts(offre: EntrepriseOffre, depts: list):
return None return None
def get_offres_non_expirees_with_files(offres):
"""
Retourne une liste avec toutes les offres non expirées (offre, files, offre_depts, correspondant)
"""
depts = get_depts()
offres_with_files = []
for offre in offres:
if not offre.expired and (
offre.expiration_date is None
or (
offre.expiration_date is not None
and date.today() < offre.expiration_date
)
):
offre_with_files = get_offre_files_and_depts(offre, depts)
if offre_with_files is not None:
offres_with_files.append(offre_with_files)
return offres_with_files
def get_offres_expirees_with_files(offres):
"""
Retourne une liste avec toutes les offres expirées (offre, files, offre_depts, correspondant)
"""
depts = get_depts()
offres_with_files = []
for offre in offres:
if offre.expired or (
offre.expiration_date is not None and date.today() > offre.expiration_date
):
offre_with_files = get_offre_files_and_depts(offre, depts)
if offre_with_files is not None:
offres_with_files.append(offre_with_files)
return offres_with_files
def send_email_notifications_entreprise(subject: str, entreprise: Entreprise): def send_email_notifications_entreprise(subject: str, entreprise: Entreprise):
txt = [ txt = [
"Une entreprise est en attente de validation", "Une entreprise est en attente de validation",
@ -186,6 +226,7 @@ def send_email_notifications_entreprise(subject: str, entreprise: Entreprise):
def get_excel_book_are(export: bool = False): def get_excel_book_are(export: bool = False):
""" """
Retourne un Excel avec les 3 feuilles "Entreprises", "Sites" et "Correspondants" Retourne un Excel avec les 3 feuilles "Entreprises", "Sites" et "Correspondants"
si export est True, remplit les feuilles avec les données a exporter
""" """
entreprises_titles = ENTREPRISES_KEYS[:] entreprises_titles = ENTREPRISES_KEYS[:]
sites_titles = SITES_KEYS[:] sites_titles = SITES_KEYS[:]
@ -450,7 +491,7 @@ def check_sites_import(m):
def check_site_import(site_data): def check_site_import(site_data):
""" """
Verifie les données d'une ligne Excel (sites) Verifie les données d'une ligne Excel (site)
""" """
champs_obligatoires = [ champs_obligatoires = [
"siret_entreprise", "siret_entreprise",
@ -482,6 +523,9 @@ def check_site_import(site_data):
def check_correspondants_import(m): def check_correspondants_import(m):
"""
Verifie la feuille Excel "Correspondants" de l'importation données
"""
ligne = 1 ligne = 1
if m[0] != CORRESPONDANTS_KEYS: if m[0] != CORRESPONDANTS_KEYS:
flash( flash(
@ -557,6 +601,9 @@ def check_correspondant_import(correspondant_data):
def list_to_dict(m): def list_to_dict(m):
"""
Transforme une liste de liste (matrice) en liste de dictionnaire (key = premiere liste de la matrice)
"""
l = [] l = []
for data in m[1:]: for data in m[1:]:
new_dict = {title: value.strip() for title, value in zip(m[0], data)} new_dict = {title: value.strip() for title, value in zip(m[0], data)}

View File

@ -123,6 +123,7 @@ class EntrepriseCreationForm(FlaskForm):
notes = _build_string_field("Notes sur le correspondant", required=False) notes = _build_string_field("Notes sur le correspondant", required=False)
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -200,6 +201,7 @@ class EntrepriseModificationForm(FlaskForm):
ville = _build_string_field("Ville (*)") ville = _build_string_field("Ville (*)")
pays = _build_string_field("Pays", required=False) pays = _build_string_field("Pays", required=False)
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -245,6 +247,7 @@ class SiteCreationForm(FlaskForm):
ville = _build_string_field("Ville (*)") ville = _build_string_field("Ville (*)")
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)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -271,6 +274,7 @@ class SiteModificationForm(FlaskForm):
ville = _build_string_field("Ville (*)") ville = _build_string_field("Ville (*)")
pays = _build_string_field("Pays", required=False) pays = _build_string_field("Pays", required=False)
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -321,6 +325,7 @@ class OffreCreationForm(FlaskForm):
], ],
) )
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -368,6 +373,7 @@ class OffreModificationForm(FlaskForm):
expiration_date = DateField("Date expiration", validators=[Optional()]) expiration_date = DateField("Date expiration", validators=[Optional()])
correspondant = SelectField("Correspondant à contacté", validators=[Optional()]) correspondant = SelectField("Correspondant à contacté", validators=[Optional()])
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -450,7 +456,8 @@ class CorrespondantCreationForm(FlaskForm):
class CorrespondantsCreationForm(FlaskForm): class CorrespondantsCreationForm(FlaskForm):
hidden_site_id = HiddenField() hidden_site_id = HiddenField()
correspondants = FieldList(FormField(CorrespondantCreationForm), min_entries=1) correspondants = FieldList(FormField(CorrespondantCreationForm), min_entries=1)
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer")
cancel = SubmitField("Annuler")
def validate(self): def validate(self):
validate = True validate = True
@ -489,6 +496,7 @@ class CorrespondantsCreationForm(FlaskForm):
class CorrespondantModificationForm(FlaskForm): class CorrespondantModificationForm(FlaskForm):
hidden_correspondant_id = HiddenField() hidden_correspondant_id = HiddenField()
hidden_site_id = HiddenField() hidden_site_id = HiddenField()
hidden_entreprise_id = HiddenField()
civilite = SelectField( civilite = SelectField(
"Civilité (*)", "Civilité (*)",
choices=[("H", "Monsieur"), ("F", "Madame")], choices=[("H", "Monsieur"), ("F", "Madame")],
@ -505,7 +513,21 @@ class CorrespondantModificationForm(FlaskForm):
service = _build_string_field("Service", required=False) service = _build_string_field("Service", required=False)
origine = _build_string_field("Origine", required=False) origine = _build_string_field("Origine", required=False)
notes = _build_string_field("Notes", required=False) notes = _build_string_field("Notes", required=False)
site = SelectField(
"Site du correspondant", validators=[DataRequired()], description="Nom du site"
)
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.site.choices = [
(site.id, f"{site.nom}")
for site in db.session.query(EntrepriseSite)
.filter(EntrepriseSite.entreprise_id == self.hidden_entreprise_id.data)
.all()
]
def validate(self): def validate(self):
validate = True validate = True
@ -543,6 +565,7 @@ class ContactCreationForm(FlaskForm):
) )
notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)]) notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)])
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate_utilisateur(self, utilisateur): def validate_utilisateur(self, utilisateur):
utilisateur_data = self.utilisateur.data.upper().strip() utilisateur_data = self.utilisateur.data.upper().strip()
@ -569,6 +592,7 @@ class ContactModificationForm(FlaskForm):
) )
notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)]) notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)])
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate_utilisateur(self, utilisateur): def validate_utilisateur(self, utilisateur):
utilisateur_data = self.utilisateur.data.upper().strip() utilisateur_data = self.utilisateur.data.upper().strip()
@ -602,6 +626,7 @@ class StageApprentissageCreationForm(FlaskForm):
) )
notes = TextAreaField("Notes") notes = TextAreaField("Notes")
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -649,6 +674,7 @@ class StageApprentissageModificationForm(FlaskForm):
) )
notes = TextAreaField("Notes") notes = TextAreaField("Notes")
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -705,6 +731,7 @@ class TaxeApprentissageForm(FlaskForm):
) )
notes = TextAreaField("Notes") notes = TextAreaField("Notes")
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def validate(self): def validate(self):
validate = True validate = True
@ -738,6 +765,7 @@ class TaxeApprentissageModificationForm(FlaskForm):
) )
notes = TextAreaField("Notes") notes = TextAreaField("Notes")
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -755,7 +783,8 @@ class EnvoiOffreForm(FlaskForm):
), ),
min_entries=1, min_entries=1,
) )
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) submit = SubmitField("Envoyer")
cancel = SubmitField("Annuler")
def validate(self): def validate(self):
validate = True validate = True
@ -795,23 +824,28 @@ class AjoutFichierForm(FlaskForm):
], ],
) )
submit = SubmitField("Ajouter", render_kw=SUBMIT_MARGE) submit = SubmitField("Ajouter", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
class SuppressionConfirmationForm(FlaskForm): class SuppressionConfirmationForm(FlaskForm):
submit = SubmitField("Supprimer", render_kw=SUBMIT_MARGE) submit = SubmitField("Supprimer", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
class DesactivationConfirmationForm(FlaskForm): class DesactivationConfirmationForm(FlaskForm):
notes_active = TextAreaField("Notes sur la désactivation", validators=[Optional()]) notes_active = TextAreaField("Notes sur la désactivation", validators=[Optional()])
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
class ActivationConfirmationForm(FlaskForm): class ActivationConfirmationForm(FlaskForm):
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
class ValidationConfirmationForm(FlaskForm): class ValidationConfirmationForm(FlaskForm):
submit = SubmitField("Valider", render_kw=SUBMIT_MARGE) submit = SubmitField("Valider", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
class ImportForm(FlaskForm): class ImportForm(FlaskForm):
@ -833,3 +867,4 @@ class PreferencesForm(FlaskForm):
) )
check_siret = BooleanField("Vérification SIRET") check_siret = BooleanField("Vérification SIRET")
submit = SubmitField("Valider", render_kw=SUBMIT_MARGE) submit = SubmitField("Valider", render_kw=SUBMIT_MARGE)
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)

View File

@ -66,7 +66,7 @@ from werkzeug.utils import secure_filename
@permission_required(Permission.RelationsEntreprisesView) @permission_required(Permission.RelationsEntreprisesView)
def index(): def index():
""" """
Permet d'afficher une page avec la liste des entreprises (visible) et une liste des dernières opérations Permet d'afficher une page avec la liste des entreprises (visible et active) et une liste des dernières opérations
""" """
entreprises = Entreprise.query.filter_by(visible=True, active=True) entreprises = Entreprise.query.filter_by(visible=True, active=True)
logs = ( logs = (
@ -81,12 +81,12 @@ def index():
if checked[0]: if checked[0]:
entreprises = Entreprise.query.filter_by(visible=True) entreprises = Entreprise.query.filter_by(visible=True)
if checked[1]: if checked[1]:
entreprises = Entreprise.query.filter_by(association=True) entreprises = Entreprise.query.filter_by(visible=True, association=True)
if checked[2]: if checked[2]:
entreprises = Entreprise.query.filter_by(siret_provisoire=True) entreprises = Entreprise.query.filter_by(visible=True, siret_provisoire=True)
if checked[1] and checked[2]: if checked[1] and checked[2]:
entreprises = Entreprise.query.filter_by( entreprises = Entreprise.query.filter_by(
association=True, siret_provisoire=True visible=True, association=True, siret_provisoire=True
) )
return render_template( return render_template(
"entreprises/entreprises.html", "entreprises/entreprises.html",
@ -115,20 +115,6 @@ def logs():
) )
@bp.route("/validation", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesValidate)
def validation():
"""
Permet d'afficher une page avec la liste des entreprises a valider (non visible)
"""
entreprises = Entreprise.query.filter_by(visible=False).all()
return render_template(
"entreprises/entreprises_validation.html",
title="Validation entreprises",
entreprises=entreprises,
)
@bp.route("/correspondants", methods=["GET"]) @bp.route("/correspondants", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesCorrespondants) @permission_required(Permission.RelationsEntreprisesCorrespondants)
def correspondants(): def correspondants():
@ -155,80 +141,17 @@ def correspondants():
) )
@bp.route("/fiche_entreprise/<int:entreprise_id>", methods=["GET"]) @bp.route("/validation", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesView) @permission_required(Permission.RelationsEntreprisesValidate)
def fiche_entreprise(entreprise_id): def validation():
""" """
Permet d'afficher la fiche entreprise d'une entreprise avec une liste des dernières opérations et Permet d'afficher une page avec la liste des entreprises a valider (non visible)
l'historique des étudiants ayant réaliser un stage ou une alternance dans cette entreprise.
La fiche entreprise comporte les informations de l'entreprise, les correspondants de l'entreprise et
les offres de l'entreprise.
""" """
entreprise = Entreprise.query.filter_by( entreprises = Entreprise.query.filter_by(visible=False).all()
id=entreprise_id, visible=True
).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue")
offres_with_files = []
depts = are.get_depts()
for offre in entreprise.offres:
if not offre.expired and (
offre.expiration_date is None
or (
offre.expiration_date is not None
and date.today() < offre.expiration_date
)
):
offre_with_files = are.get_offre_files_and_depts(offre, depts)
if offre_with_files is not None:
offres_with_files.append(offre_with_files)
logs = (
EntrepriseHistorique.query.order_by(EntrepriseHistorique.date.desc())
.filter(EntrepriseHistorique.entreprise_id == entreprise.id)
.limit(LOGS_LEN)
.all()
)
stages_apprentissages = (
db.session.query(EntrepriseStageApprentissage, Identite)
.order_by(EntrepriseStageApprentissage.date_debut.desc())
.filter(EntrepriseStageApprentissage.entreprise_id == entreprise.id)
.join(Identite, Identite.id == EntrepriseStageApprentissage.etudid)
.all()
)
taxes = (
EntrepriseTaxeApprentissage.query.filter_by(entreprise_id=entreprise.id)
.order_by(EntrepriseTaxeApprentissage.annee.desc())
.all()
)
return render_template( return render_template(
"entreprises/fiche_entreprise.html", "entreprises/entreprises_validation.html",
title="Fiche entreprise", title="Validation entreprises",
entreprise=entreprise, entreprises=entreprises,
offres=offres_with_files,
logs=logs,
stages_apprentissages=stages_apprentissages,
taxes=taxes,
)
@bp.route("/fiche_entreprise/<int:entreprise_id>/logs", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesView)
def logs_entreprise(entreprise_id):
"""
Permet d'afficher les logs d'une entreprise
"""
page = request.args.get("page", 1, type=int)
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"logs fiche entreprise {entreprise_id} inconnu")
logs = (
EntrepriseHistorique.query.order_by(EntrepriseHistorique.date.desc())
.filter(EntrepriseHistorique.entreprise_id == entreprise.id)
.paginate(page=page, per_page=20)
)
return render_template(
"entreprises/logs_entreprise.html",
title="Logs",
logs=logs,
entreprise=entreprise,
) )
@ -250,6 +173,82 @@ def fiche_entreprise_validation(entreprise_id):
) )
@bp.route(
"/fiche_entreprise_validation/<int:entreprise_id>/validate_entreprise",
methods=["GET", "POST"],
)
@permission_required(Permission.RelationsEntreprisesValidate)
def validate_entreprise(entreprise_id):
"""
Permet de valider une entreprise
"""
form = ValidationConfirmationForm()
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=False
).first_or_404(description=f"entreprise (validation) {entreprise_id} inconnue")
if request.method == "POST" and form.cancel.data:
return redirect(
url_for(
"entreprises.fiche_entreprise_validation", entreprise_id=entreprise_id
)
)
if form.validate_on_submit():
entreprise.visible = True
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
log = EntrepriseHistorique(
authenticated_user=current_user.user_name,
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Validation de la fiche entreprise ({entreprise.nom})",
)
db.session.add(log)
db.session.commit()
flash("L'entreprise a été validé et ajouté à la liste.")
return redirect(url_for("entreprises.validation"))
return render_template(
"entreprises/form_validate_confirmation.html",
title="Validation entreprise",
form=form,
)
@bp.route(
"/fiche_entreprise_validation/<int:entreprise_id>/delete_validation_entreprise",
methods=["GET", "POST"],
)
@permission_required(Permission.RelationsEntreprisesValidate)
def delete_validation_entreprise(entreprise_id):
"""
Permet de supprimer une entreprise en attente de validation avec une formulaire de validation
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=False
).first_or_404(description=f"entreprise (validation) {entreprise_id} inconnue")
form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for(
"entreprises.fiche_entreprise_validation", entreprise_id=entreprise_id
)
)
if form.validate_on_submit():
db.session.delete(entreprise)
db.session.commit()
log = EntrepriseHistorique(
authenticated_user=current_user.user_name,
entreprise_id=entreprise.id,
text=f"Non validation de la fiche entreprise ({entreprise.nom})",
)
db.session.add(log)
flash("L'entreprise a été supprimé de la liste des entreprise à valider.")
return redirect(url_for("entreprises.validation"))
return render_template(
"entreprises/form_confirmation.html",
title="Supression entreprise",
form=form,
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
)
@bp.route("/offres_recues", methods=["GET"]) @bp.route("/offres_recues", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesView) @permission_required(Permission.RelationsEntreprisesView)
def offres_recues(): def offres_recues():
@ -263,16 +262,16 @@ def offres_recues():
.all() .all()
) )
offres_recues_with_files = [] offres_recues_with_files = []
for offre in offres_recues: for envoi_offre, offre in offres_recues:
correspondant = EntrepriseCorrespondant.query.filter_by( correspondant = EntrepriseCorrespondant.query.filter_by(
id=offre[1].correspondant_id id=offre.correspondant_id
).first() ).first()
files = [] files = []
path = os.path.join( path = os.path.join(
Config.SCODOC_VAR_DIR, Config.SCODOC_VAR_DIR,
"entreprises", "entreprises",
f"{offre[1].entreprise_id}", f"{offre.entreprise_id}",
f"{offre[1].id}", f"{offre.id}",
) )
if os.path.exists(path): if os.path.exists(path):
for dir in glob.glob( for dir in glob.glob(
@ -281,7 +280,7 @@ def offres_recues():
for file in glob.glob(f"{dir}/*"): for file in glob.glob(f"{dir}/*"):
file = [os.path.basename(dir), os.path.basename(file)] file = [os.path.basename(dir), os.path.basename(file)]
files.append(file) files.append(file)
offres_recues_with_files.append([offre[0], offre[1], files, correspondant]) offres_recues_with_files.append([envoi_offre, offre, files, correspondant])
return render_template( return render_template(
"entreprises/offres_recues.html", "entreprises/offres_recues.html",
title="Offres reçues", title="Offres reçues",
@ -289,29 +288,42 @@ def offres_recues():
) )
@bp.route("/fiche_entreprise/<int:entreprise_id>/offres_expirees") @bp.route(
"/offres_recues/delete_offre_recue/<int:envoi_offre_id>", methods=["GET", "POST"]
)
@permission_required(Permission.RelationsEntreprisesView) @permission_required(Permission.RelationsEntreprisesView)
def offres_expirees(entreprise_id): def delete_offre_recue(envoi_offre_id):
""" """
Permet d'afficher la liste des offres expirés d'une entreprise Permet de supprimer une offre reçue
""" """
entreprise = Entreprise.query.filter_by( offre_recue = EntrepriseEnvoiOffre.query.filter_by(
id=entreprise_id, visible=True id=envoi_offre_id, receiver_id=current_user.id
).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue") ).first_or_404(description=f"offre recu {envoi_offre_id} inconnue")
offres_expirees_with_files = [] db.session.delete(offre_recue)
depts = are.get_depts() db.session.commit()
for offre in entreprise.offres: return redirect(url_for("entreprises.offres_recues"))
if offre.expired or (
offre.expiration_date is not None and date.today() > offre.expiration_date
): @bp.route("/preferences", methods=["GET", "POST"])
offre_expiree_with_files = are.get_offre_files_and_depts(offre, depts) @permission_required(Permission.RelationsEntreprisesValidate)
if offre_expiree_with_files is not None: def preferences():
offres_expirees_with_files.append(offre_expiree_with_files) """
Permet d'afficher la page des préférences du module gestion des relations entreprises
"""
form = PreferencesForm()
if request.method == "POST" and form.cancel.data:
return redirect(url_for("entreprises.index"))
if form.validate_on_submit():
EntreprisePreferences.set_email_notifications(form.mail_entreprise.data.strip())
EntreprisePreferences.set_check_siret(int(form.check_siret.data))
return redirect(url_for("entreprises.index"))
elif request.method == "GET":
form.mail_entreprise.data = EntreprisePreferences.get_email_notifications()
form.check_siret.data = int(EntreprisePreferences.get_check_siret())
return render_template( return render_template(
"entreprises/offres_expirees.html", "entreprises/preferences.html",
title="Offres expirées", title="Préférences",
entreprise=entreprise, form=form,
offres_expirees=offres_expirees_with_files,
) )
@ -322,6 +334,8 @@ def add_entreprise():
Permet d'ajouter une entreprise dans la base avec un formulaire Permet d'ajouter une entreprise dans la base avec un formulaire
""" """
form = EntrepriseCreationForm() form = EntrepriseCreationForm()
if request.method == "POST" and form.cancel.data:
return redirect(url_for("entreprises.index"))
if form.validate_on_submit(): if form.validate_on_submit():
entreprise = Entreprise( entreprise = Entreprise(
nom=form.nom_entreprise.data.strip(), nom=form.nom_entreprise.data.strip(),
@ -400,6 +414,89 @@ def add_entreprise():
) )
@bp.route("/fiche_entreprise/<int:entreprise_id>", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesView)
def fiche_entreprise(entreprise_id):
"""
Permet d'afficher la fiche entreprise d'une entreprise avec une liste des dernières opérations et
l'historique des étudiants ayant réaliser un stage ou une alternance dans cette entreprise.
La fiche entreprise comporte les informations de l'entreprise, les correspondants de l'entreprise et
les offres de l'entreprise.
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue")
offres_with_files = are.get_offres_non_expirees_with_files(entreprise.offres)
logs = (
EntrepriseHistorique.query.order_by(EntrepriseHistorique.date.desc())
.filter(EntrepriseHistorique.entreprise_id == entreprise.id)
.limit(LOGS_LEN)
.all()
)
stages_apprentissages = (
db.session.query(EntrepriseStageApprentissage, Identite)
.order_by(EntrepriseStageApprentissage.date_debut.desc())
.filter(EntrepriseStageApprentissage.entreprise_id == entreprise.id)
.join(Identite, Identite.id == EntrepriseStageApprentissage.etudid)
.all()
)
taxes = (
EntrepriseTaxeApprentissage.query.filter_by(entreprise_id=entreprise.id)
.order_by(EntrepriseTaxeApprentissage.annee.desc())
.all()
)
return render_template(
"entreprises/fiche_entreprise.html",
title="Fiche entreprise",
entreprise=entreprise,
offres=offres_with_files,
logs=logs,
stages_apprentissages=stages_apprentissages,
taxes=taxes,
)
@bp.route("/fiche_entreprise/<int:entreprise_id>/logs", methods=["GET"])
@permission_required(Permission.RelationsEntreprisesView)
def logs_entreprise(entreprise_id):
"""
Permet d'afficher les logs d'une entreprise
"""
page = request.args.get("page", 1, type=int)
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"logs fiche entreprise {entreprise_id} inconnu")
logs = (
EntrepriseHistorique.query.order_by(EntrepriseHistorique.date.desc())
.filter(EntrepriseHistorique.entreprise_id == entreprise.id)
.paginate(page=page, per_page=20)
)
return render_template(
"entreprises/logs_entreprise.html",
title="Logs",
logs=logs,
entreprise=entreprise,
)
@bp.route("/fiche_entreprise/<int:entreprise_id>/offres_expirees")
@permission_required(Permission.RelationsEntreprisesView)
def offres_expirees(entreprise_id):
"""
Permet d'afficher la liste des offres expirés d'une entreprise
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue")
offres_with_files = are.get_offres_expirees_with_files(entreprise.offres)
return render_template(
"entreprises/offres_expirees.html",
title="Offres expirées",
entreprise=entreprise,
offres_expirees=offres_with_files,
)
@bp.route( @bp.route(
"/fiche_entreprise/<int:entreprise_id>/edit_entreprise", methods=["GET", "POST"] "/fiche_entreprise/<int:entreprise_id>/edit_entreprise", methods=["GET", "POST"]
) )
@ -412,6 +509,10 @@ def edit_entreprise(entreprise_id):
id=entreprise_id, visible=True id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = EntrepriseModificationForm(siret=entreprise.siret) form = EntrepriseModificationForm(siret=entreprise.siret)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
lien_entreprise = f"<a href='{url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id)}'>{form.nom.data.strip()}</a>" lien_entreprise = f"<a href='{url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id)}'>{form.nom.data.strip()}</a>"
logs_text = [] logs_text = []
@ -489,6 +590,10 @@ def fiche_entreprise_desactiver(entreprise_id):
id=entreprise_id, visible=True, active=True id=entreprise_id, visible=True, active=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = DesactivationConfirmationForm() form = DesactivationConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
entreprise.notes_active = form.notes_active.data.strip() entreprise.notes_active = form.notes_active.data.strip()
entreprise.active = False entreprise.active = False
@ -522,6 +627,10 @@ def fiche_entreprise_activer(entreprise_id):
id=entreprise_id, visible=True, active=False id=entreprise_id, visible=True, active=False
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = ActivationConfirmationForm() form = ActivationConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
entreprise.active = True entreprise.active = True
lien_entreprise = f"<a href='{url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id)}'>{entreprise.nom}</a>" lien_entreprise = f"<a href='{url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id)}'>{entreprise.nom}</a>"
@ -556,6 +665,10 @@ def add_taxe_apprentissage(entreprise_id):
id=entreprise_id, visible=True id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = TaxeApprentissageForm(hidden_entreprise_id=entreprise.id) form = TaxeApprentissageForm(hidden_entreprise_id=entreprise.id)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
taxe = EntrepriseTaxeApprentissage( taxe = EntrepriseTaxeApprentissage(
entreprise_id=entreprise.id, entreprise_id=entreprise.id,
@ -599,6 +712,10 @@ def edit_taxe_apprentissage(entreprise_id, taxe_id):
description=f"taxe d'apprentissage {taxe_id} inconnue pour l'entreprise {entreprise_id}" description=f"taxe d'apprentissage {taxe_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = TaxeApprentissageModificationForm(annee=taxe.annee) form = TaxeApprentissageModificationForm(annee=taxe.annee)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
taxe.montant = form.montant.data taxe.montant = form.montant.data
taxe.notes = form.notes.data.strip() taxe.notes = form.notes.data.strip()
@ -638,6 +755,10 @@ def delete_taxe_apprentissage(entreprise_id, taxe_id):
description=f"taxe d'apprentissage {taxe_id} inconnue pour l'entreprise {entreprise_id}" description=f"taxe d'apprentissage {taxe_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
db.session.delete(taxe) db.session.delete(taxe)
log = EntrepriseHistorique( log = EntrepriseHistorique(
@ -661,70 +782,6 @@ def delete_taxe_apprentissage(entreprise_id, taxe_id):
) )
@bp.route(
"/fiche_entreprise_validation/<int:entreprise_id>/validate_entreprise",
methods=["GET", "POST"],
)
@permission_required(Permission.RelationsEntreprisesValidate)
def validate_entreprise(entreprise_id):
"""
Permet de valider une entreprise
"""
form = ValidationConfirmationForm()
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=False
).first_or_404(description=f"entreprise (validation) {entreprise_id} inconnue")
if form.validate_on_submit():
entreprise.visible = True
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
log = EntrepriseHistorique(
authenticated_user=current_user.user_name,
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Validation de la fiche entreprise ({entreprise.nom})",
)
db.session.add(log)
db.session.commit()
flash("L'entreprise a été validé et ajouté à la liste.")
return redirect(url_for("entreprises.validation"))
return render_template(
"entreprises/form_validate_confirmation.html",
title="Validation entreprise",
form=form,
)
@bp.route(
"/fiche_entreprise_validation/<int:entreprise_id>/delete_validation_entreprise",
methods=["GET", "POST"],
)
@permission_required(Permission.RelationsEntreprisesValidate)
def delete_validation_entreprise(entreprise_id):
"""
Permet de supprimer une entreprise en attente de validation avec une formulaire de validation
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=False
).first_or_404(description=f"entreprise (validation) {entreprise_id} inconnue")
form = SuppressionConfirmationForm()
if form.validate_on_submit():
db.session.delete(entreprise)
db.session.commit()
log = EntrepriseHistorique(
authenticated_user=current_user.user_name,
entreprise_id=entreprise.id,
text=f"Non validation de la fiche entreprise ({entreprise.nom})",
)
db.session.add(log)
flash("L'entreprise a été supprimé de la liste des entreprise à valider.")
return redirect(url_for("entreprises.validation"))
return render_template(
"entreprises/form_confirmation.html",
title="Supression entreprise",
form=form,
info_message="Cliquez sur le bouton Supprimer pour confirmer votre supression",
)
@bp.route("/fiche_entreprise/<int:entreprise_id>/add_offre", methods=["GET", "POST"]) @bp.route("/fiche_entreprise/<int:entreprise_id>/add_offre", methods=["GET", "POST"])
@permission_required(Permission.RelationsEntreprisesChange) @permission_required(Permission.RelationsEntreprisesChange)
def add_offre(entreprise_id): def add_offre(entreprise_id):
@ -735,6 +792,10 @@ def add_offre(entreprise_id):
id=entreprise_id, visible=True id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = OffreCreationForm(hidden_entreprise_id=entreprise.id) form = OffreCreationForm(hidden_entreprise_id=entreprise.id)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
offre = EntrepriseOffre( offre = EntrepriseOffre(
entreprise_id=entreprise.id, entreprise_id=entreprise.id,
@ -805,10 +866,14 @@ def edit_offre(entreprise_id, offre_id):
description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}"
) )
offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all() offre_depts = EntrepriseOffreDepartement.query.filter_by(offre_id=offre.id).all()
offre_depts_list = [(offre_dept.dept_id) for offre_dept in offre_depts]
form = OffreModificationForm( form = OffreModificationForm(
hidden_entreprise_id=offre.entreprise_id, correspondant=offre.correspondant_id hidden_entreprise_id=offre.entreprise_id, correspondant=offre.correspondant_id
) )
offre_depts_list = [(offre_dept.dept_id) for offre_dept in offre_depts] if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
offre.intitule = form.intitule.data.strip() offre.intitule = form.intitule.data.strip()
offre.description = form.description.data.strip() offre.description = form.description.data.strip()
@ -878,6 +943,10 @@ def delete_offre(entreprise_id, offre_id):
) )
entreprise_id = offre.entreprise.id entreprise_id = offre.entreprise.id
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
db.session.delete(offre) db.session.delete(offre)
path = os.path.join( path = os.path.join(
@ -909,22 +978,6 @@ def delete_offre(entreprise_id, offre_id):
) )
@bp.route(
"/offres_recues/delete_offre_recue/<int:envoi_offre_id>", methods=["GET", "POST"]
)
@permission_required(Permission.RelationsEntreprisesView)
def delete_offre_recue(envoi_offre_id):
"""
Permet de supprimer une offre reçue
"""
offre_recue = EntrepriseEnvoiOffre.query.filter_by(
id=envoi_offre_id, receiver_id=current_user.id
).first_or_404(description=f"offre recu {envoi_offre_id} inconnue")
db.session.delete(offre_recue)
db.session.commit()
return redirect(url_for("entreprises.offres_recues"))
@bp.route( @bp.route(
"/fiche_entreprise/<int:entreprise_id>/expired/<int:offre_id>", "/fiche_entreprise/<int:entreprise_id>/expired/<int:offre_id>",
methods=["GET", "POST"], methods=["GET", "POST"],
@ -956,10 +1009,17 @@ def expired(entreprise_id, offre_id):
) )
@permission_required(Permission.RelationsEntreprisesChange) @permission_required(Permission.RelationsEntreprisesChange)
def add_site(entreprise_id): def add_site(entreprise_id):
"""
Permet d'ajouter un site a une entreprise
"""
entreprise = Entreprise.query.filter_by( entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = SiteCreationForm(hidden_entreprise_id=entreprise.id) form = SiteCreationForm(hidden_entreprise_id=entreprise.id)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
site = EntrepriseSite( site = EntrepriseSite(
entreprise_id=entreprise.id, entreprise_id=entreprise.id,
@ -998,6 +1058,9 @@ def add_site(entreprise_id):
methods=["GET", "POST"], methods=["GET", "POST"],
) )
def edit_site(entreprise_id, site_id): def edit_site(entreprise_id, site_id):
"""
Permet de modifier une offre
"""
site = EntrepriseSite.query.filter_by( site = EntrepriseSite.query.filter_by(
id=site_id, entreprise_id=entreprise_id id=site_id, entreprise_id=entreprise_id
).first_or_404( ).first_or_404(
@ -1006,6 +1069,10 @@ def edit_site(entreprise_id, site_id):
form = SiteModificationForm( form = SiteModificationForm(
hidden_entreprise_id=site.entreprise_id, hidden_site_id=site.id hidden_entreprise_id=site.entreprise_id, hidden_site_id=site.id
) )
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
site.nom = form.nom.data.strip() site.nom = form.nom.data.strip()
site.adresse = form.adresse.data.strip() site.adresse = form.adresse.data.strip()
@ -1052,6 +1119,10 @@ def add_correspondant(entreprise_id, site_id):
description=f"site {site_id} inconnue pour l'entreprise {entreprise_id}" description=f"site {site_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = CorrespondantsCreationForm(hidden_site_id=site.id) form = CorrespondantsCreationForm(hidden_site_id=site.id)
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
for correspondant_entry in form.correspondants.entries: for correspondant_entry in form.correspondants.entries:
correspondant = EntrepriseCorrespondant( correspondant = EntrepriseCorrespondant(
@ -1118,7 +1189,13 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id):
form = CorrespondantModificationForm( form = CorrespondantModificationForm(
hidden_site_id=correspondant.site.id, hidden_site_id=correspondant.site.id,
hidden_correspondant_id=correspondant.id, hidden_correspondant_id=correspondant.id,
hidden_entreprise_id=entreprise_id,
site=correspondant.site_id,
) )
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
correspondant.civilite = form.civilite.data correspondant.civilite = form.civilite.data
correspondant.nom = form.nom.data.strip() correspondant.nom = form.nom.data.strip()
@ -1129,6 +1206,7 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id):
correspondant.service = form.service.data.strip() correspondant.service = form.service.data.strip()
correspondant.origine = form.origine.data.strip() correspondant.origine = form.origine.data.strip()
correspondant.notes = form.notes.data.strip() correspondant.notes = form.notes.data.strip()
correspondant.site_id = form.site.data
log = EntrepriseHistorique( log = EntrepriseHistorique(
authenticated_user=current_user.user_name, authenticated_user=current_user.user_name,
entreprise_id=correspondant.site.entreprise.id, entreprise_id=correspondant.site.entreprise.id,
@ -1189,6 +1267,10 @@ def delete_correspondant(entreprise_id, site_id, correspondant_id):
) )
) )
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
db.session.delete(correspondant) db.session.delete(correspondant)
log = EntrepriseHistorique( log = EntrepriseHistorique(
@ -1215,6 +1297,24 @@ def delete_correspondant(entreprise_id, site_id, correspondant_id):
) )
@bp.route("/fiche_entreprise/<int:entreprise_id>/contacts")
@permission_required(Permission.RelationsEntreprisesView)
def contacts(entreprise_id):
"""
Permet d'afficher une page avec la liste des contacts d'une entreprise
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue")
contacts = EntrepriseContact.query.filter_by(entreprise=entreprise.id).all()
return render_template(
"entreprises/contacts.html",
title="Liste des contacts",
contacts=contacts,
entreprise=entreprise,
)
@bp.route( @bp.route(
"/fiche_entreprise/<int:entreprise_id>/contacts/add_contact", "/fiche_entreprise/<int:entreprise_id>/contacts/add_contact",
methods=["GET", "POST"], methods=["GET", "POST"],
@ -1233,6 +1333,8 @@ def add_contact(entreprise_id):
if current_user.nom and current_user.prenom if current_user.nom and current_user.prenom
else "", else "",
) )
if request.method == "POST" and form.cancel.data:
return redirect(url_for("entreprises.contacts", entreprise_id=entreprise_id))
if form.validate_on_submit(): if form.validate_on_submit():
utilisateur_data = form.utilisateur.data.upper().strip() utilisateur_data = form.utilisateur.data.upper().strip()
stm = text( stm = text(
@ -1284,6 +1386,8 @@ def edit_contact(entreprise_id, contact_id):
description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}" description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}"
) )
form = ContactModificationForm() form = ContactModificationForm()
if request.method == "POST" and form.cancel.data:
return redirect(url_for("entreprises.contacts", entreprise_id=entreprise_id))
if form.validate_on_submit(): if form.validate_on_submit():
utilisateur_data = form.utilisateur.data.upper().strip() utilisateur_data = form.utilisateur.data.upper().strip()
stm = text( stm = text(
@ -1338,6 +1442,8 @@ def delete_contact(entreprise_id, contact_id):
description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}" description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}"
) )
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(url_for("entreprises.contacts", entreprise_id=entreprise_id))
if form.validate_on_submit(): if form.validate_on_submit():
db.session.delete(contact) db.session.delete(contact)
log = EntrepriseHistorique( log = EntrepriseHistorique(
@ -1360,24 +1466,6 @@ def delete_contact(entreprise_id, contact_id):
) )
@bp.route("/fiche_entreprise/<int:entreprise_id>/contacts")
@permission_required(Permission.RelationsEntreprisesView)
def contacts(entreprise_id):
"""
Permet d'afficher une page avec la liste des contacts d'une entreprise
"""
entreprise = Entreprise.query.filter_by(
id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue")
contacts = EntrepriseContact.query.filter_by(entreprise=entreprise.id).all()
return render_template(
"entreprises/contacts.html",
title="Liste des contacts",
contacts=contacts,
entreprise=entreprise,
)
@bp.route( @bp.route(
"/fiche_entreprise/<int:entreprise_id>/add_stage_apprentissage", "/fiche_entreprise/<int:entreprise_id>/add_stage_apprentissage",
methods=["GET", "POST"], methods=["GET", "POST"],
@ -1391,6 +1479,10 @@ def add_stage_apprentissage(entreprise_id):
id=entreprise_id, visible=True id=entreprise_id, visible=True
).first_or_404(description=f"entreprise {entreprise_id} inconnue") ).first_or_404(description=f"entreprise {entreprise_id} inconnue")
form = StageApprentissageCreationForm() form = StageApprentissageCreationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
etudiant_nomcomplet = form.etudiant.data.upper().strip() etudiant_nomcomplet = form.etudiant.data.upper().strip()
stm = text( stm = text(
@ -1457,6 +1549,10 @@ def edit_stage_apprentissage(entreprise_id, stage_apprentissage_id):
description=f"etudiant {stage_apprentissage.etudid} inconnue" description=f"etudiant {stage_apprentissage.etudid} inconnue"
) )
form = StageApprentissageModificationForm() form = StageApprentissageModificationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
etudiant_nomcomplet = form.etudiant.data.upper().strip() etudiant_nomcomplet = form.etudiant.data.upper().strip()
stm = text( stm = text(
@ -1522,6 +1618,10 @@ def delete_stage_apprentissage(entreprise_id, stage_apprentissage_id):
id=stage_apprentissage_id, entreprise_id=entreprise_id id=stage_apprentissage_id, entreprise_id=entreprise_id
).first_or_404(description=f"stage_apprentissage {stage_apprentissage_id} inconnu") ).first_or_404(description=f"stage_apprentissage {stage_apprentissage_id} inconnu")
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
db.session.delete(stage_apprentissage) db.session.delete(stage_apprentissage)
log = EntrepriseHistorique( log = EntrepriseHistorique(
@ -1562,6 +1662,10 @@ def envoyer_offre(entreprise_id, offre_id):
description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = EnvoiOffreForm() form = EnvoiOffreForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
for responsable in form.responsables.entries: for responsable in form.responsables.entries:
if responsable.data.strip(): if responsable.data.strip():
@ -1666,7 +1770,7 @@ def export_donnees():
@bp.route("/import_donnees/get_file_sample") @bp.route("/import_donnees/get_file_sample")
@permission_required(Permission.RelationsEntreprisesExport) @permission_required(Permission.RelationsEntreprisesExport)
def get_import_donnees_file_sample(): def import_donnees_get_file_sample():
""" """
Permet de récupérer un fichier exemple vide pour pouvoir importer des entreprises Permet de récupérer un fichier exemple vide pour pouvoir importer des entreprises
""" """
@ -1801,6 +1905,10 @@ def add_offre_file(entreprise_id, offre_id):
description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = AjoutFichierForm() form = AjoutFichierForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
date = f"{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}" date = f"{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}"
path = os.path.join( path = os.path.join(
@ -1840,6 +1948,10 @@ def delete_offre_file(entreprise_id, offre_id, filedir):
description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}"
) )
form = SuppressionConfirmationForm() form = SuppressionConfirmationForm()
if request.method == "POST" and form.cancel.data:
return redirect(
url_for("entreprises.fiche_entreprise", entreprise_id=entreprise_id)
)
if form.validate_on_submit(): if form.validate_on_submit():
path = os.path.join( path = os.path.join(
Config.SCODOC_VAR_DIR, Config.SCODOC_VAR_DIR,
@ -1864,27 +1976,9 @@ def delete_offre_file(entreprise_id, offre_id, filedir):
) )
@bp.route("/preferences", methods=["GET", "POST"])
@permission_required(Permission.RelationsEntreprisesValidate)
def preferences():
"""
Permet d'afficher la page des préférences du module gestion des relations entreprises
"""
form = PreferencesForm()
if form.validate_on_submit():
EntreprisePreferences.set_email_notifications(form.mail_entreprise.data.strip())
EntreprisePreferences.set_check_siret(int(form.check_siret.data))
return redirect(url_for("entreprises.index"))
elif request.method == "GET":
form.mail_entreprise.data = EntreprisePreferences.get_email_notifications()
form.check_siret.data = int(EntreprisePreferences.get_check_siret())
return render_template(
"entreprises/preferences.html",
title="Préférences",
form=form,
)
@bp.errorhandler(404) @bp.errorhandler(404)
def not_found_error_handler(e): def not_found_error_handler(e):
"""
Renvoie une page d'erreur pour l'erreur 404
"""
return render_template("entreprises/error.html", title="Erreur", e=e) return render_template("entreprises/error.html", title="Erreur", e=e)

View File

@ -184,6 +184,10 @@
padding-left: 0; padding-left: 0;
} }
#form-entreprise-filter > label { #form-entreprise-filter > div {
display: inline-block;
}
#form-entreprise-filter > div > label {
margin-right: 20px; margin-right: 20px;
} }

View File

@ -1,53 +1,53 @@
{# -*- mode: jinja-html -*- #} {# -*- mode: jinja-html -*- #}
<div class="offre"> <div class="offre">
<div style="word-break:break-all; text-align: justify;"> <div style="word-break:break-all; text-align: justify;">
Ajouté le {{ offre[0].date_ajout.strftime('%d/%m/%y') }} à {{ offre[0].date_ajout.strftime('%Hh%M') }}<br> Ajouté le {{ offre.date_ajout.strftime('%d/%m/%y') }} à {{ offre.date_ajout.strftime('%Hh%M') }}<br>
Intitulé : {{ offre[0].intitule }}<br> Intitulé : {{ offre.intitule }}<br>
Description : {{ offre[0].description }}<br> Description : {{ offre.description }}<br>
Type de l'offre : {{ offre[0].type_offre }}<br> Type de l'offre : {{ offre.type_offre }}<br>
Missions : {{ offre[0].missions }}<br> Missions : {{ offre.missions }}<br>
Durée : {{ offre[0].duree }}<br> Durée : {{ offre.duree }}<br>
{% if offre[2] %} {% if offre_depts %}
Département(s) : {% for offre_dept in offre[2] %} <div class="offre-depts">{{ offre_dept.dept_id|get_dept_acronym }}</div> {% endfor %}<br> Département(s) : {% for offre_dept in offre_depts %} <div class="offre-depts">{{ offre_dept.dept_id|get_dept_acronym }}</div> {% endfor %}<br>
{% endif %} {% endif %}
{% if offre[0].correspondant_id %} {% if offre.correspondant_id %}
Contacté {{ offre[3].nom }} {{ offre[3].prenom }} Contacté {{ correspondant.nom }} {{ correspondant.prenom }}
{% if offre[3].mail and offre[3].telephone %} {% if correspondant.mail and correspondant.telephone %}
({{ offre[3].mail }} - {{ offre[3].telephone }})<br> ({{ correspondant.mail }} - {{ correspondant.telephone }})<br>
{% else %} {% else %}
({{ offre[3].mail }}{{offre[3].telephone}})<br> ({{ correspondant.mail }}{{ correspondant.telephone }})<br>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% for fichier in offre[1] %} {% for filedir, filename in files %}
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id, filedir=fichier[0], filename=fichier[1] )}}">{{ fichier[1] }}</a> <a href="{{ url_for('entreprises.get_offre_file', entreprise_id=entreprise.id, offre_id=offre.id, filedir=filedir, filename=filename )}}">{{ filename }}</a>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a href="{{ url_for('entreprises.delete_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id, filedir=fichier[0] )}}" style="margin-left: 5px;"><img title="Supprimer fichier" alt="supprimer" width="10" height="9" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a> <a href="{{ url_for('entreprises.delete_offre_file', entreprise_id=entreprise.id, offre_id=offre.id, filedir=filedir )}}" style="margin-left: 5px;"><img title="Supprimer fichier" alt="supprimer" width="10" height="9" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a>
{% endif %} {% endif %}
<br> <br>
{% endfor %} {% endfor %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a href="{{ url_for('entreprises.add_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id) }}">Ajoutez un fichier</a> <a href="{{ url_for('entreprises.add_offre_file', entreprise_id=entreprise.id, offre_id=offre.id) }}">Ajoutez un fichier</a>
{% endif %} {% endif %}
</div> </div>
<div class="parent-btn"> <div class="parent-btn">
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a class="btn btn-primary" href="{{ url_for('entreprises.edit_offre', entreprise_id=offre[0].entreprise_id, offre_id=offre[0].id) }}">Modifier l'offre</a> <a class="btn btn-primary" href="{{ url_for('entreprises.edit_offre', entreprise_id=offre.entreprise_id, offre_id=offre.id) }}">Modifier l'offre</a>
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_offre', entreprise_id=offre[0].entreprise_id, offre_id=offre[0].id) }}">Supprimer l'offre</a> <a class="btn btn-danger" href="{{ url_for('entreprises.delete_offre', entreprise_id=offre.entreprise_id, offre_id=offre.id) }}">Supprimer l'offre</a>
{% endif %} {% endif %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesSend, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesSend, None) %}
<a class="btn btn-primary" href="{{ url_for('entreprises.envoyer_offre', entreprise_id=entreprise.id, offre_id=offre[0].id) }}">Envoyer l'offre</a> <a class="btn btn-primary" href="{{ url_for('entreprises.envoyer_offre', entreprise_id=entreprise.id, offre_id=offre.id) }}">Envoyer l'offre</a>
{% endif %} {% endif %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
{% if not offre[0].expired %} {% if not offre.expired %}
<a class="btn btn-danger" href="{{ url_for('entreprises.expired', entreprise_id=offre[0].entreprise_id, offre_id=offre[0].id) }}">Rendre expirée</a> <a class="btn btn-danger" href="{{ url_for('entreprises.expired', entreprise_id=offre.entreprise_id, offre_id=offre.id) }}">Rendre expirée</a>
{% else %} {% else %}
<a class="btn btn-success" href="{{ url_for('entreprises.expired', entreprise_id=offre[0].entreprise_id, offre_id=offre[0].id) }}">Rendre non expirée</a> <a class="btn btn-success" href="{{ url_for('entreprises.expired', entreprise_id=offre.entreprise_id, offre_id=offre.id) }}">Rendre non expirée</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>

View File

@ -37,15 +37,15 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for correspondant in correspondants %} {% for correspondant, site in correspondants %}
<tr> <tr>
<td>{{ correspondant[0].nom }}</td> <td>{{ correspondant.nom }}</td>
<td>{{ correspondant[0].prenom }}</td> <td>{{ correspondant.prenom }}</td>
<td>{{ correspondant[0].telephone }}</td> <td>{{ correspondant.telephone }}</td>
<td>{{ correspondant[0].mail }}</td> <td>{{ correspondant.mail }}</td>
<td>{{ correspondant[0].poste}}</td> <td>{{ correspondant.poste}}</td>
<td>{{ correspondant[0].service}}</td> <td>{{ correspondant.service}}</td>
<td><a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=correspondant[1].entreprise.id) }}">{{ correspondant[1].nom }}</a></td> <td><a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=site.entreprise.id) }}">{{ site.nom }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -39,9 +39,9 @@
{% if form %} {% if form %}
<form id="form-entreprise-filter" method="POST" action=""> <form id="form-entreprise-filter" method="POST" action="">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<input id="active" name="active" type="checkbox" onChange="form.submit()" {% if checked[0] %} checked {% endif %}> {{ form.active.label }} <div><input id="active" name="active" type="checkbox" onChange="form.submit()" {% if checked[0] %} checked {% endif %}> {{ form.active.label }}</div>
<input id="association" name="association" type="checkbox" onChange="form.submit()" {% if checked[1] %} checked {% endif %}> {{ form.association.label }} <div><input id="association" name="association" type="checkbox" onChange="form.submit()" {% if checked[1] %} checked {% endif %}> {{ form.association.label }}</div>
<input id="siret_provisoire" name="siret_provisoire" type="checkbox" onChange="form.submit()" {% if checked[2] %} checked {% endif %}> {{ form.siret_provisoire.label }} <div><input id="siret_provisoire" name="siret_provisoire" type="checkbox" onChange="form.submit()" {% if checked[2] %} checked {% endif %}> {{ form.siret_provisoire.label }}</div>
</form> </form>
{% endif %} {% endif %}
<table id="table-entreprises"> <table id="table-entreprises">
@ -61,7 +61,7 @@
<tbody> <tbody>
{% for entreprise in entreprises %} {% for entreprise in entreprises %}
<tr> <tr>
<td><a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id) }}" {% if not entreprise.active %} style="color:red" {% endif %}>{{ entreprise.siret }}</a></td> <td><a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=entreprise.id) }}" style="{% if not entreprise.active %}color:red;{% endif %}{% if entreprise.siret_provisoire %}font-weight:bold;{% endif %}" >{{ entreprise.siret }}</a></td>
<td>{{ entreprise.nom }}</td> <td>{{ entreprise.nom }}</td>
<td>{{ entreprise.adresse }}</td> <td>{{ entreprise.adresse }}</td>
<td>{{ entreprise.codepostal }}</td> <td>{{ entreprise.codepostal }}</td>

View File

@ -48,7 +48,7 @@
<div class="entreprise"> <div class="entreprise">
<div> <div>
SIRET : {{ entreprise.siret }}<br> SIRET {% if entreprise.siret_provisoire %}provisoire{% endif %} : {{ entreprise.siret }}<br>
Nom : {{ entreprise.nom }}<br> Nom : {{ entreprise.nom }}<br>
Adresse : {{ entreprise.adresse }}<br> Adresse : {{ entreprise.adresse }}<br>
Code postal : {{ entreprise.codepostal }}<br> Code postal : {{ entreprise.codepostal }}<br>
@ -126,7 +126,7 @@
{% if offres %} {% if offres %}
<div> <div>
<h3>Offres - <a href="{{ url_for('entreprises.offres_expirees', entreprise_id=entreprise.id) }}">Voir les offres expirées</a></h3> <h3>Offres - <a href="{{ url_for('entreprises.offres_expirees', entreprise_id=entreprise.id) }}">Voir les offres expirées</a></h3>
{% for offre in offres %} {% for offre, files, offre_depts, correspondant in offres %}
{% include 'entreprises/_offre.html' %} {% include 'entreprises/_offre.html' %}
{% endfor %} {% endfor %}
</div> </div>
@ -155,15 +155,15 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for data in stages_apprentissages %} {% for stage_apprentissage, etudiant in stages_apprentissages %}
<tr> <tr>
<td>{{ data[0].date_debut.strftime('%d/%m/%Y') }}</td> <td>{{ stage_apprentissage.date_debut.strftime('%d/%m/%Y') }}</td>
<td>{{ data[0].date_fin.strftime('%d/%m/%Y') }}</td> <td>{{ stage_apprentissage.date_fin.strftime('%d/%m/%Y') }}</td>
<td>{{ (data[0].date_fin-data[0].date_debut).days//7 }} semaines</td> <td>{{ (stage_apprentissage.date_fin-stage_apprentissage.date_debut).days//7 }} semaines</td>
<td>{{ data[0].type_offre }}</td> <td>{{ stage_apprentissage.type_offre }}</td>
<td><a href="{{ url_for('scolar.ficheEtud', scodoc_dept=data[1].dept_id|get_dept_acronym, etudid=data[0].etudid) }}">{{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }}</a></td> <td><a href="{{ url_for('scolar.ficheEtud', scodoc_dept=etudiant.dept_id|get_dept_acronym, etudid=stage_apprentissage.etudid) }}">{{ etudiant.nom|format_nom }} {{ etudiant.prenom|format_prenom }}</a></td>
<td>{% if data[0].formation_text %}{{ data[0].formation_text }}{% endif %}</td> <td>{% if stage_apprentissage.formation_text %}{{ stage_apprentissage.formation_text }}{% endif %}</td>
<td>{{ data[0].notes }}</td> <td>{{ stage_apprentissage.notes }}</td>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<td> <td>
<div class="btn-group"> <div class="btn-group">
@ -171,8 +171,8 @@
<span class="caret"></span> <span class="caret"></span>
</a> </a>
<ul class="dropdown-menu pull-left"> <ul class="dropdown-menu pull-left">
<li><a href="{{ url_for('entreprises.edit_stage_apprentissage', entreprise_id=entreprise.id, stage_apprentissage_id=data[0].id) }}">Modifier</a></li> <li><a href="{{ url_for('entreprises.edit_stage_apprentissage', entreprise_id=entreprise.id, stage_apprentissage_id=stage_apprentissage.id) }}">Modifier</a></li>
<li><a href="{{ url_for('entreprises.delete_stage_apprentissage', entreprise_id=entreprise.id, stage_apprentissage_id=data[0].id) }}" style="color:red">Supprimer</a></li> <li><a href="{{ url_for('entreprises.delete_stage_apprentissage', entreprise_id=entreprise.id, stage_apprentissage_id=stage_apprentissage.id) }}" style="color:red">Supprimer</a></li>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -2,12 +2,23 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block app_content %} {% block app_content %}
<div class="container">
<ul class="breadcrumbs">
<li class="breadcrumbs_item">
<a href="{{ url_for('entreprises.validation') }}" class="breadcrumbs_link">Entreprises</a>
</li>
<li class="breadcrumbs_item">
<a href="" class="breadcrumbs_link breadcrumbs_link-active">Fiche entreprise</a>
</li>
</ul>
</div>
<div class="container"> <div class="container">
<h2>Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})</h2> <h2>Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})</h2>
<div class="entreprise"> <div class="entreprise">
<div> <div>
SIRET : {{ entreprise.siret }}<br> SIRET {% if entreprise.siret_provisoire %}provisoire{% endif %} : {{ entreprise.siret }}<br>
Nom : {{ entreprise.nom }}<br> Nom : {{ entreprise.nom }}<br>
Adresse : {{ entreprise.adresse }}<br> Adresse : {{ entreprise.adresse }}<br>
Code postal : {{ entreprise.codepostal }}<br> Code postal : {{ entreprise.codepostal }}<br>

View File

@ -32,7 +32,8 @@
{{ form.correspondants }} {{ form.correspondants }}
<div style="margin-bottom: 10px;"> <div style="margin-bottom: 10px;">
<button class="btn btn-default" id="add-correspondant-field">Ajouter un correspondant</button> <button class="btn btn-default" id="add-correspondant-field">Ajouter un correspondant</button>
<input class="btn btn-default" type="submit" value="Envoyer"> {{ form.submit(class_="btn btn-default") }}
{{ form.cancel(class_="btn btn-default") }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -25,7 +25,8 @@
{{ form.responsables }} {{ form.responsables }}
<div style="margin-bottom: 10px;"> <div style="margin-bottom: 10px;">
<button class="btn btn-default" id="add-responsable-field">Ajouter un responsable</button> <button class="btn btn-default" id="add-responsable-field">Ajouter un responsable</button>
<input class="btn btn-default" type="submit" value="Envoyer"> {{ form.submit(class_="btn btn-default") }}
{{ form.cancel(class_="btn btn-default") }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -22,7 +22,7 @@
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<br> <br>
<div> <div>
<a href="{{ url_for('entreprises.get_import_donnees_file_sample') }}">Obtenir la feuille excel à remplir</a> <a href="{{ url_for('entreprises.import_donnees_get_file_sample') }}">Obtenir la feuille excel à remplir</a>
</div> </div>
<br> <br>
<div class="row"> <div class="row">

View File

@ -19,7 +19,7 @@
<div class="container"> <div class="container">
<h1>Offres expirées - {{ entreprise.nom }}</h1> <h1>Offres expirées - {{ entreprise.nom }}</h1>
{% if offres_expirees %} {% if offres_expirees %}
{% for offre in offres_expirees %} {% for offre, files, offre_depts, correspondant in offres_expirees %}
{% include 'entreprises/_offre.html' %} {% include 'entreprises/_offre.html' %}
{% endfor %} {% endfor %}
{% else %} {% else %}

View File

@ -7,41 +7,41 @@
<div class="container"> <div class="container">
<h1>Offres reçues</h1> <h1>Offres reçues</h1>
{% if offres_recues %} {% if offres_recues %}
{% for offre in offres_recues %} {% for envoi_offre, offre, files, correspondant in offres_recues %}
<div class="offre offre-recue"> <div class="offre offre-recue">
<div style="word-break:break-all; text-align: justify;"> <div style="word-break:break-all; text-align: justify;">
Envoyé le {{ offre[0].date_envoi.strftime('%d/%m/%Y') }} à {{ offre[0].date_envoi.strftime('%Hh%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}<br> Envoyé le {{ envoi_offre.date_envoi.strftime('%d/%m/%Y') }} à {{ envoi_offre.date_envoi.strftime('%Hh%M') }} par {{ envoi_offre.sender_id|get_nomcomplet_by_id }}<br>
Intitulé : {{ offre[1].intitule }}<br> Intitulé : {{ offre.intitule }}<br>
Description : {{ offre[1].description }}<br> Description : {{ offre.description }}<br>
Type de l'offre : {{ offre[1].type_offre }}<br> Type de l'offre : {{ offre.type_offre }}<br>
Missions : {{ offre[1].missions }}<br> Missions : {{ offre.missions }}<br>
Durée : {{ offre[1].duree }}<br> Durée : {{ offre.duree }}<br>
{% if offre[1].correspondant_id %} {% if offre.correspondant_id %}
Contacté {{ offre[3].nom }} {{ offre[3].prenom }} Contacté {{ correspondant.nom }} {{ correspondant.prenom }}
{% if offre[3].mail and offre[3].telephone %} {% if correspondant.mail and correspondant.telephone %}
({{ offre[3].mail }} - {{ offre[3].telephone }}) ({{ correspondant.mail }} - {{ correspondant.telephone }})
{% else %} {% else %}
({{ offre[3].mail }}{{ offre[3].telephone }}) ({{ correspondant.mail }}{{ correspondant.telephone }})
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if offre[3].poste %} {% if correspondant.poste %}
, poste : {{ offre[3].poste }} - poste : {{ correspondant.poste }}
{% endif %} {% endif %}
{% if offre[3].service %} {% if correspondant.service %}
, service : {{ offre[3].service }} - service : {{ correspondant.service }}
{% endif %} {% endif %}
<br> <br>
<a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=offre[1].entreprise_id) }}">lien vers l'entreprise</a><br> <a href="{{ url_for('entreprises.fiche_entreprise', entreprise_id=offre.entreprise_id) }}">lien vers l'entreprise</a><br>
{% for fichier in offre[2] %} {% for filedir, filename in files %}
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=offre[1].entreprise_id, offre_id=offre[1].id, filedir=fichier[0], filename=fichier[1]) }}">{{ fichier[1] }}</a><br> <a href="{{ url_for('entreprises.get_offre_file', entreprise_id=offre.entreprise_id, offre_id=offre.id, filedir=filedir, filename=filename) }}">{{ filename }}</a><br>
{% endfor %} {% endfor %}
</div> </div>
<div> <div>
<a href="{{ url_for('entreprises.delete_offre_recue', envoi_offre_id=offre[0].id) }}" style="margin-left: 5px;"><img title="Supprimer" alt="supprimer" width="16" height="16" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a> <a href="{{ url_for('entreprises.delete_offre_recue', envoi_offre_id=envoi_offre.id) }}" style="margin-left: 5px;"><img title="Supprimer" alt="supprimer" width="16" height="16" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}