diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index 91383f348..651184920 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -74,7 +74,7 @@ def validation_entreprise(): entreprises = Entreprise.query.filter_by(visible=False).all() return render_template( "entreprises/entreprises_validation.html", - title=("Entreprises"), + title=("Validation entreprises"), entreprises=entreprises, ) @@ -187,7 +187,7 @@ def fiche_entreprise_validation(id): contacts = entreprise.contacts return render_template( "entreprises/fiche_entreprise_validation.html", - title=("Fiche entreprise"), + title=("Validation fiche entreprise"), entreprise=entreprise, contacts=contacts, ) @@ -195,7 +195,7 @@ def fiche_entreprise_validation(id): @bp.route("/offres_recues", methods=["GET"]) @permission_required(Permission.RelationsEntreprisesView) -def offres(): +def offres_recues(): """ Permet d'afficher la page où l'on recoit les offres @@ -222,7 +222,7 @@ def offres(): @bp.route("/fiche_entreprise/<int:id>/offres_expirees") @permission_required(Permission.RelationsEntreprisesView) def offres_expirees(id): - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() offres = entreprise.offres offres_expirees_with_files = [] for offre in offres: @@ -305,7 +305,7 @@ def edit_entreprise(id): id: l'id de l'entreprise """ - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() form = EntrepriseModificationForm() if form.validate_on_submit(): nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{form.nom.data.strip()}</a>" @@ -374,7 +374,7 @@ def delete_entreprise(id): id: l'id de l'entreprise """ - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() form = SuppressionConfirmationForm() if form.validate_on_submit(): db.session.delete(entreprise) @@ -397,7 +397,7 @@ def delete_entreprise(id): @bp.route("/validate_entreprise/<int:id>", methods=["GET", "POST"]) @permission_required(Permission.RelationsEntreprisesValidate) def validate_entreprise(id): - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=False).first_or_404() entreprise.visible = True db.session.commit() return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id)) @@ -413,7 +413,7 @@ def add_offre(id): id: l'id de l'entreprise """ - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() form = OffreCreationForm() if form.validate_on_submit(): offre = EntrepriseOffre( @@ -517,7 +517,7 @@ def add_contact(id): id: l'id de l'entreprise """ - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() form = ContactCreationForm(hidden_entreprise_id=entreprise.id) if form.validate_on_submit(): contact = EntrepriseContact( @@ -632,7 +632,7 @@ def add_historique(id): id: l'id de l'entreprise """ - entreprise = Entreprise.query.filter_by(id=id).first_or_404() + entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404() form = HistoriqueCreationForm() if form.validate_on_submit(): etudiant_nomcomplet = form.etudiant.data.upper().strip() @@ -770,7 +770,7 @@ def export_entreprises(): """ Permet d'exporter la liste des entreprises sous format excel (.xlsx) """ - entreprises = Entreprise.query.all() + entreprises = Entreprise.query.filter_by(visible=True).all() if entreprises: keys = ["siret", "nom", "adresse", "ville", "codepostal", "pays"] titles = keys[:] @@ -792,7 +792,7 @@ def export_contacts(): """ Permet d'exporter la liste des contacts sous format excel (.xlsx) """ - contacts = EntrepriseContact.query.all() + contacts = EntrepriseContact.query.filter_by(visible=True).all() if contacts: keys = ["nom", "prenom", "telephone", "mail", "poste", "service"] titles = keys[:] @@ -811,7 +811,7 @@ def export_contacts_bis(): """ Permet d'exporter la liste des contacts avec leur entreprise sous format excel (.xlsx) """ - contacts = EntrepriseContact.query.all() + contacts = EntrepriseContact.query.filter_by(visible=True).all() if contacts: keys = [ "nom", diff --git a/app/scodoc/sco_permissions.py b/app/scodoc/sco_permissions.py index 55981b033..71cfede19 100644 --- a/app/scodoc/sco_permissions.py +++ b/app/scodoc/sco_permissions.py @@ -37,6 +37,7 @@ _SCO_PERMISSIONS = ( (1 << 21, "ScoEditPVJury", "Éditer les PV de jury"), # ajouter maquettes Apogee (=> chef dept et secr): (1 << 22, "ScoEditApo", "Ajouter des maquettes Apogées"), + # application relations entreprises (1 << 23, "RelationsEntreprisesView", "Voir l'application relations entreprises"), (1 << 24, "RelationsEntreprisesChange", "Modifier les entreprises"), ( diff --git a/app/templates/entreprises/_contact.html b/app/templates/entreprises/_contact.html index e7083a26f..29f7bd46f 100644 --- a/app/templates/entreprises/_contact.html +++ b/app/templates/entreprises/_contact.html @@ -13,8 +13,10 @@ {% endif %} </p> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <div style="margin-bottom: 10px;"> <a class="btn btn-primary" href="{{ url_for('entreprises.edit_contact', id=contact.id) }}">Modifier contact</a> <a class="btn btn-danger" href="{{ url_for('entreprises.delete_contact', id=contact.id) }}">Supprimer contact</a> </div> + {% endif %} </div> \ No newline at end of file diff --git a/app/templates/entreprises/_offre.html b/app/templates/entreprises/_offre.html index ea69110e9..a893cf5b6 100644 --- a/app/templates/entreprises/_offre.html +++ b/app/templates/entreprises/_offre.html @@ -8,14 +8,23 @@ Durée : {{ offre[0].duree }}<br> {% for fichier in offre[1] %} <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> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <a href="{{ url_for('entreprises.delete_offre_file', 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><br> + {% endif %} {% endfor %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <a href="{{ url_for('entreprises.add_offre_file', offre_id=offre[0].id) }}">Ajoutez un fichier</a> + {% endif %} </p> <div style="margin-bottom: 10px;"> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <a class="btn btn-primary" href="{{ url_for('entreprises.edit_offre', id=offre[0].id) }}">Modifier l'offre</a> <a class="btn btn-danger" href="{{ url_for('entreprises.delete_offre', id=offre[0].id) }}">Supprimer l'offre</a> + {% endif %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesSend, None) %} <a class="btn btn-primary" href="{{ url_for('entreprises.envoyer_offre', id=offre[0].id) }}">Envoyer l'offre</a> + {% endif %} </div> + </div> \ No newline at end of file diff --git a/app/templates/entreprises/contacts.html b/app/templates/entreprises/contacts.html index 22fb1be92..0d0df6797 100644 --- a/app/templates/entreprises/contacts.html +++ b/app/templates/entreprises/contacts.html @@ -42,11 +42,13 @@ <div>Aucun contact présent dans la base</div> </div> {% endif %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} <div> {% if contacts %} <a class="btn btn-default" href="{{ url_for('entreprises.export_contacts') }}">Exporter la liste des contacts</a> <a class="btn btn-default" href="{{ url_for('entreprises.export_contacts_bis') }}">Exporter la liste des contacts avec leur entreprise</a> {% endif %} </div> + {% endif %} </div> {% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/entreprises.html b/app/templates/entreprises/entreprises.html index fe790a8d6..4dd96a0e0 100644 --- a/app/templates/entreprises/entreprises.html +++ b/app/templates/entreprises/entreprises.html @@ -24,7 +24,9 @@ <th>Code postal</th> <th>Ville</th> <th>Pays</th> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <th>Action</th> + {% endif %} </tr> {% for entreprise in entreprises %} <tr class="table-row active"> @@ -34,6 +36,7 @@ <th>{{ entreprise.codepostal }}</th> <th>{{ entreprise.ville }}</th> <th>{{ entreprise.pays }}</th> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <th> <div class="btn-group"> <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">Action @@ -45,6 +48,7 @@ </ul> </div> </th> + {% endif %} </tr> {% endfor %} </table> @@ -54,9 +58,13 @@ </div> {% endif %} <div style="margin-bottom: 20px;"> - <a class="btn btn-default" href="{{ url_for('entreprises.add_entreprise') }}">Ajouter une entreprise</a> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} + <a class="btn btn-default" href="{{ url_for('entreprises.add_entreprise') }}">Ajouter une entreprise</a> + {% endif %} {% if entreprises %} - <a class="btn btn-default" href="{{ url_for('entreprises.export_entreprises') }}">Exporter la liste des entreprises</a> + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} + <a class="btn btn-default" href="{{ url_for('entreprises.export_entreprises') }}">Exporter la liste des entreprises</a> + {% endif %} {% endif %} </div> </div> diff --git a/app/templates/entreprises/fiche_entreprise.html b/app/templates/entreprises/fiche_entreprise.html index a7cc09632..94bb21476 100644 --- a/app/templates/entreprises/fiche_entreprise.html +++ b/app/templates/entreprises/fiche_entreprise.html @@ -64,6 +64,7 @@ </div> {% endif %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} <div> <a class="btn btn-primary" href="{{ url_for('entreprises.edit_entreprise', id=entreprise.id) }}">Modifier</a> <a class="btn btn-danger" href="{{ url_for('entreprises.delete_entreprise', id=entreprise.id) }}">Supprimer</a> @@ -73,5 +74,6 @@ historique</a> <a class="btn btn-primary" href="{{ url_for('entreprises.offres_expirees', id=entreprise.id) }}">Voir les offres expirées</a> </div> + {% endif %} </div> {% endblock %} \ No newline at end of file