From a064d1aac8182c9a18e06af4730dcc5baa00ff0c Mon Sep 17 00:00:00 2001
From: Arthur ZHU
Date: Thu, 27 Jan 2022 16:28:28 +0100
Subject: [PATCH] =?UTF-8?q?page=20=20diff=C3=A9rente=20selon=20les=20permi?=
=?UTF-8?q?ssions=20de=20l'utilisateur?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/entreprises/routes.py | 26 +++++++++----------
app/scodoc/sco_permissions.py | 1 +
app/templates/entreprises/_contact.html | 2 ++
app/templates/entreprises/_offre.html | 9 +++++++
app/templates/entreprises/contacts.html | 2 ++
app/templates/entreprises/entreprises.html | 12 +++++++--
.../entreprises/fiche_entreprise.html | 2 ++
7 files changed, 39 insertions(+), 15 deletions(-)
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//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"{form.nom.data.strip()}"
@@ -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/", 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 %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
+ {% endif %}
\ 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 }}
{% for fichier in offre[1] %}
{{ fichier[1] }}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
+ {% endif %}
{% endfor %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
Ajoutez un fichier
+ {% endif %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
Modifier l'offre
Supprimer l'offre
+ {% endif %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesSend, None) %}
Envoyer l'offre
+ {% endif %}
+
\ 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 @@
Aucun contact présent dans la base
{% endif %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %}
+ {% endif %}
{% 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 @@
Code postal |
Ville |
Pays |
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
Action |
+ {% endif %}
{% for entreprise in entreprises %}
@@ -34,6 +36,7 @@
{{ entreprise.codepostal }} |
{{ entreprise.ville }} |
{{ entreprise.pays }} |
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
+ {% endif %}
{% endfor %}
@@ -54,9 +58,13 @@
{% endif %}
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 @@
{% endif %}
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
+ {% endif %}
{% endblock %}
\ No newline at end of file