forked from ScoDoc/ScoDoc
refactoring, page erreur (bp entreprises)
This commit is contained in:
parent
5806cd29a7
commit
781744a8fa
@ -367,10 +367,10 @@ def add_entreprise():
|
||||
db.session.add(correspondant)
|
||||
if current_user.has_permission(Permission.RelationsEntreprisesValidate, None):
|
||||
entreprise.visible = True
|
||||
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
|
||||
lien_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
text=f"{nom_entreprise} - Création de la fiche entreprise ({entreprise.nom})",
|
||||
text=f"{lien_entreprise} - Création de la fiche entreprise ({entreprise.nom})",
|
||||
entreprise_id=entreprise.id,
|
||||
)
|
||||
db.session.add(log)
|
||||
@ -404,50 +404,49 @@ def edit_entreprise(id):
|
||||
)
|
||||
form = EntrepriseModificationForm(siret=entreprise.siret)
|
||||
if form.validate_on_submit():
|
||||
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{form.nom.data.strip()}</a>"
|
||||
lien_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{form.nom.data.strip()}</a>"
|
||||
logs_text = []
|
||||
if entreprise.nom != form.nom.data.strip():
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du nom (ancien nom: {entreprise.nom})",
|
||||
logs_text.append(
|
||||
f"{lien_entreprise} - Modification du nom (ancien nom: {entreprise.nom})"
|
||||
)
|
||||
entreprise.nom = form.nom.data.strip()
|
||||
db.session.add(log)
|
||||
|
||||
if entreprise.adresse != form.adresse.data.strip():
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})",
|
||||
logs_text.append(
|
||||
f"{lien_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})"
|
||||
)
|
||||
entreprise.adresse = form.adresse.data.strip()
|
||||
db.session.add(log)
|
||||
|
||||
if entreprise.codepostal != form.codepostal.data.strip():
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})",
|
||||
logs_text.append(
|
||||
f"{lien_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})"
|
||||
)
|
||||
entreprise.codepostal = form.codepostal.data.strip()
|
||||
db.session.add(log)
|
||||
|
||||
if entreprise.ville != form.ville.data.strip():
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})",
|
||||
logs_text.append(
|
||||
f"{lien_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})"
|
||||
)
|
||||
entreprise.ville = form.ville.data.strip()
|
||||
db.session.add(log)
|
||||
|
||||
if entreprise.pays != form.pays.data.strip() or not form.pays.data.strip():
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du pays (ancien pays: {entreprise.pays})",
|
||||
logs_text.append(
|
||||
f"{lien_entreprise} - Modification du pays (ancien pays: {entreprise.pays})"
|
||||
)
|
||||
entreprise.pays = (
|
||||
form.pays.data.strip() if form.pays.data.strip() else "FRANCE"
|
||||
)
|
||||
db.session.add(log)
|
||||
|
||||
entreprise.association = form.association.data
|
||||
for log_text in logs_text:
|
||||
db.session.add(
|
||||
EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
text=log_text,
|
||||
)
|
||||
)
|
||||
db.session.commit()
|
||||
flash("L'entreprise a été modifié.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
@ -865,6 +864,7 @@ def add_site(id):
|
||||
)
|
||||
form = SiteCreationForm(hidden_entreprise_id=id)
|
||||
if form.validate_on_submit():
|
||||
lien_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom} - {form.nom.data.strip()}</a>"
|
||||
site = EntrepriseSite(
|
||||
entreprise_id=entreprise.id,
|
||||
nom=form.nom.data.strip(),
|
||||
@ -875,6 +875,16 @@ def add_site(id):
|
||||
)
|
||||
db.session.add(site)
|
||||
db.session.commit()
|
||||
db.session.refresh(site)
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=entreprise.id,
|
||||
object="site",
|
||||
object_id=site.id,
|
||||
text=f"{lien_entreprise} - Création d'un site",
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
flash("Le site a été créé et ajouté à la fiche entreprise")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template(
|
||||
@ -1157,7 +1167,7 @@ def contacts(id):
|
||||
"entreprises/contacts.html",
|
||||
title="Liste des contacts",
|
||||
contacts=contacts,
|
||||
entreprise_id=id,
|
||||
entreprise=entreprise,
|
||||
)
|
||||
|
||||
|
||||
@ -1602,3 +1612,8 @@ def preferences():
|
||||
title="Préférences",
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@bp.errorhandler(404)
|
||||
def not_found_error_handler(e):
|
||||
return render_template("entreprises/error.html", title="Erreur", e=e)
|
||||
|
@ -1,37 +1,85 @@
|
||||
.nav-entreprise {
|
||||
/* nav */
|
||||
|
||||
.nav_entreprise {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.nav-entreprise ul {
|
||||
.nav_entreprise > ul {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.nav-entreprise li{
|
||||
.nav_entreprise_item {
|
||||
list-style: none;
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
margin: 2px;
|
||||
border: 2px black solid;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.nav-entreprise li:hover{
|
||||
.nav_entreprise_item:hover {
|
||||
background-color: rgb(212, 212, 212);
|
||||
}
|
||||
|
||||
.nav-entreprise>ul>li>a {
|
||||
.nav_entreprise_link {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.nav-entreprise>ul>li>a:hover {
|
||||
.nav_entreprise_link:hover {
|
||||
text-decoration: underline;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.nav_entreprise_link-active {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* breadcrumbs */
|
||||
|
||||
.breadcrumbs {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.breadcrumbs_item {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.breadcrumbs_item:not(:last-of-type)::after {
|
||||
content: '\203a';
|
||||
margin: 0 5px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.breadcrumbs_link {
|
||||
text-decoration: none;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.breadcrumbs_link:hover {
|
||||
text-decoration: underline;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.breadcrumbs_link-active {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* form error */
|
||||
|
||||
.title-form-error {
|
||||
font-weight: bold;
|
||||
color: #a94442;
|
||||
}
|
||||
|
||||
.form-error {
|
||||
color: #a94442;
|
||||
}
|
||||
|
||||
/* entreprises */
|
||||
|
||||
.boutons .btn {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
@ -139,37 +187,3 @@
|
||||
#form-entreprise-filter > label {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.title-form-error {
|
||||
font-weight: bold;
|
||||
color: #a94442;
|
||||
}
|
||||
|
||||
.breadcrumbs {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.breadcrumbs_item {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.breadcrumbs_item:not(:last-of-type)::after {
|
||||
content: '\203a';
|
||||
margin: 0 5px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.breadcrumbs_link {
|
||||
text-decoration: none;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.breadcrumbs_link:hover {
|
||||
text-decoration: underline;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.breadcrumbs_link-active {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
<a href="{{ url_for('entreprises.index') }}" class="breadcrumbs_link">Entreprises</a>
|
||||
</li>
|
||||
<li class="breadcrumbs_item">
|
||||
<a href="{{ url_for('entreprises.fiche_entreprise', id=entreprise_id) }}" class="breadcrumbs_link">Fiche entreprise</a>
|
||||
<a href="{{ url_for('entreprises.fiche_entreprise', id=entreprise.id) }}" class="breadcrumbs_link">Fiche entreprise</a>
|
||||
</li>
|
||||
<li class="breadcrumbs_item">
|
||||
<a href="" class="breadcrumbs_link breadcrumbs_link-active">Contacts</a>
|
||||
@ -26,7 +26,7 @@
|
||||
<div class="container" style="margin-bottom: 10px;">
|
||||
<h1>Liste des contacts</h1>
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
|
||||
<a class="btn btn-primary" style="margin-bottom:10px;" href="{{ url_for('entreprises.add_contact', id=entreprise_id) }}">Ajouter contact</a>
|
||||
<a class="btn btn-primary" style="margin-bottom:10px;" href="{{ url_for('entreprises.add_contact', id=entreprise.id) }}">Ajouter contact</a>
|
||||
{% endif %}
|
||||
<table id="table-contacts">
|
||||
<thead>
|
||||
|
14
app/templates/entreprises/error.html
Normal file
14
app/templates/entreprises/error.html
Normal file
@ -0,0 +1,14 @@
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block app_content %}
|
||||
|
||||
<h2>Erreur !</h2>
|
||||
|
||||
{{ e }}
|
||||
|
||||
<p>
|
||||
<a href="{{ url_for('entreprises.index') }}">Retour</a>
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
@ -1,15 +1,28 @@
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
<div class="container">
|
||||
<nav class="nav-entreprise">
|
||||
<nav class="nav_entreprise">
|
||||
<ul>
|
||||
<li><a href="{{ url_for('entreprises.index') }}">Entreprises</a></li>
|
||||
<li class="nav_entreprise_item">
|
||||
<a href="{{ url_for('entreprises.index') }}" class="nav_entreprise_link {% if title=='Entreprises' %}nav_entreprise_link-active{% endif %}">Entreprises</a>
|
||||
</li>
|
||||
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesCorrespondants, None) %}
|
||||
<li><a href="{{ url_for('entreprises.correspondants') }}">Correspondants</a></li>
|
||||
<li class="nav_entreprise_item">
|
||||
<a href="{{ url_for('entreprises.correspondants') }}" class="nav_entreprise_link {% if title=='Correspondants' %}nav_entreprise_link-active{% endif %}">Correspondants</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li><a href="{{ url_for('entreprises.offres_recues') }}">Offres reçues</a></li>
|
||||
|
||||
<li class="nav_entreprise_item">
|
||||
<a href="{{ url_for('entreprises.offres_recues') }}" class="nav_entreprise_link {% if title=='Offres reçues' %}nav_entreprise_link-active{% endif %}">Offres reçues</a>
|
||||
</li>
|
||||
|
||||
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesValidate, None) %}
|
||||
<li><a href="{{ url_for('entreprises.validation') }}">Entreprises à valider</a></li>
|
||||
<li><a href="{{ url_for('entreprises.preferences') }}">Préférences</a></li>
|
||||
<li class="nav_entreprise_item">
|
||||
<a href="{{ url_for('entreprises.validation') }}" class="nav_entreprise_link {% if title=='Validation entreprises' %}nav_entreprise_link-active{% endif %}">Entreprises à valider</a>
|
||||
</li>
|
||||
<li class="nav_entreprise_item">
|
||||
<a href="{{ url_for('entreprises.preferences') }}" class="nav_entreprise_link {% if title=='Préférences' %}nav_entreprise_link-active{% endif %}">Préférences</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
|
Loading…
Reference in New Issue
Block a user