forked from ScoDoc/ScoDoc
Compare commits
2 Commits
48c16d761f
...
259b2a449d
Author | SHA1 | Date | |
---|---|---|---|
259b2a449d | |||
e34ae9b3ec |
|
@ -81,8 +81,8 @@ def _build_string_field(label, required=True, render_kw=None):
|
|||
|
||||
|
||||
class EntreprisesFilterForm(FlaskForm):
|
||||
active = BooleanField("Afficher les entreprises désactivés")
|
||||
association = BooleanField("Afficher les associations partenaires")
|
||||
active = BooleanField("Toutes les entreprises")
|
||||
association = BooleanField("Seulement les associations partenaires")
|
||||
|
||||
|
||||
class EntrepriseCreationForm(FlaskForm):
|
||||
|
@ -662,7 +662,6 @@ class TaxeApprentissageForm(FlaskForm):
|
|||
|
||||
|
||||
class TaxeApprentissageModificationForm(FlaskForm):
|
||||
hidden_annee = HiddenField()
|
||||
annee = IntegerField("Année (*)")
|
||||
montant = IntegerField(
|
||||
"Montant (*)",
|
||||
|
|
|
@ -137,7 +137,9 @@ class EntrepriseLog(db.Model):
|
|||
id = db.Column(db.Integer, primary_key=True)
|
||||
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
||||
authenticated_user = db.Column(db.Text)
|
||||
object = db.Column(db.Integer)
|
||||
entreprise_id = db.Column(db.Integer)
|
||||
object = db.Column(db.Text)
|
||||
object_id = db.Column(db.Integer)
|
||||
text = db.Column(db.Text)
|
||||
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ def fiche_entreprise(id):
|
|||
sites = entreprise.sites[:]
|
||||
logs = (
|
||||
EntrepriseLog.query.order_by(EntrepriseLog.date.desc())
|
||||
.filter_by(object=id)
|
||||
.filter(EntrepriseLog.entreprise_id == id)
|
||||
.limit(LOGS_LEN)
|
||||
.all()
|
||||
)
|
||||
|
@ -216,7 +216,7 @@ def logs_entreprise(id):
|
|||
)
|
||||
logs = (
|
||||
EntrepriseLog.query.order_by(EntrepriseLog.date.desc())
|
||||
.filter_by(object=id)
|
||||
.filter(EntrepriseLog.entreprise_id == id)
|
||||
.paginate(page=page, per_page=20)
|
||||
)
|
||||
return render_template(
|
||||
|
@ -362,6 +362,7 @@ def add_entreprise():
|
|||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
text=f"{nom_entreprise} - Création de la fiche entreprise ({entreprise.nom})",
|
||||
entreprise_id=entreprise.id,
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
|
@ -398,7 +399,7 @@ def edit_entreprise(id):
|
|||
if entreprise.nom != form.nom.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du nom (ancien nom: {entreprise.nom})",
|
||||
)
|
||||
entreprise.nom = form.nom.data.strip()
|
||||
|
@ -406,7 +407,7 @@ def edit_entreprise(id):
|
|||
if entreprise.adresse != form.adresse.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})",
|
||||
)
|
||||
entreprise.adresse = form.adresse.data.strip()
|
||||
|
@ -414,7 +415,7 @@ def edit_entreprise(id):
|
|||
if entreprise.codepostal != form.codepostal.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})",
|
||||
)
|
||||
entreprise.codepostal = form.codepostal.data.strip()
|
||||
|
@ -422,7 +423,7 @@ def edit_entreprise(id):
|
|||
if entreprise.ville != form.ville.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})",
|
||||
)
|
||||
entreprise.ville = form.ville.data.strip()
|
||||
|
@ -430,7 +431,7 @@ def edit_entreprise(id):
|
|||
if entreprise.pays != form.pays.data.strip() or not form.pays.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du pays (ancien pays: {entreprise.pays})",
|
||||
)
|
||||
entreprise.pays = (
|
||||
|
@ -604,7 +605,8 @@ def validate_entreprise(id):
|
|||
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{entreprise.nom}</a>"
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
text=f"{nom_entreprise} - Validation de la fiche entreprise ({entreprise.nom}) avec un correspondant",
|
||||
entreprise_id=entreprise.id,
|
||||
text=f"{nom_entreprise} - Validation de la fiche entreprise ({entreprise.nom})",
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
|
@ -688,7 +690,9 @@ def add_offre(id):
|
|||
file.save(os.path.join(path, filename))
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=entreprise.id,
|
||||
object="offre",
|
||||
object_id=offre.id,
|
||||
text="Création d'une offre",
|
||||
)
|
||||
db.session.add(log)
|
||||
|
@ -740,7 +744,9 @@ def edit_offre(id):
|
|||
db.session.delete(offre_dept)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=offre.entreprise_id,
|
||||
entreprise_id=offre.entreprise_id,
|
||||
object="offre",
|
||||
object_id=offre.id,
|
||||
text="Modification d'une offre",
|
||||
)
|
||||
db.session.add(log)
|
||||
|
@ -785,7 +791,9 @@ def delete_offre(id):
|
|||
shutil.rmtree(path)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=offre.entreprise_id,
|
||||
entreprise_id=offre.entreprise_id,
|
||||
object="offre",
|
||||
object_id=offre.id,
|
||||
text="Suppression d'une offre",
|
||||
)
|
||||
db.session.add(log)
|
||||
|
@ -925,13 +933,17 @@ def add_correspondant(id_entreprise, id_site):
|
|||
origine=correspondant_entry.origine.data.strip(),
|
||||
notes=correspondant_entry.notes.data.strip(),
|
||||
)
|
||||
db.session.add(correspondant)
|
||||
db.session.commit()
|
||||
db.session.refresh(correspondant)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
entreprise_id=correspondant.entreprise_id,
|
||||
object="correspondant",
|
||||
object_id=correspondant.id,
|
||||
text="Création d'un correspondant",
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.add(correspondant)
|
||||
db.session.commit()
|
||||
flash("Le correspondant a été ajouté à la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
|
@ -967,7 +979,9 @@ def edit_correspondant(id):
|
|||
correspondant.notes = form.notes.data.strip()
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=correspondant.entreprise_id,
|
||||
entreprise_id=correspondant.entreprise_id,
|
||||
object="correspondant",
|
||||
object_id=correspondant.id,
|
||||
text="Modification d'un correspondant",
|
||||
)
|
||||
db.session.add(log)
|
||||
|
@ -1007,7 +1021,9 @@ def delete_correspondant(id):
|
|||
db.session.delete(correspondant)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=correspondant.entreprise_id,
|
||||
entreprise_id=correspondant.entreprise_id,
|
||||
object="correspondant",
|
||||
object_id=correspondant.id,
|
||||
text="Suppression d'un correspondant",
|
||||
)
|
||||
db.session.add(log)
|
||||
|
|
|
@ -121,3 +121,7 @@
|
|||
list-style: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
#form-entreprise-filter > label {
|
||||
margin-right: 20px;
|
||||
}
|
|
@ -37,10 +37,10 @@
|
|||
<div class="container" style="margin-bottom: 10px;">
|
||||
<h1>Liste des entreprises</h1>
|
||||
{% if form %}
|
||||
<form method="POST" action="">
|
||||
<form id="form-entreprise-filter" method="POST" action="">
|
||||
{{ form.hidden_tag() }}
|
||||
<input id="active" name="active" type="checkbox" onChange="form.submit()" {% if checked[0] %} checked {% endif %}> <label for="active" style="margin-right:20px">Afficher les entreprises désactivés</label>
|
||||
<input id="association" name="association" type="checkbox" onChange="form.submit()" {% if checked[1] %} checked {% endif %}> <label for="association">Afficher les associations partenaires</label>
|
||||
<input id="active" name="active" type="checkbox" onChange="form.submit()" {% if checked[0] %} checked {% endif %}> {{ form.active.label }}
|
||||
<input id="association" name="association" type="checkbox" onChange="form.submit()" {% if checked[1] %} checked {% endif %}> {{ form.association.label }}
|
||||
</form>
|
||||
{% endif %}
|
||||
<table id="table-entreprises">
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
{% for taxe in taxes %}
|
||||
<li>
|
||||
<a href="{{ url_for('entreprises.delete_taxe_apprentissage', id_entreprise=entreprise.id, id_taxe=taxe.id) }}"><img title="Supprimer taxe d'apprentissage" alt="supprimer" width="10" height="9" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a>
|
||||
<a href="{{ url_for('entreprises.edit_taxe_apprentissage', id_entreprise=entreprise.id, id_taxe=taxe.id) }}">{{ taxe.annee }}</a> : {{ taxe.montant }} euros
|
||||
<a href="{{ url_for('entreprises.edit_taxe_apprentissage', id_entreprise=entreprise.id, id_taxe=taxe.id) }}">{{ taxe.annee }}</a> : {{ taxe.montant }} euros {% if taxe.notes %}- {{ taxe.notes}} {% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
"""ajout taxe apprentissage, association, changement historique
|
||||
|
||||
Revision ID: 2b872cb116ca
|
||||
Revises: d5b3bdd1d622
|
||||
Create Date: 2022-05-06 18:16:58.727052
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "2b872cb116ca"
|
||||
down_revision = "d5b3bdd1d622"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
"are_taxe_apprentissage",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("entreprise_id", sa.Integer(), nullable=True),
|
||||
sa.Column("annee", sa.Integer(), nullable=True),
|
||||
sa.Column("montant", sa.Integer(), nullable=True),
|
||||
sa.Column("notes", sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.add_column(
|
||||
"are_entreprises", sa.Column("association", sa.Boolean(), nullable=True)
|
||||
)
|
||||
op.add_column("are_logs", sa.Column("entreprise_id", sa.Integer(), nullable=True))
|
||||
op.add_column("are_logs", sa.Column("object_id", sa.Integer(), nullable=True))
|
||||
op.alter_column(
|
||||
"are_logs",
|
||||
"object",
|
||||
existing_type=sa.INTEGER(),
|
||||
type_=sa.Text(),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_scolar_news_authenticated_user"),
|
||||
"scolar_news",
|
||||
["authenticated_user"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(op.f("ix_scolar_news_date"), "scolar_news", ["date"], unique=False)
|
||||
op.create_index(
|
||||
op.f("ix_scolar_news_object"), "scolar_news", ["object"], unique=False
|
||||
)
|
||||
op.create_index(op.f("ix_scolar_news_type"), "scolar_news", ["type"], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_scolar_news_type"), table_name="scolar_news")
|
||||
op.drop_index(op.f("ix_scolar_news_object"), table_name="scolar_news")
|
||||
op.drop_index(op.f("ix_scolar_news_date"), table_name="scolar_news")
|
||||
op.drop_index(op.f("ix_scolar_news_authenticated_user"), table_name="scolar_news")
|
||||
op.execute(
|
||||
"alter table are_logs alter column object set data type int using object::integer"
|
||||
)
|
||||
op.alter_column(
|
||||
"are_logs",
|
||||
"object",
|
||||
existing_type=sa.Text(),
|
||||
type_=sa.INTEGER(),
|
||||
existing_nullable=True,
|
||||
)
|
||||
op.drop_column("are_logs", "object_id")
|
||||
op.drop_column("are_logs", "entreprise_id")
|
||||
op.drop_column("are_entreprises", "association")
|
||||
op.drop_table("are_taxe_apprentissage")
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user