diff --git a/app/entreprises/app_relations_entreprises.py b/app/entreprises/app_relations_entreprises.py index c34c602b..c989c12f 100644 --- a/app/entreprises/app_relations_entreprises.py +++ b/app/entreprises/app_relations_entreprises.py @@ -29,6 +29,7 @@ from config import Config import re import requests import glob +from datetime import date from flask import flash 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): + """ + Retourne l'acronym d'un departement a l'aide de son id + """ dept = Departement.query.filter_by(id=id).first() if dept is not None: 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): """ - 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() correspondant = EntrepriseCorrespondant.query.filter_by( @@ -162,6 +166,42 @@ def get_offre_files_and_depts(offre: EntrepriseOffre, depts: list): 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): txt = [ "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): """ 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[:] sites_titles = SITES_KEYS[:] @@ -450,7 +491,7 @@ def check_sites_import(m): 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 = [ "siret_entreprise", @@ -482,6 +523,9 @@ def check_site_import(site_data): def check_correspondants_import(m): + """ + Verifie la feuille Excel "Correspondants" de l'importation données + """ ligne = 1 if m[0] != CORRESPONDANTS_KEYS: flash( @@ -557,6 +601,9 @@ def check_correspondant_import(correspondant_data): def list_to_dict(m): + """ + Transforme une liste de liste (matrice) en liste de dictionnaire (key = premiere liste de la matrice) + """ l = [] for data in m[1:]: new_dict = {title: value.strip() for title, value in zip(m[0], data)} diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py index 227e9f8b..44e679f9 100644 --- a/app/entreprises/forms.py +++ b/app/entreprises/forms.py @@ -123,6 +123,7 @@ class EntrepriseCreationForm(FlaskForm): notes = _build_string_field("Notes sur le correspondant", required=False) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -200,6 +201,7 @@ class EntrepriseModificationForm(FlaskForm): ville = _build_string_field("Ville (*)") pays = _build_string_field("Pays", required=False) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -245,6 +247,7 @@ class SiteCreationForm(FlaskForm): ville = _build_string_field("Ville (*)") pays = _build_string_field("Pays", required=False) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -271,6 +274,7 @@ class SiteModificationForm(FlaskForm): ville = _build_string_field("Ville (*)") pays = _build_string_field("Pays", required=False) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -321,6 +325,7 @@ class OffreCreationForm(FlaskForm): ], ) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -368,6 +373,7 @@ class OffreModificationForm(FlaskForm): expiration_date = DateField("Date expiration", validators=[Optional()]) correspondant = SelectField("Correspondant à contacté", validators=[Optional()]) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -450,7 +456,8 @@ class CorrespondantCreationForm(FlaskForm): class CorrespondantsCreationForm(FlaskForm): hidden_site_id = HiddenField() correspondants = FieldList(FormField(CorrespondantCreationForm), min_entries=1) - submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + submit = SubmitField("Envoyer") + cancel = SubmitField("Annuler") def validate(self): validate = True @@ -489,6 +496,7 @@ class CorrespondantsCreationForm(FlaskForm): class CorrespondantModificationForm(FlaskForm): hidden_correspondant_id = HiddenField() hidden_site_id = HiddenField() + hidden_entreprise_id = HiddenField() civilite = SelectField( "Civilité (*)", choices=[("H", "Monsieur"), ("F", "Madame")], @@ -505,7 +513,21 @@ class CorrespondantModificationForm(FlaskForm): service = _build_string_field("Service", required=False) origine = _build_string_field("Origine", 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) + 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): validate = True @@ -543,6 +565,7 @@ class ContactCreationForm(FlaskForm): ) notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)]) submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate_utilisateur(self, utilisateur): utilisateur_data = self.utilisateur.data.upper().strip() @@ -569,6 +592,7 @@ class ContactModificationForm(FlaskForm): ) notes = TextAreaField("Notes (*)", validators=[DataRequired(message=CHAMP_REQUIS)]) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate_utilisateur(self, utilisateur): utilisateur_data = self.utilisateur.data.upper().strip() @@ -602,6 +626,7 @@ class StageApprentissageCreationForm(FlaskForm): ) notes = TextAreaField("Notes") submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -649,6 +674,7 @@ class StageApprentissageModificationForm(FlaskForm): ) notes = TextAreaField("Notes") submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -705,6 +731,7 @@ class TaxeApprentissageForm(FlaskForm): ) notes = TextAreaField("Notes") submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def validate(self): validate = True @@ -738,6 +765,7 @@ class TaxeApprentissageModificationForm(FlaskForm): ) notes = TextAreaField("Notes") submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -755,7 +783,8 @@ class EnvoiOffreForm(FlaskForm): ), min_entries=1, ) - submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE) + submit = SubmitField("Envoyer") + cancel = SubmitField("Annuler") def validate(self): validate = True @@ -795,23 +824,28 @@ class AjoutFichierForm(FlaskForm): ], ) submit = SubmitField("Ajouter", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) class SuppressionConfirmationForm(FlaskForm): submit = SubmitField("Supprimer", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) class DesactivationConfirmationForm(FlaskForm): notes_active = TextAreaField("Notes sur la désactivation", validators=[Optional()]) submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) class ActivationConfirmationForm(FlaskForm): submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) class ValidationConfirmationForm(FlaskForm): submit = SubmitField("Valider", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) class ImportForm(FlaskForm): @@ -833,3 +867,4 @@ class PreferencesForm(FlaskForm): ) check_siret = BooleanField("Vérification SIRET") submit = SubmitField("Valider", render_kw=SUBMIT_MARGE) + cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE) diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index 7060e85b..2d419500 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -66,7 +66,7 @@ from werkzeug.utils import secure_filename @permission_required(Permission.RelationsEntreprisesView) 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) logs = ( @@ -81,12 +81,12 @@ def index(): if checked[0]: entreprises = Entreprise.query.filter_by(visible=True) if checked[1]: - entreprises = Entreprise.query.filter_by(association=True) + entreprises = Entreprise.query.filter_by(visible=True, association=True) 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]: entreprises = Entreprise.query.filter_by( - association=True, siret_provisoire=True + visible=True, association=True, siret_provisoire=True ) return render_template( "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"]) @permission_required(Permission.RelationsEntreprisesCorrespondants) def correspondants(): @@ -155,80 +141,17 @@ def correspondants(): ) -@bp.route("/fiche_entreprise/", methods=["GET"]) -@permission_required(Permission.RelationsEntreprisesView) -def fiche_entreprise(entreprise_id): +@bp.route("/validation", methods=["GET"]) +@permission_required(Permission.RelationsEntreprisesValidate) +def validation(): """ - 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. + Permet d'afficher une page avec la liste des entreprises a valider (non visible) """ - entreprise = Entreprise.query.filter_by( - 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() - ) + entreprises = Entreprise.query.filter_by(visible=False).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//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, + "entreprises/entreprises_validation.html", + title="Validation entreprises", + entreprises=entreprises, ) @@ -250,6 +173,82 @@ def fiche_entreprise_validation(entreprise_id): ) +@bp.route( + "/fiche_entreprise_validation//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"{entreprise.nom}" + 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//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"]) @permission_required(Permission.RelationsEntreprisesView) def offres_recues(): @@ -263,16 +262,16 @@ def offres_recues(): .all() ) offres_recues_with_files = [] - for offre in offres_recues: + for envoi_offre, offre in offres_recues: correspondant = EntrepriseCorrespondant.query.filter_by( - id=offre[1].correspondant_id + id=offre.correspondant_id ).first() files = [] path = os.path.join( Config.SCODOC_VAR_DIR, "entreprises", - f"{offre[1].entreprise_id}", - f"{offre[1].id}", + f"{offre.entreprise_id}", + f"{offre.id}", ) if os.path.exists(path): for dir in glob.glob( @@ -281,7 +280,7 @@ def offres_recues(): for file in glob.glob(f"{dir}/*"): file = [os.path.basename(dir), os.path.basename(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( "entreprises/offres_recues.html", title="Offres reçues", @@ -289,29 +288,42 @@ def offres_recues(): ) -@bp.route("/fiche_entreprise//offres_expirees") +@bp.route( + "/offres_recues/delete_offre_recue/", methods=["GET", "POST"] +) @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( - id=entreprise_id, visible=True - ).first_or_404(description=f"fiche entreprise {entreprise_id} inconnue") - offres_expirees_with_files = [] - depts = are.get_depts() - for offre in entreprise.offres: - if offre.expired or ( - offre.expiration_date is not None and date.today() > offre.expiration_date - ): - offre_expiree_with_files = are.get_offre_files_and_depts(offre, depts) - if offre_expiree_with_files is not None: - offres_expirees_with_files.append(offre_expiree_with_files) + 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("/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 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( - "entreprises/offres_expirees.html", - title="Offres expirées", - entreprise=entreprise, - offres_expirees=offres_expirees_with_files, + "entreprises/preferences.html", + title="Préférences", + form=form, ) @@ -322,6 +334,8 @@ def add_entreprise(): Permet d'ajouter une entreprise dans la base avec un formulaire """ form = EntrepriseCreationForm() + if request.method == "POST" and form.cancel.data: + return redirect(url_for("entreprises.index")) if form.validate_on_submit(): entreprise = Entreprise( nom=form.nom_entreprise.data.strip(), @@ -400,6 +414,89 @@ def add_entreprise(): ) +@bp.route("/fiche_entreprise/", 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//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//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( "/fiche_entreprise//edit_entreprise", methods=["GET", "POST"] ) @@ -412,6 +509,10 @@ def edit_entreprise(entreprise_id): id=entreprise_id, visible=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): lien_entreprise = f"{form.nom.data.strip()}" logs_text = [] @@ -489,6 +590,10 @@ def fiche_entreprise_desactiver(entreprise_id): id=entreprise_id, visible=True, active=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): entreprise.notes_active = form.notes_active.data.strip() entreprise.active = False @@ -522,6 +627,10 @@ def fiche_entreprise_activer(entreprise_id): id=entreprise_id, visible=True, active=False ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): entreprise.active = True lien_entreprise = f"{entreprise.nom}" @@ -556,6 +665,10 @@ def add_taxe_apprentissage(entreprise_id): id=entreprise_id, visible=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): taxe = EntrepriseTaxeApprentissage( 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}" ) 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(): taxe.montant = form.montant.data 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}" ) 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(): db.session.delete(taxe) log = EntrepriseHistorique( @@ -661,70 +782,6 @@ def delete_taxe_apprentissage(entreprise_id, taxe_id): ) -@bp.route( - "/fiche_entreprise_validation//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"{entreprise.nom}" - 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//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//add_offre", methods=["GET", "POST"]) @permission_required(Permission.RelationsEntreprisesChange) def add_offre(entreprise_id): @@ -735,6 +792,10 @@ def add_offre(entreprise_id): id=entreprise_id, visible=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): offre = EntrepriseOffre( 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}" ) 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( 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(): offre.intitule = form.intitule.data.strip() offre.description = form.description.data.strip() @@ -878,6 +943,10 @@ def delete_offre(entreprise_id, offre_id): ) entreprise_id = offre.entreprise.id 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(): db.session.delete(offre) path = os.path.join( @@ -909,22 +978,6 @@ def delete_offre(entreprise_id, offre_id): ) -@bp.route( - "/offres_recues/delete_offre_recue/", 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( "/fiche_entreprise//expired/", methods=["GET", "POST"], @@ -956,10 +1009,17 @@ def expired(entreprise_id, offre_id): ) @permission_required(Permission.RelationsEntreprisesChange) def add_site(entreprise_id): + """ + Permet d'ajouter un site a une entreprise + """ entreprise = Entreprise.query.filter_by( id=entreprise_id, visible=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): site = EntrepriseSite( entreprise_id=entreprise.id, @@ -998,6 +1058,9 @@ def add_site(entreprise_id): methods=["GET", "POST"], ) def edit_site(entreprise_id, site_id): + """ + Permet de modifier une offre + """ site = EntrepriseSite.query.filter_by( id=site_id, entreprise_id=entreprise_id ).first_or_404( @@ -1006,6 +1069,10 @@ def edit_site(entreprise_id, site_id): form = SiteModificationForm( 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(): site.nom = form.nom.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}" ) 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(): for correspondant_entry in form.correspondants.entries: correspondant = EntrepriseCorrespondant( @@ -1118,7 +1189,13 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id): form = CorrespondantModificationForm( hidden_site_id=correspondant.site.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(): correspondant.civilite = form.civilite.data 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.origine = form.origine.data.strip() correspondant.notes = form.notes.data.strip() + correspondant.site_id = form.site.data log = EntrepriseHistorique( authenticated_user=current_user.user_name, entreprise_id=correspondant.site.entreprise.id, @@ -1189,6 +1267,10 @@ def delete_correspondant(entreprise_id, site_id, correspondant_id): ) ) 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(): db.session.delete(correspondant) log = EntrepriseHistorique( @@ -1215,6 +1297,24 @@ def delete_correspondant(entreprise_id, site_id, correspondant_id): ) +@bp.route("/fiche_entreprise//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( "/fiche_entreprise//contacts/add_contact", methods=["GET", "POST"], @@ -1233,6 +1333,8 @@ def add_contact(entreprise_id): if current_user.nom and current_user.prenom else "", ) + if request.method == "POST" and form.cancel.data: + return redirect(url_for("entreprises.contacts", entreprise_id=entreprise_id)) if form.validate_on_submit(): utilisateur_data = form.utilisateur.data.upper().strip() stm = text( @@ -1284,6 +1386,8 @@ def edit_contact(entreprise_id, contact_id): description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}" ) 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(): utilisateur_data = form.utilisateur.data.upper().strip() stm = text( @@ -1338,6 +1442,8 @@ def delete_contact(entreprise_id, contact_id): description=f"contact {contact_id} inconnu pour l'entreprise {entreprise_id}" ) 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(): db.session.delete(contact) log = EntrepriseHistorique( @@ -1360,24 +1466,6 @@ def delete_contact(entreprise_id, contact_id): ) -@bp.route("/fiche_entreprise//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( "/fiche_entreprise//add_stage_apprentissage", methods=["GET", "POST"], @@ -1391,6 +1479,10 @@ def add_stage_apprentissage(entreprise_id): id=entreprise_id, visible=True ).first_or_404(description=f"entreprise {entreprise_id} inconnue") 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(): etudiant_nomcomplet = form.etudiant.data.upper().strip() stm = text( @@ -1457,6 +1549,10 @@ def edit_stage_apprentissage(entreprise_id, stage_apprentissage_id): description=f"etudiant {stage_apprentissage.etudid} inconnue" ) 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(): etudiant_nomcomplet = form.etudiant.data.upper().strip() stm = text( @@ -1522,6 +1618,10 @@ def delete_stage_apprentissage(entreprise_id, stage_apprentissage_id): id=stage_apprentissage_id, entreprise_id=entreprise_id ).first_or_404(description=f"stage_apprentissage {stage_apprentissage_id} inconnu") 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(): db.session.delete(stage_apprentissage) log = EntrepriseHistorique( @@ -1562,6 +1662,10 @@ def envoyer_offre(entreprise_id, offre_id): description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" ) 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(): for responsable in form.responsables.entries: if responsable.data.strip(): @@ -1666,7 +1770,7 @@ def export_donnees(): @bp.route("/import_donnees/get_file_sample") @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 """ @@ -1801,6 +1905,10 @@ def add_offre_file(entreprise_id, offre_id): description=f"offre {offre_id} inconnue pour l'entreprise {entreprise_id}" ) 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(): date = f"{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}" 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}" ) 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(): path = os.path.join( 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) 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) diff --git a/app/static/css/entreprises.css b/app/static/css/entreprises.css index 947f90fb..7f86d9d7 100644 --- a/app/static/css/entreprises.css +++ b/app/static/css/entreprises.css @@ -184,6 +184,10 @@ padding-left: 0; } -#form-entreprise-filter > label { +#form-entreprise-filter > div { + display: inline-block; +} + +#form-entreprise-filter > div > label { margin-right: 20px; } \ No newline at end of file diff --git a/app/templates/entreprises/_offre.html b/app/templates/entreprises/_offre.html index 4ae08232..188cb692 100644 --- a/app/templates/entreprises/_offre.html +++ b/app/templates/entreprises/_offre.html @@ -1,53 +1,53 @@ {# -*- mode: jinja-html -*- #}
- Ajouté le {{ offre[0].date_ajout.strftime('%d/%m/%y') }} à {{ offre[0].date_ajout.strftime('%Hh%M') }}
- Intitulé : {{ offre[0].intitule }}
- Description : {{ offre[0].description }}
- Type de l'offre : {{ offre[0].type_offre }}
- Missions : {{ offre[0].missions }}
- Durée : {{ offre[0].duree }}
- {% if offre[2] %} - Département(s) : {% for offre_dept in offre[2] %}
{{ offre_dept.dept_id|get_dept_acronym }}
{% endfor %}
+ Ajouté le {{ offre.date_ajout.strftime('%d/%m/%y') }} à {{ offre.date_ajout.strftime('%Hh%M') }}
+ Intitulé : {{ offre.intitule }}
+ Description : {{ offre.description }}
+ Type de l'offre : {{ offre.type_offre }}
+ Missions : {{ offre.missions }}
+ Durée : {{ offre.duree }}
+ {% if offre_depts %} + Département(s) : {% for offre_dept in offre_depts %}
{{ offre_dept.dept_id|get_dept_acronym }}
{% endfor %}
{% endif %} - {% if offre[0].correspondant_id %} - Contacté {{ offre[3].nom }} {{ offre[3].prenom }} - {% if offre[3].mail and offre[3].telephone %} - ({{ offre[3].mail }} - {{ offre[3].telephone }})
+ {% if offre.correspondant_id %} + Contacté {{ correspondant.nom }} {{ correspondant.prenom }} + {% if correspondant.mail and correspondant.telephone %} + ({{ correspondant.mail }} - {{ correspondant.telephone }})
{% else %} - ({{ offre[3].mail }}{{offre[3].telephone}})
+ ({{ correspondant.mail }}{{ correspondant.telephone }})
{% endif %} {% endif %} - {% for fichier in offre[1] %} - {{ fichier[1] }} + {% for filedir, filename in files %} + {{ filename }} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - supprimer + supprimer {% endif %}
{% endfor %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - Ajoutez un fichier + Ajoutez un fichier {% endif %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - Modifier l'offre - Supprimer l'offre + Modifier l'offre + Supprimer l'offre {% endif %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesSend, None) %} - Envoyer l'offre + Envoyer l'offre {% endif %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - {% if not offre[0].expired %} - Rendre expirée + {% if not offre.expired %} + Rendre expirée {% else %} - Rendre non expirée + Rendre non expirée {% endif %} {% endif %}
diff --git a/app/templates/entreprises/correspondants.html b/app/templates/entreprises/correspondants.html index 0f89ffc6..d4ce6322 100644 --- a/app/templates/entreprises/correspondants.html +++ b/app/templates/entreprises/correspondants.html @@ -37,15 +37,15 @@ - {% for correspondant in correspondants %} + {% for correspondant, site in correspondants %} - {{ correspondant[0].nom }} - {{ correspondant[0].prenom }} - {{ correspondant[0].telephone }} - {{ correspondant[0].mail }} - {{ correspondant[0].poste}} - {{ correspondant[0].service}} - {{ correspondant[1].nom }} + {{ correspondant.nom }} + {{ correspondant.prenom }} + {{ correspondant.telephone }} + {{ correspondant.mail }} + {{ correspondant.poste}} + {{ correspondant.service}} + {{ site.nom }} {% endfor %} diff --git a/app/templates/entreprises/entreprises.html b/app/templates/entreprises/entreprises.html index dda33de4..89fd97be 100644 --- a/app/templates/entreprises/entreprises.html +++ b/app/templates/entreprises/entreprises.html @@ -39,9 +39,9 @@ {% if form %}
{{ form.hidden_tag() }} - {{ form.active.label }} - {{ form.association.label }} - {{ form.siret_provisoire.label }} +
{{ form.active.label }}
+
{{ form.association.label }}
+
{{ form.siret_provisoire.label }}
{% endif %} @@ -61,7 +61,7 @@ {% for entreprise in entreprises %} - + diff --git a/app/templates/entreprises/fiche_entreprise.html b/app/templates/entreprises/fiche_entreprise.html index 6535ff73..c895348a 100644 --- a/app/templates/entreprises/fiche_entreprise.html +++ b/app/templates/entreprises/fiche_entreprise.html @@ -48,7 +48,7 @@
- SIRET : {{ entreprise.siret }}
+ SIRET {% if entreprise.siret_provisoire %}provisoire{% endif %} : {{ entreprise.siret }}
Nom : {{ entreprise.nom }}
Adresse : {{ entreprise.adresse }}
Code postal : {{ entreprise.codepostal }}
@@ -126,7 +126,7 @@ {% if offres %}

Offres - Voir les offres expirées

- {% for offre in offres %} + {% for offre, files, offre_depts, correspondant in offres %} {% include 'entreprises/_offre.html' %} {% endfor %}
@@ -155,15 +155,15 @@
- {% for data in stages_apprentissages %} + {% for stage_apprentissage, etudiant in stages_apprentissages %} - - - - - - - + + + + + + + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} diff --git a/app/templates/entreprises/fiche_entreprise_validation.html b/app/templates/entreprises/fiche_entreprise_validation.html index 9ee189c1..f4b6f718 100644 --- a/app/templates/entreprises/fiche_entreprise_validation.html +++ b/app/templates/entreprises/fiche_entreprise_validation.html @@ -2,12 +2,23 @@ {% extends 'base.html' %} {% block app_content %} +
+ +
+

Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})

