Compare commits

...

3 Commits

7 changed files with 138 additions and 79 deletions

3
.gitignore vendored
View File

@ -173,3 +173,6 @@ Thumbs.db
.idea/ .idea/
copy copy
# Symlinks static ScoDoc
app/static/links/[0-9]*.*[0-9]

View File

@ -153,4 +153,4 @@ def liste_semestres_courant(dept_ident: str):
FormSemestre.date_fin >= app.db.func.now(), FormSemestre.date_fin >= app.db.func.now(),
) )
return jsonify([d.to_dict() for d in formsemestres]) return jsonify([d.to_dict(convert_parcours=True) for d in formsemestres])

View File

@ -367,10 +367,10 @@ def add_entreprise():
db.session.add(correspondant) db.session.add(correspondant)
if current_user.has_permission(Permission.RelationsEntreprisesValidate, None): if current_user.has_permission(Permission.RelationsEntreprisesValidate, None):
entreprise.visible = True 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( log = EntrepriseHistorique(
authenticated_user=current_user.user_name, 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, entreprise_id=entreprise.id,
) )
db.session.add(log) db.session.add(log)
@ -404,50 +404,49 @@ def edit_entreprise(id):
) )
form = EntrepriseModificationForm(siret=entreprise.siret) form = EntrepriseModificationForm(siret=entreprise.siret)
if form.validate_on_submit(): 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(): if entreprise.nom != form.nom.data.strip():
log = EntrepriseHistorique( logs_text.append(
authenticated_user=current_user.user_name, f"{lien_entreprise} - Modification du nom (ancien nom: {entreprise.nom})"
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Modification du nom (ancien nom: {entreprise.nom})",
) )
entreprise.nom = form.nom.data.strip() entreprise.nom = form.nom.data.strip()
db.session.add(log)
if entreprise.adresse != form.adresse.data.strip(): if entreprise.adresse != form.adresse.data.strip():
log = EntrepriseHistorique( logs_text.append(
authenticated_user=current_user.user_name, f"{lien_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})"
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})",
) )
entreprise.adresse = form.adresse.data.strip() entreprise.adresse = form.adresse.data.strip()
db.session.add(log)
if entreprise.codepostal != form.codepostal.data.strip(): if entreprise.codepostal != form.codepostal.data.strip():
log = EntrepriseHistorique( logs_text.append(
authenticated_user=current_user.user_name, f"{lien_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})"
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})",
) )
entreprise.codepostal = form.codepostal.data.strip() entreprise.codepostal = form.codepostal.data.strip()
db.session.add(log)
if entreprise.ville != form.ville.data.strip(): if entreprise.ville != form.ville.data.strip():
log = EntrepriseHistorique( logs_text.append(
authenticated_user=current_user.user_name, f"{lien_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})"
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})",
) )
entreprise.ville = form.ville.data.strip() entreprise.ville = form.ville.data.strip()
db.session.add(log)
if entreprise.pays != form.pays.data.strip() or not form.pays.data.strip(): if entreprise.pays != form.pays.data.strip() or not form.pays.data.strip():
log = EntrepriseHistorique( logs_text.append(
authenticated_user=current_user.user_name, f"{lien_entreprise} - Modification du pays (ancien pays: {entreprise.pays})"
entreprise_id=entreprise.id,
text=f"{nom_entreprise} - Modification du pays (ancien pays: {entreprise.pays})",
) )
entreprise.pays = ( entreprise.pays = (
form.pays.data.strip() if form.pays.data.strip() else "FRANCE" form.pays.data.strip() if form.pays.data.strip() else "FRANCE"
) )
db.session.add(log)
entreprise.association = form.association.data 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() db.session.commit()
flash("L'entreprise a été modifié.") flash("L'entreprise a été modifié.")
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id)) return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
@ -865,6 +864,7 @@ def add_site(id):
) )
form = SiteCreationForm(hidden_entreprise_id=id) form = SiteCreationForm(hidden_entreprise_id=id)
if form.validate_on_submit(): 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( site = EntrepriseSite(
entreprise_id=entreprise.id, entreprise_id=entreprise.id,
nom=form.nom.data.strip(), nom=form.nom.data.strip(),
@ -875,6 +875,16 @@ def add_site(id):
) )
db.session.add(site) db.session.add(site)
db.session.commit() 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") flash("Le site a été créé et ajouté à la fiche entreprise")
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id)) return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
return render_template( return render_template(
@ -1157,7 +1167,7 @@ def contacts(id):
"entreprises/contacts.html", "entreprises/contacts.html",
title="Liste des contacts", title="Liste des contacts",
contacts=contacts, contacts=contacts,
entreprise_id=id, entreprise=entreprise,
) )
@ -1602,3 +1612,8 @@ def preferences():
title="Préférences", title="Préférences",
form=form, form=form,
) )
@bp.errorhandler(404)
def not_found_error_handler(e):
return render_template("entreprises/error.html", title="Erreur", e=e)

