L'outil de gestion de stock de composants électroniques du Tetalab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

164 lines
4.7 KiB

#!/usr/bin/env python
# -*- coding: utf-8
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile('config.py')
app.secret_key = app.config.get('446307a5f61c2bb810436b2ee0f903f2')
app.debug = True
app.static_url_path='/static'
db = SQLAlchemy(app)
class Stock_users(db.Model):
id = db.Column(db.Integer, primary_key=True)
mail = db.Column(db.Text, nullable=False)
password = db.Column(db.Text, nullable=False)
name = db.Column(db.Text, nullable=False)
class Stock_componants(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, nullable=False)
description = db.Column(db.Text, nullable=False)
last_price = db.Column(db.Float)
mean_price = db.Column(db.Float)
quantity = db.Column(db.Integer)
min_quantity = db.Column(db.Integer)
place = db.Column(db.Text, nullable=False)
provider_id = db.Column(db.Integer, nullable=False)
class Stock_providers(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, nullable=False)
postal_address = db.Column(db.Text)
url = db.Column(db.Text)
comment = db.Column(db.Text)
class Stock_kits(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, nullable=False)
description = db.Column(db.Text, nullable=False)
class Stock_kit_compositions(db.Model):
id = db.Column(db.Integer, primary_key=True)
kit_id = db.Column(db.Integer, db.ForeignKey('Stock_kits.id'), nullable=False)
component_id = db.Column(db.Integer, db.ForeignKey('Stock_componants.id'), nullable=False)
component_quantity = db.Column(db.Integer, nullable=False)
@app.errorhandler(404)
def page_not_found(e):
return render_template('error.html'), 404
@app.route("/")
def authenticate():
return render_template('index.html')
########################################################################
# Componants
########################################################################
@app.route('/componants')
def get_componants():
return render_template('wip.html')
@app.route('/componants/<componant_id>')
def get_componant(componant_id):
return render_template('wip.html')
@app.route('/componants/add/<componant_id>')
def add_componant(componant_id):
return render_template('wip.html')
@app.route('/componants/edit/<componant_id>')
def edit_componant(componant_id):
return render_template('wip.html')
@app.route('/componants/delete/<componant_id>')
def delete_componant(componant_id):
return render_template('wip.html')
########################################################################
# Kits
########################################################################
@app.route('/kits')
def get_kits():
return render_template('wip.html')
@app.route('/kits/<kit_id>')
def get_kit(kit_id):
return render_template('wip.html')
@app.route('/kits/add/<kit_id>')
def add_kit(kit_id):
return render_template('wip.html')
@app.route('/kits/edit/<kit_id>')
def edit_kit(kit_id):
return render_template('wip.html')
@app.route('/kits/delete/<kit_id>')
def delete_kit(kit_id):
return render_template('wip.html')
########################################################################
# Providers
########################################################################
@app.route('/providers')
def get_providers():
return render_template('wip.html')
@app.route('/providers/<provider_id>')
def get_provider(provider_id):
return render_template('wip.html')
@app.route('/providers/add/<provider_id>')
def add_provider(provider_id):
return render_template('wip.html')
@app.route('/providers/edit/<provider_id>')
def edit_provider(provider_id):
return render_template('wip.html')
@app.route('/providers/delete/<provider_id>')
def delete_provider(provider_id):
return render_template('wip.html')
########################################################################
# Users
########################################################################
@app.route('/users')
def get_users():
return render_template('wip.html')
@app.route('/users/<user_id>')
def get_user(user_id):
return render_template('wip.html')
@app.route('/users/add/<user_id>')
def add_user(user_id):
return render_template('wip.html')
@app.route('/users/edit/<user_id>')
def edit_user(user_id):
return render_template('wip.html')
@app.route('/users/delete/<user_id>')
def delete_user(user_id):
return render_template('wip.html')
##############################################
def get_distinct(query):
results = []
for result in query:
result = result[0]
if result not in results:
results.append(result)
return results
# Main #######################################
if __name__ == '__main__':
app.run()