1
0
forked from ScoDoc/ScoDoc

ajout error + offre obsolète

This commit is contained in:
Arthur ZHU 2021-12-30 19:37:46 +01:00
parent 63f40fc940
commit 3d4b903acf
3 changed files with 55 additions and 1 deletions

View File

@ -88,6 +88,15 @@ class EntrepriseOffre(db.Model):
missions = db.Column(db.Text)
duree = db.Column(db.Text)
def to_dict(self):
return {
"intitule": self.intitule,
"description": self.description,
"type_offre": self.type_offre,
"missions": self.missions,
"duree": self.duree,
}
class EntrepriseLog(db.Model):
__tablename__ = "entreprise_log"
@ -117,3 +126,12 @@ class EntrepriseEnvoiOffre(db.Model):
receiver_id = db.Column(db.Integer, db.ForeignKey("user.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("entreprise_offre.id"))
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
class EntrepriseEnvoiOffreEtudiant(db.Model):
__tablename__ = "entreprise_envoi_offre_etudiant"
id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id"))
receiver_id = db.Column(db.Integer, db.ForeignKey("identite.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("entreprise_offre.id"))
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())

View File

@ -1,6 +1,6 @@
import os
from config import Config
from datetime import datetime
from datetime import datetime, timedelta
import glob
import shutil
@ -123,6 +123,10 @@ def fiche_entreprise(id):
offres = entreprise.offres
offres_with_files = []
for offre in offres:
if datetime.now() - offre.date_ajout.replace(tzinfo=None) >= timedelta(
days=90
): # pour une date d'expiration ?
break
files = []
path = os.path.join(
Config.SCODOC_VAR_DIR,
@ -626,6 +630,8 @@ def json_etudiants():
Retourne:
le JSON de tous les étudiants (nom, prenom, formation actuelle?) correspondant au terme
"""
if request.args.get("term") == None:
abort(400)
term = request.args.get("term").strip()
etudiants = Identite.query.filter(Identite.nom.ilike(f"%{term}%")).all()
list = []
@ -657,6 +663,8 @@ def json_responsables():
Retourne:
le JSON de tous les utilisateurs (nom, prenom, login) correspondant au terme
"""
if request.args.get("term") == None:
abort(400)
term = request.args.get("term").strip()
responsables = User.query.filter(
User.nom.ilike(f"%{term}%"), User.nom.is_not(None), User.prenom.is_not(None)

View File

@ -97,6 +97,33 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"entreprise_envoi_offre_etudiant",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.Column("offre_id", sa.Integer(), nullable=True),
sa.Column(
"date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.ForeignKeyConstraint(
["offre_id"],
["entreprise_offre.id"],
),
sa.ForeignKeyConstraint(
["sender_id"],
["user.id"],
),
sa.ForeignKeyConstraint(
["receiver_id"],
["identite.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.drop_constraint(
"entreprise_contact_entreprise_corresp_id_fkey",
"entreprise_contact",
@ -249,6 +276,7 @@ def downgrade():
op.drop_column("entreprise_contact", "nom")
op.drop_table("entreprise_envoi_offre")
op.drop_table("entreprise_envoi_offre_etudiant")
op.drop_table("entreprise_offre")
op.drop_table("entreprise_etudiant")
op.drop_table("entreprise_log")