forked from ScoDoc/ScoDoc
ajout page offres, insertion en base des différents objets, enrichissement des champs
This commit is contained in:
parent
9477106e9a
commit
178016b682
@ -67,11 +67,13 @@ class OffreModificationForm(FlaskForm):
|
|||||||
submit = SubmitField("Modifier")
|
submit = SubmitField("Modifier")
|
||||||
|
|
||||||
class ContactCreationForm(FlaskForm):
|
class ContactCreationForm(FlaskForm):
|
||||||
|
hidden_entreprise_id = HiddenField()
|
||||||
nom = StringField("Nom", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
|
nom = StringField("Nom", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE)])
|
||||||
prenom = StringField("Pré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)])
|
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")])
|
mail = EmailField("Mail", validators=[DataRequired(message=DATA_REQUIRED_ERROR_MESSAGE), Email(message="Adresse e-mail invalide")])
|
||||||
hidden_entreprise_id = HiddenField()
|
poste = StringField("Poste", validators=[])
|
||||||
|
service = StringField("Service", validators=[])
|
||||||
submit = SubmitField("Envoyer")
|
submit = SubmitField("Envoyer")
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
@ -21,7 +21,8 @@ from app.entreprises.models import (
|
|||||||
EntrepriseOffre,
|
EntrepriseOffre,
|
||||||
EntrepriseContact,
|
EntrepriseContact,
|
||||||
EntrepriseLog,
|
EntrepriseLog,
|
||||||
EntrepriseEtudiant
|
EntrepriseEtudiant,
|
||||||
|
EntrepriseEnvoiOffre
|
||||||
)
|
)
|
||||||
from app.models import (
|
from app.models import (
|
||||||
Identite
|
Identite
|
||||||
@ -52,10 +53,16 @@ def fiche_entreprise(id):
|
|||||||
contacts = entreprise.contacts
|
contacts = entreprise.contacts
|
||||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).filter_by(object=id).limit(LOGS_LEN).all()
|
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).filter_by(object=id).limit(LOGS_LEN).all()
|
||||||
historique = db.session.query(EntrepriseEtudiant, Identite).order_by(EntrepriseEtudiant.date_debut.desc()).\
|
historique = db.session.query(EntrepriseEtudiant, Identite).order_by(EntrepriseEtudiant.date_debut.desc()).\
|
||||||
filter_by(entreprise_id=id).\
|
filter(EntrepriseEtudiant.entreprise_id == id).\
|
||||||
join(Identite, Identite.id == EntrepriseEtudiant.etudid).all()
|
join(Identite, Identite.id == EntrepriseEtudiant.etudid).all()
|
||||||
return render_template("entreprises/fiche_entreprise.html", title=("Fiche entreprise"), entreprise=entreprise, contacts=contacts, offres=offres, logs=logs, historique=historique)
|
return render_template("entreprises/fiche_entreprise.html", title=("Fiche entreprise"), entreprise=entreprise, contacts=contacts, offres=offres, logs=logs, historique=historique)
|
||||||
|
|
||||||
|
@bp.route("/offres", methods=["GET"])
|
||||||
|
def offres():
|
||||||
|
offres_recus = db.session.query(EntrepriseEnvoiOffre, EntrepriseOffre).filter(EntrepriseEnvoiOffre.user_id == current_user.id).\
|
||||||
|
join(EntrepriseOffre, EntrepriseOffre.id == EntrepriseEnvoiOffre.offre_id).all()
|
||||||
|
return render_template("entreprises/offres.html", title=("Offres"), offres_recus=offres_recus)
|
||||||
|
|
||||||
@bp.route("/add_entreprise", methods=["GET", "POST"])
|
@bp.route("/add_entreprise", methods=["GET", "POST"])
|
||||||
def add_entreprise():
|
def add_entreprise():
|
||||||
form = EntrepriseCreationForm()
|
form = EntrepriseCreationForm()
|
||||||
@ -245,7 +252,9 @@ def add_contact(id):
|
|||||||
nom=form.nom.data.strip(),
|
nom=form.nom.data.strip(),
|
||||||
prenom=form.prenom.data.strip(),
|
prenom=form.prenom.data.strip(),
|
||||||
telephone=form.telephone.data.strip(),
|
telephone=form.telephone.data.strip(),
|
||||||
mail=form.mail.data.strip()
|
mail=form.mail.data.strip(),
|
||||||
|
poste=form.poste.data.strip(),
|
||||||
|
service=form.service.data.strip()
|
||||||
)
|
)
|
||||||
log = EntrepriseLog(
|
log = EntrepriseLog(
|
||||||
authenticated_user = current_user.user_name,
|
authenticated_user = current_user.user_name,
|
||||||
@ -268,6 +277,8 @@ def edit_contact(id):
|
|||||||
contact.prenom = form.prenom.data.strip()
|
contact.prenom = form.prenom.data.strip()
|
||||||
contact.telephone = form.telephone.data.strip()
|
contact.telephone = form.telephone.data.strip()
|
||||||
contact.mail = form.mail.data.strip()
|
contact.mail = form.mail.data.strip()
|
||||||
|
contact.poste = form.poste.data.strip()
|
||||||
|
contact.service = form.service.data.strip()
|
||||||
log = EntrepriseLog(
|
log = EntrepriseLog(
|
||||||
authenticated_user = current_user.user_name,
|
authenticated_user = current_user.user_name,
|
||||||
object = contact.entreprise_id,
|
object = contact.entreprise_id,
|
||||||
@ -282,6 +293,8 @@ def edit_contact(id):
|
|||||||
form.prenom.data = contact.prenom
|
form.prenom.data = contact.prenom
|
||||||
form.telephone.data = contact.telephone
|
form.telephone.data = contact.telephone
|
||||||
form.mail.data = contact.mail
|
form.mail.data = contact.mail
|
||||||
|
form.poste.data = contact.poste
|
||||||
|
form.service.data = contact.service
|
||||||
return render_template("entreprises/form.html", title=("Modification contact"), form=form)
|
return render_template("entreprises/form.html", title=("Modification contact"), form=form)
|
||||||
|
|
||||||
@bp.route("/delete_contact/<id>", methods=["GET", "POST"])
|
@bp.route("/delete_contact/<id>", methods=["GET", "POST"])
|
||||||
@ -335,9 +348,20 @@ def add_historique(id):
|
|||||||
|
|
||||||
@bp.route("/envoyer_offre/<id>", methods=["GET", "POST"])
|
@bp.route("/envoyer_offre/<id>", methods=["GET", "POST"])
|
||||||
def envoyer_offre(id):
|
def envoyer_offre(id):
|
||||||
|
offre = EntrepriseOffre.query.filter_by(id=id).first_or_404()
|
||||||
form = EnvoiOffreForm()
|
form = EnvoiOffreForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
print("tmp") # faire l'envoie du mail
|
responsable_data = form.responsable.data.upper().strip()
|
||||||
|
stm = text("SELECT id, UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')')) FROM \"user\" WHERE UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')'))=:responsable_data")
|
||||||
|
responsable = User.query.from_statement(stm).params(responsable_data=responsable_data).first()
|
||||||
|
envoi_offre = EntrepriseEnvoiOffre(
|
||||||
|
user_id = responsable.id,
|
||||||
|
offre_id = offre.id
|
||||||
|
)
|
||||||
|
db.session.add(envoi_offre)
|
||||||
|
db.session.commit()
|
||||||
|
flash(f"L'offre a été envoyé à {responsable.get_nomplogin()}.")
|
||||||
|
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||||
return render_template("entreprises/envoi_offre_form.html", title=("Envoyer une offre"), form=form)
|
return render_template("entreprises/envoi_offre_form.html", title=("Envoyer une offre"), form=form)
|
||||||
|
|
||||||
@bp.route("/etudiants")
|
@bp.route("/etudiants")
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
<br>
|
<br>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>Aucun contact présent dans la base</div>
|
<div>Aucun contact présent dans la base</div>
|
||||||
<br>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
28
app/templates/entreprises/offres.html
Normal file
28
app/templates/entreprises/offres.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block app_content %}
|
||||||
|
<div class="container">
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
{% if offres_recus %}
|
||||||
|
<div class="table-responsive">
|
||||||
|
<div>
|
||||||
|
{% for offre in offres_recus %}
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Date envoi : {{ offre[0].date_envoi.strftime('%d/%m/%Y %H:%M') }}<br>
|
||||||
|
Intitulé : {{ offre[1].intitule }}<br>
|
||||||
|
Description : {{ offre[1].description }}<br>
|
||||||
|
Type de l'offre : {{ offre[1].type_offre }}<br>
|
||||||
|
Missions : {{ offre[1].missions }}<br>
|
||||||
|
Durée : {{ offre[1].duree }}<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
{% else %}
|
||||||
|
<div>Aucune offre reçue</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user