Skip to content
Snippets Groups Projects
Commit ce2b86b0 authored by MavericksFive's avatar MavericksFive
Browse files

rebase

parent 98a0ef66
Branches backend_branch
No related tags found
No related merge requests found
No preview for this file type
import flask
from flask import Flask, render_template
from flask import Flask, render_template, request
from database.database import db, init_database
from database.models import Personne, Thematique
from database.models import Personne, Thematique, Pfe, Organisation
import os
absolute_path = os.path.dirname(__file__)
......@@ -29,10 +29,10 @@ def add_promotion(db_object):
return None
@app.route('/')
@app.route('/', methods=["GET", "POST"])
def hello_world(): # put application's code here
taf_dcl = Thematique(nom_taf='DCL')#, date='2023')
taf_nemo = Thematique(nom_taf='NEMO')
taf_dcl = Thematique(nom_taf='DCL', date='2023')
taf_nemo = Thematique(nom_taf='NEMO', date='2021')
db.session.add(taf_nemo)
db.session.commit()
db.session.add(taf_dcl)
......@@ -43,11 +43,29 @@ def hello_world(): # put application's code here
db.session.commit()
db.session.add(new2_Etudiant)
db.session.commit()
return taf_dcl.eleves[0].nom + taf_dcl.eleves[1].nom
new_Pfe = Pfe(tuteur="Stephane",titre="FullStack dev", personne=new2_Etudiant)
db.session.add(new_Pfe)
new2_Pfe = Pfe(tuteur="Jean", titre="Frontend dev", personne=new_Etudiant)
db.session.add(new2_Pfe)
db.session.add(new_Etudiant)
db.session.commit()
new_Organisation = Organisation(nom_organisation='IMTA')
db.session.add(new_Organisation)
db.session.commit()
new_Organisation.personnes.append(new_Etudiant)
new_Organisation.personnes.append(new2_Etudiant)
if request.method == "POST":
name = request.form.get("fname")
return "your name is" + name
return flask.render_template('profil.html.jinja2')
@app.route('/user')
@app.route('/user', methods=["GET", "POST"])
def display_profile():
if request.method == "POST":
name = request.form.get("fname")
return "your name is" + name
return flask.render_template('profil.html.jinja2')
@app.route('/dashboard')
......
No preview for this file type
No preview for this file type
......@@ -2,6 +2,5 @@ from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def init_database():
db.create_all()
\ No newline at end of file
......@@ -9,33 +9,26 @@ personne_organisation = db.Table('position',
class Thematique(db.Model):
id = db.Column(db.Integer, primary_key=True)
nom_taf = db.Column(db.Text)
#date = db.Column(db.Text)
date = db.Column(db.Text)
eleves = db.relationship('Personne', backref='Taf')
class Personne(db.Model):
thematique_id = db.Column(db.Integer, db.ForeignKey('thematique.id'))
id = db.Column(db.Integer, primary_key=True)
nom = db.Column(db.Text)
prenom = db.Column(db.Text)
#pfe = db.relationship('Pfe', backref='personne')
#organisations = db.relationship('Organisation', backref='personnes', secondary=personne_organisation)
class Stage(db.Model):
id = db.Column(db.Integer, primary_key=True)
nom_tuteur = db.Column(db.Text)
prenom_tuteur = db.Column(db.Text)
pfe = db.relationship('Pfe', uselist=False, backref='personne')
organisations = db.relationship('Organisation', backref='personnes', secondary=personne_organisation)
class Organisation(db.Model):
id = db.Column(db.Integer, primary_key=True)
nom_organisation = db.Column(db.Text)
#class Pfe(db.Model):
# id = db.Column(db.Integer, primary_key=True)
# tuteur = db.Column(db.Text)
# titre = db.Column(db.Text)
# owner_id = db.Column(db.Integer, db.ForeignKey('personne.id'))
class Pfe(db.Model):
id = db.Column(db.Integer, primary_key=True)
tuteur = db.Column(db.Text)
titre = db.Column(db.Text)
owner_id = db.Column(db.Integer, db.ForeignKey('personne.id'))
{% extends "layout.html.jinja2" %}
{% block content %}
<form action = "{{url_for("hello_world")}}" method="post">
<div class="container rounded bg-white mt-5 mb-5">
<div class="row">
<div class="col-md-3 border-right">
......@@ -12,7 +13,7 @@
<h4 class="text-right">Profile Settings</h4>
</div>
<div class="row mt-2" >
<div class="col-md-6"><label class="labels">Name</label><input type="text" class="form-control" placeholder="name" value=""></div>
<div class="col-md-6"><label class="labels" >Name</label><input type="text" class="form-control" name="fname" placeholder="name" value=""></div>
<div class="col-md-6"><label class="labels">Surname</label><input type="text" class="form-control" value="" placeholder="surname"></div>
</div>
<div class="row mt-3">
......@@ -28,7 +29,7 @@
<div class="col-md-6"><label class="labels">Company</label><input type="text" class="form-control" placeholder="company" value=""></div>
<div class="col-md-6"><label class="labels">Position</label><input type="text" class="form-control" value="" placeholder="position"></div>
</div>
<div class="mt-5 text-center"><button class="btn btn-primary profile-button" type="button">Save Profile</button></div>
<div class="mt-5 text-center"><button class="btn btn-primary profile-button" type="submit">Save Profile</button></div>
</div>
</div>
<div class="col-md-4">
......@@ -47,4 +48,5 @@
</div>
</div>
</div>
</form>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment