diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py
index d2f3762b..1ce49cc0 100644
--- a/app/entreprises/forms.py
+++ b/app/entreprises/forms.py
@@ -1,10 +1,10 @@
from flask import flash
-from markupsafe import Markup
-from flask.app import Flask
-import requests, re
from flask_wtf import FlaskForm
-from wtforms import StringField, SubmitField, TextAreaField, SelectField, FileField, HiddenField
+from markupsafe import Markup
+import requests, re
+from wtforms import StringField, SubmitField, TextAreaField, SelectField, HiddenField
from wtforms.fields.html5 import EmailField, DateField
+from flask_wtf.file import FileField, FileAllowed
from wtforms.validators import ValidationError, DataRequired, Email
from app.entreprises.models import Entreprise, EntrepriseContact
from app.models import Identite
@@ -15,18 +15,20 @@ from sqlalchemy import text
DATA_REQUIRED_ERROR_MESSAGE = "Ce champ est requis"
class EntrepriseCreationForm(FlaskForm):
- siret = StringField("SIRET", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)], render_kw={"placeholder": "Numéro composé de 14 chiffres"})
+ siret = StringField("SIRET", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)], render_kw={"placeholder": "Numéro composé de 14 chiffres", "maxlength": "14"})
nom_entreprise = StringField("Nom de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
adresse = StringField("Adresse de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
codepostal = StringField("Code postal de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
ville = StringField("Ville de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- pays = StringField("Pays de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
+ pays = StringField("Pays de l'entreprise", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)], render_kw={"style": "margin-bottom: 50px;"})
nom_contact = StringField("Nom du contact", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
prenom_contact = StringField("Prénom du contact", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
telephone = StringField("Téléphone du contact", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
mail = EmailField("Mail du contact", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE), Email(message="Adresse e-mail invalide")])
- submit = SubmitField("Envoyer")
+ poste = StringField("Poste du contact", validators=[])
+ service = StringField("Service du contact", validators=[])
+ submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
def validate_siret(self, siret):
siret = siret.data.strip()
@@ -47,7 +49,7 @@ class EntrepriseModificationForm(FlaskForm):
codepostal = StringField("Code postal", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
ville = StringField("Ville", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
pays = StringField("Pays", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- submit = SubmitField("Modifier")
+ submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"})
class OffreCreationForm(FlaskForm):
intitule = StringField("Intitulé", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
@@ -55,8 +57,8 @@ class OffreCreationForm(FlaskForm):
type_offre = SelectField("Type de l'offre", choices=[('Stage'), ('Alternance')], validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
missions = TextAreaField("Missions", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
duree = StringField("Durée", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- ficher = FileField("Fichier", validators=[])
- submit = SubmitField("Envoyer")
+ fichier = FileField("Fichier", validators=[FileAllowed(['pdf', 'docx'], 'Fichier .pdf ou .docx uniquement')])
+ submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
class OffreModificationForm(FlaskForm):
intitule = StringField("Intitulé", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
@@ -64,15 +66,17 @@ class OffreModificationForm(FlaskForm):
type_offre = SelectField("Type de l'offre", choices=[('Stage'), ('Alternance')], validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
missions = TextAreaField("Missions", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
duree = StringField("Durée", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- submit = SubmitField("Modifier")
+ submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"})
class ContactCreationForm(FlaskForm):
+ hidden_entreprise_id = HiddenField()
nom = StringField("Nom", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
prenom = StringField("Prénom", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
telephone = StringField("Téléphone", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
mail = EmailField("Mail", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE), Email(message="Adresse e-mail invalide")])
- hidden_entreprise_id = HiddenField()
- submit = SubmitField("Envoyer")
+ poste = StringField("Poste", validators=[])
+ service = StringField("Service", validators=[])
+ submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
def validate(self):
rv = FlaskForm.validate(self)
@@ -97,14 +101,16 @@ class ContactModificationForm(FlaskForm):
prenom = StringField("Prénom", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
telephone = StringField("Téléphone", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
mail = EmailField("Mail", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE), Email(message="Adresse e-mail invalide")])
- submit = SubmitField("Modifier")
+ poste = StringField("Poste", validators=[])
+ service = StringField("Service", validators=[])
+ submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"})
class HistoriqueCreationForm(FlaskForm):
etudiant = StringField("Étudiant", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)], render_kw={"placeholder": "Tapez le nom de l'étudiant puis selectionnez"})
type_offre = SelectField("Type de l'offre", choices=[('Stage'), ('Alternance')], validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
date_debut = DateField("Date début", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
date_fin = DateField("Date fin", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- submit = SubmitField("Envoyer")
+ submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
def validate(self):
rv = FlaskForm.validate(self)
@@ -126,7 +132,7 @@ class HistoriqueCreationForm(FlaskForm):
class EnvoiOffreForm(FlaskForm):
responsable = StringField("Responsable de formation", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
- submit = SubmitField("Envoyer")
+ submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
def validate_responsable(self, responsable):
responsable_data = responsable.data.upper().strip()
@@ -136,4 +142,4 @@ class EnvoiOffreForm(FlaskForm):
raise ValidationError("Champ incorrect (selectionnez dans la liste)")
class SuppressionConfirmationForm(FlaskForm):
- submit = SubmitField("Supprimer")
\ No newline at end of file
+ submit = SubmitField("Supprimer", render_kw={"style": "margin-bottom: 10px;"})
\ No newline at end of file
diff --git a/app/entreprises/models.py b/app/entreprises/models.py
index ec963be2..3e2211e2 100644
--- a/app/entreprises/models.py
+++ b/app/entreprises/models.py
@@ -12,27 +12,48 @@ class Entreprise(db.Model):
contacts = db.relationship('EntrepriseContact', backref='entreprise', lazy='dynamic', cascade="all, delete-orphan")
offres = db.relationship('EntrepriseOffre', backref='entreprise', lazy='dynamic', cascade="all, delete-orphan")
+ def to_dict_export(self):
+ return {
+ "siret": self.siret,
+ "nom": self.nom,
+ "adresse": self.adresse,
+ "codepostal": self.codepostal,
+ "ville": self.ville,
+ "pays": self.pays
+ }
+
class EntrepriseContact(db.Model):
__tablename__ = "entreprise_contact"
id = db.Column(db.Integer, primary_key=True)
- entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id"))
+ entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id", ondelete="cascade"))
nom = db.Column(db.Text)
prenom = db.Column(db.Text)
telephone = db.Column(db.Text)
mail = db.Column(db.Text)
poste = db.Column(db.Text)
service = db.Column(db.Text)
+
+ def to_dict_export(self):
+ return {
+ "nom": self.nom,
+ "prenom": self.prenom,
+ "telephone": self.telephone,
+ "mail": self.mail,
+ "poste": self.poste,
+ "service": self.service
+ }
class EntrepriseOffre(db.Model):
__tablename__ = "entreprise_offre"
id = db.Column(db.Integer, primary_key=True)
- entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id"))
+ entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id", ondelete="cascade"))
date_ajout = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
intitule = db.Column(db.Text)
description = db.Column(db.Text)
type_offre = db.Column(db.Text)
missions = db.Column(db.Text)
duree = db.Column(db.Text)
+ filename = db.Column(db.Text)
class EntrepriseLog(db.Model):
__tablename__ = "entreprise_log"
diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py
index 1791199e..94af6a75 100644
--- a/app/entreprises/routes.py
+++ b/app/entreprises/routes.py
@@ -1,9 +1,13 @@
-from flask import render_template, redirect, url_for, request, flash
+import os
+from config import Config
+
+from flask import render_template, redirect, url_for, request, flash, send_file, abort
from flask.json import jsonify
from flask_login import current_user
+
from app.decorators import permission_required
+
from app.entreprises import LOGS_LEN
-from app.scodoc.sco_permissions import Permission
from app.entreprises.forms import (
EntrepriseCreationForm,
EntrepriseModificationForm,
@@ -21,16 +25,21 @@ from app.entreprises.models import (
EntrepriseOffre,
EntrepriseContact,
EntrepriseLog,
- EntrepriseEtudiant
+ EntrepriseEtudiant,
+ EntrepriseEnvoiOffre
)
from app.models import (
Identite
)
from app.auth.models import User
from app.scodoc.sco_find_etud import search_etud_by_name
+from app.scodoc.sco_permissions import Permission
+from app.scodoc import sco_etud, sco_excel
+import app.scodoc.sco_utils as scu
+
from app import db
-from app.scodoc import sco_etud
from sqlalchemy import text
+from werkzeug.utils import secure_filename, send_from_directory
@bp.route("/", methods=["GET"])
def index():
@@ -45,17 +54,23 @@ def contacts():
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
return render_template("entreprises/contacts.html", title=("Contacts"), contacts=contacts, logs=logs)
-@bp.route("/fiche_entreprise/
Missions : {{ offre.missions }}
Durée : {{ offre.duree }}
+ {% if offre.filename %}
+ {{ offre.filename }}
+ {% endif %}