commit 33131ed07bf49cd5bfe64852e8daa480afe02fd5 Author: Doug Le Tough Date: Thu Oct 19 11:57:28 2017 +0200 "Initial commit" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16d837e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*un~ +*.swp +*.pyc +config.tetalab.py + diff --git a/config.local.py b/config.local.py new file mode 100644 index 0000000..8c13253 --- /dev/null +++ b/config.local.py @@ -0,0 +1,2 @@ +SQLALCHEMY_TRACK_MODIFICATIONS = True +SQLALCHEMY_DATABASE_URI = "postgresql://tetalab_user:tetalab@localhost/tetalab_stock" diff --git a/config.py b/config.py new file mode 120000 index 0000000..26e8fb0 --- /dev/null +++ b/config.py @@ -0,0 +1 @@ +config.local.py \ No newline at end of file diff --git a/ref.tetalab.org.wsgi b/ref.tetalab.org.wsgi new file mode 100644 index 0000000..24533b6 --- /dev/null +++ b/ref.tetalab.org.wsgi @@ -0,0 +1,3 @@ +import sys +sys.path.insert(0, '/var/www/stock.tetalab.org') +from stock_tetalab import app as application diff --git a/static/images/404.jpg b/static/images/404.jpg new file mode 100644 index 0000000..b7cf6e1 Binary files /dev/null and b/static/images/404.jpg differ diff --git a/static/images/logo_tetalab.png b/static/images/logo_tetalab.png new file mode 100644 index 0000000..3ff1932 Binary files /dev/null and b/static/images/logo_tetalab.png differ diff --git a/static/images/working.jpg b/static/images/working.jpg new file mode 100644 index 0000000..d18eb46 Binary files /dev/null and b/static/images/working.jpg differ diff --git a/static/images/working.xcf b/static/images/working.xcf new file mode 100644 index 0000000..57d3a5a Binary files /dev/null and b/static/images/working.xcf differ diff --git a/static/scripts/tetalab.js b/static/scripts/tetalab.js new file mode 100644 index 0000000..e69de29 diff --git a/static/style/style.css b/static/style/style.css new file mode 100644 index 0000000..10d2f85 --- /dev/null +++ b/static/style/style.css @@ -0,0 +1,224 @@ +body { + font-family: sans-serif; + background-color: #2B2B2B; +} + +div.main_wrapper { + width: 1280px; + height: auto; + margin: 0 auto; + padding: 10px; + position: relative; +} + +div.center { + width: auto; + background-color: #E5E5E5; + height: auto; + border-style: solid; + border-color: #AAAAAA; + border-width: 1px 0 1px 0; +} + +div.banner { + background: url(../images/logo_tetalab.png); + background-repeat: no-repeat; + background-position: 10px -2px; + background-color: #FF5D00; + color: #FFFFFF; + font-size: 24px; + padding: 10px; + text-align: right; + font-weight: bold; + height: 40px; + text-shadow: 0 0 1px #000000; +} + +div.top_menu { + background-color: #BBBBBB; + height: 30px; + text-align: right; + line-height: 30px; + border-style: solid; + border-color: #888888; + border-width: 1px 0 0 0; +} + +span.top_menu_item { + margin: 5px 2px 0 0; + font-size: 12px; + background-color: #F0ECE0; + padding: 1px 5px 1px 5px; + border-radius: 4px; + border-style: solid; + border-color: #888888; + border-width: 1px; + font-weight: bold; + color: #FF5D00; + line-height: 30px; +} + +span.top_menu_item_selected { + margin: 5px 2px 0 0; + font-size: 12px; + background-color: #FF5D00; + padding: 1px 5px 1px 5px; + border-radius: 4px; + border-style: solid; + border-color: #888888; + border-width: 1px; + font-weight: bold; + color: #F0ECE0; + line-height: 30px; +} + +span.top_menu_item:hover, span.top_menu_item_selected:hover { + background-color: #FFB387; + color: #555555; + cursor: pointer; +} + +div.content_wrapper { + height: 497px; + width: 1280px; +} + +div.left_menu { + background-color: #E5E5E5; + border-style: solid; + border-color: #AAAAAA; + border-width: 1px 1px 1px 0; + overflow-y: auto; + overflow-x: hidden; + width: 249px; + height: 495px; + line-height: 50px; +} + +div.left_menu_item, div.left_menu_item_selected { + background-color: #E5E5E5; + width: 229px; + height: 40px; + overflow-y: hidden; + border-style: solid; + border-color: #AAAAAA; + border-width: 0 0 1px 0; + padding: 10px; + line-height: 50px; + font-weight: bold; + font-size: 20px; + color: #555555; +} + +div.left_menu_item:hover, div.left_menu_item_selected:hover { + background-color: #FFB387; + color: #555555; + cursor: pointer; +} + +div.left_menu_item_selected { + color: #F0ECE0; + background-color: #FF5D00; + +} + + +div.content { + position: absolute; + top: 102px; + left: 260px; + width: 1010px; + height: 475px; + background-color: #E5E5E5; + overflow-y: auto; + padding: 10px; + border-style: solid; + border-color: #AAAAAA; + border-width: 1px 0 1px 0; + color: #555555; + text-align: justify; +} + +div.git_desc, pre { + border-style: solid; + border-color: #FF5D00; + border-width: 1px; + background-color: #FFFFFF; + padding: 5px; +} + +div.git_desc { + text-align: justify; +} + +div.error { + background: url(../images/404.jpg); + background-repeat: no-repeat; + background-position: center center; + background-color: #000000; + height: 476px; + padding: 10px; + text-align: center; + font-size: 70px; + font-weight: bold; + color: #FF5D00; +} + +div.wip { + background: url(../images/working.jpg); + background-repeat: no-repeat; + background-position: center center; + background-color: #000000; + height: 476px; + padding: 10px; + text-align: center; + font-size: 70px; + font-weight: bold; + color: #FF5D00; +} + +div.footer { + background-color: #FF5D00; + font-size: 10px; + color: #2B2B2B; + text-align: center; +} + + +/* *********************************** + * Classes génériques +*********************************** */ + +h3, h4 { + text-decoration: underline; +} + +a { + color: #FF5D00; + text-decoration: none; + padding: 2px; +} + +a:hover { + background-color: #FFB387; +} + +span.bold { + font-weight: bold; +} + +table { + border-collapse: collapse; + width: 100%; +} + +th { + background-color: #FFB387; +} + +th, td { + text-align: left; + padding: 8px; +} + +tr:nth-child(even){background-color: #f2f2f2} diff --git a/stock.sql b/stock.sql new file mode 100644 index 0000000..1786748 --- /dev/null +++ b/stock.sql @@ -0,0 +1,43 @@ +CREATE TABLE Stock_users ( + id serial primary key, + mail text not NULL, + password text not NULL, + name text not NULL +); + + +CREATE TABLE Stock_kits ( + id serial primary key, + name text not NULL, + description text not NULL +); + + +CREATE TABLE Stock_providers ( + id serial primary key, + address text not NULL, + mail text not NULL, + url text not NULL, + comment text not NULL +); + + +CREATE TABLE Stock_componants ( + id serial primary key, + name text not NULL, + description text not NULL, + last_price NUMERIC not NULL, + mean_price NUMERIC not NULL, + quantity NUMERIC not NULL, + min_quantity NUMERIC not NULL, + place text not NULL, + provider_id integer REFERENCES Stock_providers(id) +); + + +CREATE TABLE Stock_kit_compositions ( + id serial primary key, + kit_id integer REFERENCES Stock_kits(id), + componant_id integer REFERENCES Stock_componants(id), + quantity integer not NULL +); diff --git a/stock_tetalab.py b/stock_tetalab.py new file mode 100755 index 0000000..2e722e5 --- /dev/null +++ b/stock_tetalab.py @@ -0,0 +1,164 @@ +#!/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/') +def get_componant(componant_id): + return render_template('wip.html') + +@app.route('/componants/add/') +def add_componant(componant_id): + return render_template('wip.html') + +@app.route('/componants/edit/') +def edit_componant(componant_id): + return render_template('wip.html') + +@app.route('/componants/delete/') +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/') +def get_kit(kit_id): + return render_template('wip.html') + +@app.route('/kits/add/') +def add_kit(kit_id): + return render_template('wip.html') + +@app.route('/kits/edit/') +def edit_kit(kit_id): + return render_template('wip.html') + +@app.route('/kits/delete/') +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/') +def get_provider(provider_id): + return render_template('wip.html') + +@app.route('/providers/add/') +def add_provider(provider_id): + return render_template('wip.html') + +@app.route('/providers/edit/') +def edit_provider(provider_id): + return render_template('wip.html') + +@app.route('/providers/delete/') +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/') +def get_user(user_id): + return render_template('wip.html') + +@app.route('/users/add/') +def add_user(user_id): + return render_template('wip.html') + +@app.route('/users/edit/') +def edit_user(user_id): + return render_template('wip.html') + +@app.route('/users/delete/') +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() diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 0000000..c980a2b --- /dev/null +++ b/templates/error.html @@ -0,0 +1,30 @@ + + + + Référentiel Infrastructure Tetalab - {% block title %}How The Fuck{% endblock %} + + + + + + +
+
+ +
+ Retour +
+
+
+ 404 +
+
+ +
+
+ + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..f0a0f24 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,56 @@ + + + + + Stock Tetalab - {% block title %}Accueil{% endblock %} + + + + + + +
+
+ +
+ {% block top_menu %} Accueil {% endblock %} +
+
+
+ {% block left_menu %} +
+ Accueil +
+
+ Composants +
+
+ Kits +
+
+ Fournisseurs +
{% endblock %} +
+
+ {% block content %} +

Gestion du stock

+

Ceci est l'outil de gestion de stock du Tetalab.

+

Cet outil vous permet: +

    +
  • De gérer la liste des composants électroniques en possession du Tetalab
  • +
  • De gérer la liste des fournisseurs de composants
  • +
  • De gérer la liste des kits de montage
  • +
+

+ {% endblock %} +
+
+ +
+
+ + diff --git a/templates/wip.html b/templates/wip.html new file mode 100644 index 0000000..480d4dd --- /dev/null +++ b/templates/wip.html @@ -0,0 +1,30 @@ + + + + Référentiel Infrastructure Tetalab - {% block title %}How The Fuck{% endblock %} + + + + + + +
+
+ +
+ Retour +
+
+
+ Work In Progress +
+
+ +
+
+ +