- SIRET : {{ entreprise.siret }}
+ SIRET {% if entreprise.siret_provisoire %}provisoire{% endif %} : {{ entreprise.siret }}
Nom : {{ entreprise.nom }}
Adresse : {{ entreprise.adresse }}
Code postal : {{ entreprise.codepostal }}
diff --git a/app/templates/entreprises/form_ajout_correspondants.html b/app/templates/entreprises/form_ajout_correspondants.html index fd0fe64b..3690a347 100644 --- a/app/templates/entreprises/form_ajout_correspondants.html +++ b/app/templates/entreprises/form_ajout_correspondants.html @@ -32,7 +32,8 @@ {{ form.correspondants }}
- + {{ form.submit(class_="btn btn-default") }} + {{ form.cancel(class_="btn btn-default") }}
diff --git a/app/templates/entreprises/form_envoi_offre.html b/app/templates/entreprises/form_envoi_offre.html index e8f2d55e..860ce372 100644 --- a/app/templates/entreprises/form_envoi_offre.html +++ b/app/templates/entreprises/form_envoi_offre.html @@ -25,7 +25,8 @@ {{ form.responsables }}
- + {{ form.submit(class_="btn btn-default") }} + {{ form.cancel(class_="btn btn-default") }}
diff --git a/app/templates/entreprises/import_donnees.html b/app/templates/entreprises/import_donnees.html index 9fa12df2..ee883862 100644 --- a/app/templates/entreprises/import_donnees.html +++ b/app/templates/entreprises/import_donnees.html @@ -22,7 +22,7 @@

