forked from ScoDoc/ScoDoc
fichier - formualaire offre, minimum 1 dept pour une offre, ameliorations date expiration
This commit is contained in:
parent
77eefbe483
commit
37832c5bb1
@ -82,13 +82,6 @@ class EntrepriseCreationForm(FlaskForm):
|
|||||||
|
|
||||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
validate = True
|
|
||||||
if not FlaskForm.validate(self):
|
|
||||||
validate = False
|
|
||||||
|
|
||||||
return validate
|
|
||||||
|
|
||||||
def validate_siret(self, siret):
|
def validate_siret(self, siret):
|
||||||
if EntreprisePreferences.get_check_siret():
|
if EntreprisePreferences.get_check_siret():
|
||||||
siret_data = siret.data.replace(" ", "")
|
siret_data = siret.data.replace(" ", "")
|
||||||
@ -151,7 +144,14 @@ class OffreCreationForm(FlaskForm):
|
|||||||
duree = _build_string_field("Durée (*)")
|
duree = _build_string_field("Durée (*)")
|
||||||
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||||
expiration_date = DateField("Date expiration", validators=[Optional()])
|
expiration_date = DateField("Date expiration", validators=[Optional()])
|
||||||
correspondant = SelectField("Correspondant à contacté (*)", validators=[Optional()])
|
correspondant = SelectField("Correspondant à contacté", validators=[Optional()])
|
||||||
|
fichier = FileField(
|
||||||
|
"Fichier (*)",
|
||||||
|
validators=[
|
||||||
|
Optional(),
|
||||||
|
FileAllowed(["pdf", "docx"], "Fichier .pdf ou .docx uniquement"),
|
||||||
|
],
|
||||||
|
)
|
||||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -168,6 +168,17 @@ class OffreCreationForm(FlaskForm):
|
|||||||
(dept.id, dept.acronym) for dept in Departement.query.all()
|
(dept.id, dept.acronym) for dept in Departement.query.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
validate = True
|
||||||
|
if not FlaskForm.validate(self):
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
if len(self.depts.data) < 1:
|
||||||
|
self.depts.errors.append("Choisir au moins un département")
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
|
|
||||||
class OffreModificationForm(FlaskForm):
|
class OffreModificationForm(FlaskForm):
|
||||||
hidden_entreprise_id = HiddenField()
|
hidden_entreprise_id = HiddenField()
|
||||||
@ -203,6 +214,17 @@ class OffreModificationForm(FlaskForm):
|
|||||||
(dept.id, dept.acronym) for dept in Departement.query.all()
|
(dept.id, dept.acronym) for dept in Departement.query.all()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
validate = True
|
||||||
|
if not FlaskForm.validate(self):
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
if len(self.depts.data) < 1:
|
||||||
|
self.depts.errors.append("Choisir au moins un département")
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
|
|
||||||
class CorrespondantCreationForm(FlaskForm):
|
class CorrespondantCreationForm(FlaskForm):
|
||||||
nom = _build_string_field("Nom (*)", render_kw={"class": "form-control"})
|
nom = _build_string_field("Nom (*)", render_kw={"class": "form-control"})
|
||||||
|
@ -18,7 +18,6 @@ from app.entreprises.forms import (
|
|||||||
SuppressionConfirmationForm,
|
SuppressionConfirmationForm,
|
||||||
OffreCreationForm,
|
OffreCreationForm,
|
||||||
OffreModificationForm,
|
OffreModificationForm,
|
||||||
CorrespondantCreationForm,
|
|
||||||
CorrespondantModificationForm,
|
CorrespondantModificationForm,
|
||||||
ContactCreationForm,
|
ContactCreationForm,
|
||||||
ContactModificationForm,
|
ContactModificationForm,
|
||||||
@ -509,6 +508,19 @@ def add_offre(id):
|
|||||||
dept_id=dept,
|
dept_id=dept,
|
||||||
)
|
)
|
||||||
db.session.add(offre_dept)
|
db.session.add(offre_dept)
|
||||||
|
if form.fichier.data:
|
||||||
|
date = f"{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}"
|
||||||
|
path = os.path.join(
|
||||||
|
Config.SCODOC_VAR_DIR,
|
||||||
|
"entreprises",
|
||||||
|
f"{offre.entreprise_id}",
|
||||||
|
f"{offre.id}",
|
||||||
|
f"{date}",
|
||||||
|
)
|
||||||
|
os.makedirs(path)
|
||||||
|
file = form.fichier.data
|
||||||
|
filename = secure_filename(file.filename)
|
||||||
|
file.save(os.path.join(path, filename))
|
||||||
log = EntrepriseLog(
|
log = EntrepriseLog(
|
||||||
authenticated_user=current_user.user_name,
|
authenticated_user=current_user.user_name,
|
||||||
object=entreprise.id,
|
object=entreprise.id,
|
||||||
|
@ -26,13 +26,16 @@
|
|||||||
closest_form_control.classList.remove("form-control")
|
closest_form_control.classList.remove("form-control")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(document.getElementById("expiration_date").value === "")
|
||||||
|
expiration()
|
||||||
|
|
||||||
document.getElementById("type_offre").addEventListener("change", expiration);
|
document.getElementById("type_offre").addEventListener("change", expiration);
|
||||||
|
|
||||||
function expiration() {
|
function expiration() {
|
||||||
var date = new Date()
|
var date = new Date()
|
||||||
var expiration = document.getElementById("expiration_date")
|
var expiration = document.getElementById("expiration_date")
|
||||||
var type_offre = document.getElementById("type_offre").value
|
var type_offre = document.getElementById("type_offre").value
|
||||||
if (type_offre == "Alternance") {
|
if (type_offre === "Alternance") {
|
||||||
expiration.value = `${date.getFullYear() + 1}-01-01`
|
expiration.value = `${date.getFullYear() + 1}-01-01`
|
||||||
} else {
|
} else {
|
||||||
if(date.getMonth() + 1 < 7)
|
if(date.getMonth() + 1 < 7)
|
||||||
|
Loading…
Reference in New Issue
Block a user