forked from ScoDoc/ScoDoc
ajout page contacts
This commit is contained in:
parent
93d026d2ac
commit
d740244d25
@ -32,12 +32,30 @@ from app import db
|
||||
from app.scodoc import sco_etud
|
||||
from sqlalchemy import text
|
||||
|
||||
@bp.route("/", methods=["GET", "POST"])
|
||||
@bp.route("/", methods=["GET"])
|
||||
def index():
|
||||
entreprises = Entreprise.query.all()
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
||||
return render_template("entreprises/entreprises.html", title=("Entreprises"), entreprises=entreprises, logs=logs)
|
||||
|
||||
@bp.route("/contacts", methods=["GET"])
|
||||
def contacts():
|
||||
contacts = db.session.query(EntrepriseContact, Entreprise).\
|
||||
join(Entreprise, EntrepriseContact.entreprise_id == Entreprise.id).all()
|
||||
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/<id>", methods=["GET"])
|
||||
def fiche_entreprise(id):
|
||||
entreprise = Entreprise.query.filter_by(id=id).first_or_404()
|
||||
offres = entreprise.offres
|
||||
contacts = entreprise.contacts
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).filter_by(object=id).limit(LOGS_LEN).all()
|
||||
historique = db.session.query(EntrepriseHistory, Identite).order_by(EntrepriseHistory.date_debut.desc()).\
|
||||
filter_by(entreprise_id=id).\
|
||||
join(Identite, Identite.id == EntrepriseHistory.etudid).all()
|
||||
return render_template("entreprises/fiche_entreprise.html", title=("Fiche entreprise"), entreprise=entreprise, contacts=contacts, offres=offres, logs=logs, historique=historique)
|
||||
|
||||
@bp.route("/add_entreprise", methods=["GET", "POST"])
|
||||
def add_entreprise():
|
||||
form = EntrepriseCreationForm()
|
||||
@ -147,17 +165,6 @@ def delete_entreprise(id):
|
||||
return redirect(url_for("entreprises.index"))
|
||||
return render_template("entreprises/delete_confirmation.html", title=("Supression entreprise"), form=form)
|
||||
|
||||
@bp.route("/fiche_entreprise/<id>", methods=["GET", "POST"])
|
||||
def fiche_entreprise(id):
|
||||
entreprise = Entreprise.query.filter_by(id=id).first_or_404()
|
||||
offres = entreprise.offres
|
||||
contacts = entreprise.contacts
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).filter_by(object=id).limit(LOGS_LEN).all()
|
||||
historique = db.session.query(EntrepriseHistory, Identite).order_by(EntrepriseHistory.date_debut.desc()).\
|
||||
filter_by(entreprise_id=id).\
|
||||
join(Identite, Identite.id == EntrepriseHistory.etudid).all()
|
||||
return render_template("entreprises/fiche_entreprise.html", title=("Fiche entreprise"), entreprise=entreprise, contacts=contacts, offres=offres, logs=logs, historique=historique)
|
||||
|
||||
@bp.route("/add_offre/<id>", methods=["GET", "POST"])
|
||||
def add_offre(id):
|
||||
entreprise = Entreprise.query.filter_by(id=id).first_or_404()
|
||||
@ -326,6 +333,13 @@ def add_historique(id):
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template("entreprises/form.html", title=("Ajout historique"), form=form)
|
||||
|
||||
@bp.route("/envoyer_offre/<id>", methods=["GET", "POST"])
|
||||
def envoyer_offre(id):
|
||||
form = EnvoiOffreForm()
|
||||
if form.validate_on_submit():
|
||||
print("tmp") # faire l'envoie du mail
|
||||
return render_template("entreprises/form.html", title=("Envoyer une offre"), form=form)
|
||||
|
||||
@bp.route("/etudiants")
|
||||
def json_etudiants():
|
||||
term = request.args.get('term').strip()
|
||||
@ -348,13 +362,6 @@ def json_etudiants():
|
||||
list.append(content)
|
||||
content = {}
|
||||
return jsonify(results=list)
|
||||
|
||||
@bp.route("/envoyer_offre/<id>", methods=["GET", "POST"])
|
||||
def envoyer_offre(id):
|
||||
form = EnvoiOffreForm()
|
||||
if form.validate_on_submit():
|
||||
print("tmp") # faire l'envoie du mail
|
||||
return render_template("entreprises/form.html", title=("Envoyer une offre"), form=form)
|
||||
|
||||
@bp.route("/responsables")
|
||||
def json_responsables():
|
||||
|
43
app/templates/entreprises/contacts.html
Normal file
43
app/templates/entreprises/contacts.html
Normal file
@ -0,0 +1,43 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block app_content %}
|
||||
{% if logs %}
|
||||
<div class="container">
|
||||
<h3>Dernières opérations</h3>
|
||||
<ul>
|
||||
{% for log in logs %}
|
||||
<li><span style="margin-right: 10px;">{{ log.date.strftime('%d %b %Hh%M') }}</span><span>{{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
<h1>Liste des contacts</h1>
|
||||
{% if contacts %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover">
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>Prenom</th>
|
||||
<th>Telephone</th>
|
||||
<th>Mail</th>
|
||||
<th>Entreprise</th>
|
||||
</tr>
|
||||
{% for contact in contacts %}
|
||||
<tr class="table-row active">
|
||||
<th>{{ contact[0].nom }}</th>
|
||||
<th>{{ contact[0].prenom }}</th>
|
||||
<th>{{ contact[0].telephone }}</th>
|
||||
<th>{{ contact[0].mail }}</th>
|
||||
<th><a href="{{ url_for('entreprises.fiche_entreprise', id=contact[1].id) }}">{{ contact[1].nom }}</a></th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<br>
|
||||
{% else %}
|
||||
<div>Aucun contact présent dans la base</div>
|
||||
<br>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,13 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block app_content %}
|
||||
<!-- <style>
|
||||
#entreprises-table {
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style> -->
|
||||
{% if logs %}
|
||||
<div class="container">
|
||||
<h3>Dernières opérations</h3>
|
||||
@ -22,7 +15,7 @@
|
||||
<h1>Liste des entreprises</h1>
|
||||
{% if entreprises %}
|
||||
<div class="table-responsive">
|
||||
<table id="entreprises-table" class="table table-bordered table-hover">
|
||||
<table class="table table-bordered table-hover">
|
||||
<tr>
|
||||
<th>SIRET</th>
|
||||
<th>Nom</th>
|
||||
@ -35,7 +28,7 @@
|
||||
{% for entreprise in entreprises %}
|
||||
<tr class="table-row active">
|
||||
<th><a href="{{ url_for('entreprises.fiche_entreprise', id=entreprise.id) }}">{{ entreprise.siret }}</a></th>
|
||||
<th class="entreprise-nom">{{ entreprise.nom }}</th>
|
||||
<th>{{ entreprise.nom }}</th>
|
||||
<th>{{ entreprise.adresse }}</th>
|
||||
<th>{{ entreprise.codepostal }}</th>
|
||||
<th>{{ entreprise.ville }}</th>
|
||||
|
@ -21,7 +21,9 @@
|
||||
{% for data in historique %}
|
||||
<li>
|
||||
<span style="margin-right: 10px;">{{ data[0].date_debut.strftime('%d/%m/%Y') }} - {{ data[0].date_fin.strftime('%d/%m/%Y') }}</span>
|
||||
<span style="margin-right: 10px;">{{ data[0].type_offre }} réalisé par {{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }}</span>
|
||||
<span style="margin-right: 10px;">
|
||||
{{ data[0].type_offre }} réalisé par {{ data[1].nom|format_nom }} {{ data[1].prenom|format_prenom }} en {{ data[0].formation_text }}
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -47,25 +47,29 @@
|
||||
if(response.ok)
|
||||
return response.json()
|
||||
else {
|
||||
document.getElementById("nom_entreprise").value = ''
|
||||
document.getElementById("adresse").value = ''
|
||||
document.getElementById("codepostal").value = ''
|
||||
document.getElementById("ville").value = ''
|
||||
document.getElementById("pays").value = ''
|
||||
throw new Error("404")
|
||||
emptyForm()
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
data = JSON.parse(JSON.stringify(response))
|
||||
document.getElementById("nom_entreprise").value = data.etablissement.l1_normalisee
|
||||
document.getElementById("adresse").value = data.etablissement.l4_normalisee
|
||||
document.getElementById("codepostal").value = data.etablissement.code_postal
|
||||
document.getElementById("ville").value = data.etablissement.libelle_commune
|
||||
document.getElementById("pays").value = 'France'
|
||||
})
|
||||
.then(response => fillForm(response))
|
||||
.catch(err => err)
|
||||
}
|
||||
}
|
||||
|
||||
function fillForm(response) {
|
||||
document.getElementById("nom_entreprise").value = response.etablissement.l1_normalisee
|
||||
document.getElementById("adresse").value = response.etablissement.l4_normalisee
|
||||
document.getElementById("codepostal").value = response.etablissement.code_postal
|
||||
document.getElementById("ville").value = response.etablissement.libelle_commune
|
||||
document.getElementById("pays").value = 'FRANCE'
|
||||
}
|
||||
|
||||
function emptyForm() {
|
||||
document.getElementById("nom_entreprise").value = ''
|
||||
document.getElementById("adresse").value = ''
|
||||
document.getElementById("codepostal").value = ''
|
||||
document.getElementById("ville").value = ''
|
||||
document.getElementById("pays").value = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user