View File

@ -1,37 +1,85 @@
.nav-entreprise { /* nav */
.nav_entreprise {
text-align: left; text-align: left;
} }
.nav-entreprise ul { .nav_entreprise > ul {
padding: 0; padding: 0;
} }
.nav-entreprise li{ .nav_entreprise_item {
list-style: none; list-style: none;
display: inline-block; display: inline-block;
padding: 10px; padding: 10px;
margin: 2px;
border: 2px black solid; border: 2px black solid;
border-radius: 10px; border-radius: 10px;
} }
.nav-entreprise li:hover{ .nav_entreprise_item:hover {
background-color: rgb(212, 212, 212); background-color: rgb(212, 212, 212);
} }
.nav-entreprise>ul>li>a { .nav_entreprise_link {
text-decoration: none; text-decoration: none;
color: black; color: black;
padding: 15px; padding: 15px;
} }
.nav-entreprise>ul>li>a:hover { .nav_entreprise_link:hover {
text-decoration: underline; 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 { .form-error {
color: #a94442; color: #a94442;
} }
/* entreprises */
.boutons .btn { .boutons .btn {
margin-top: 5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
@ -90,7 +138,7 @@
flex: 1 0 0; flex: 1 0 0;
} }
.taxe-apprentissage{ .taxe-apprentissage {
overflow-y: scroll; overflow-y: scroll;
height: 100px; height: 100px;
} }
@ -138,38 +186,4 @@
#form-entreprise-filter > label { #form-entreprise-filter > label {
margin-right: 20px; 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;
} }

View File

@ -15,7 +15,7 @@
<a href="{{ url_for('entreprises.index') }}" class="breadcrumbs_link">Entreprises</a> <a href="{{ url_for('entreprises.index') }}" class="breadcrumbs_link">Entreprises</a>
</li> </li>
<li class="breadcrumbs_item"> <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>
<li class="breadcrumbs_item"> <li class="breadcrumbs_item">
<a href="" class="breadcrumbs_link breadcrumbs_link-active">Contacts</a> <a href="" class="breadcrumbs_link breadcrumbs_link-active">Contacts</a>
@ -26,7 +26,7 @@
<div class="container" style="margin-bottom: 10px;"> <div class="container" style="margin-bottom: 10px;">
<h1>Liste des contacts</h1> <h1>Liste des contacts</h1>
{% 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" 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 %} {% endif %}
<table id="table-contacts"> <table id="table-contacts">
<thead> <thead>

View 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 %}

View File

@ -1,15 +1,28 @@
{# -*- mode: jinja-html -*- #} {# -*- mode: jinja-html -*- #}
<div class="container"> <div class="container">
<nav class="nav-entreprise"> <nav class="nav_entreprise">
<ul> <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) %} {% 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 %} {% 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) %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesValidate, None) %}
<li><a href="{{ url_for('entreprises.validation') }}">Entreprises à valider</a></li> <li class="nav_entreprise_item">
<li><a href="{{ url_for('entreprises.preferences') }}">Préférences</a></li> <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 %} {% endif %}
</ul> </ul>
</nav> </nav>