{{ title }}



diff --git a/app/templates/entreprises/offres_expirees.html b/app/templates/entreprises/offres_expirees.html index 52736dff..06142d41 100644 --- a/app/templates/entreprises/offres_expirees.html +++ b/app/templates/entreprises/offres_expirees.html @@ -19,7 +19,7 @@

Offres expirées - {{ entreprise.nom }}

{% if offres_expirees %} - {% for offre in offres_expirees %} + {% for offre, files, offre_depts, correspondant in offres_expirees %} {% include 'entreprises/_offre.html' %} {% endfor %} {% else %} diff --git a/app/templates/entreprises/offres_recues.html b/app/templates/entreprises/offres_recues.html index 779de74f..ce7719b9 100644 --- a/app/templates/entreprises/offres_recues.html +++ b/app/templates/entreprises/offres_recues.html @@ -7,41 +7,41 @@

Offres reçues

{% if offres_recues %} - {% for offre in offres_recues %} + {% for envoi_offre, offre, files, correspondant in offres_recues %}
- 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 }}
- Intitulé : {{ offre[1].intitule }}
- Description : {{ offre[1].description }}
- Type de l'offre : {{ offre[1].type_offre }}
- Missions : {{ offre[1].missions }}
- Durée : {{ offre[1].duree }}
+ 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 }}
+ Intitulé : {{ offre.intitule }}
+ Description : {{ offre.description }}
+ Type de l'offre : {{ offre.type_offre }}
+ Missions : {{ offre.missions }}
+ Durée : {{ offre.duree }}
- {% if offre[1].correspondant_id %} - Contacté {{ offre[3].nom }} {{ offre[3].prenom }} - {% if offre[3].mail and offre[3].telephone %} - ({{ offre[3].mail }} - {{ offre[3].telephone }}) + {% if offre.correspondant_id %} + Contacté {{ correspondant.nom }} {{ correspondant.prenom }} + {% if correspondant.mail and correspondant.telephone %} + ({{ correspondant.mail }} - {{ correspondant.telephone }}) {% else %} - ({{ offre[3].mail }}{{ offre[3].telephone }}) + ({{ correspondant.mail }}{{ correspondant.telephone }}) {% endif %} {% endif %} - {% if offre[3].poste %} - , poste : {{ offre[3].poste }} + {% if correspondant.poste %} + - poste : {{ correspondant.poste }} {% endif %} - {% if offre[3].service %} - , service : {{ offre[3].service }} + {% if correspondant.service %} + - service : {{ correspondant.service }} {% endif %}
- lien vers l'entreprise
+ lien vers l'entreprise
- {% for fichier in offre[2] %} - {{ fichier[1] }}
+ {% for filedir, filename in files %} + {{ filename }}
{% endfor %}
- supprimer + supprimer
{% endfor %}
{{ entreprise.siret }}{{ entreprise.siret }} {{ entreprise.nom }} {{ entreprise.adresse }} {{ entreprise.codepostal }}
{{ data[0].date_debut.strftime('%d/%m/%Y') }}{{ data[0].date_fin.strftime('%d/%m/%Y') }}{{ (data[0].date_fin-data[0].date_debut).days//7 }} semaines{{ data[0].type_offre }}{{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }}{% if data[0].formation_text %}{{ data[0].formation_text }}{% endif %}{{ data[0].notes }}{{ stage_apprentissage.date_debut.strftime('%d/%m/%Y') }}{{ stage_apprentissage.date_fin.strftime('%d/%m/%Y') }}{{ (stage_apprentissage.date_fin-stage_apprentissage.date_debut).days//7 }} semaines{{ stage_apprentissage.type_offre }}{{ etudiant.nom|format_nom }} {{ etudiant.prenom|format_prenom }}{% if stage_apprentissage.formation_text %}{{ stage_apprentissage.formation_text }}{% endif %}{{ stage_apprentissage.notes }}
@@ -171,8 +171,8 @@