>.>...
This commit is contained in:
parent
73ea88cccf
commit
4efcb7eb06
4 changed files with 45 additions and 45 deletions
|
@ -17,7 +17,7 @@ class User(UserMixin, db.Model):
|
||||||
|
|
||||||
command = db.relationship("Command", backref="client", lazy="dynamic", foreign_keys="Command.client_id")
|
command = db.relationship("Command", backref="client", lazy="dynamic", foreign_keys="Command.client_id")
|
||||||
pc_command = db.relationship("Command", backref="pc", lazy="dynamic", foreign_keys="Command.pc_id")
|
pc_command = db.relationship("Command", backref="pc", lazy="dynamic", foreign_keys="Command.pc_id")
|
||||||
sandwitch_command = db.relationship("Command", backref="sandwitch", lazy="dynamic", foreign_keys="Command.sandwitch_id")
|
sandwich_command = db.relationship("Command", backref="sandwich", lazy="dynamic", foreign_keys="Command.sandwich_id")
|
||||||
|
|
||||||
def set_password(self, password):
|
def set_password(self, password):
|
||||||
self.password_hash = generate_password_hash(password)
|
self.password_hash = generate_password_hash(password)
|
||||||
|
@ -39,7 +39,7 @@ class Command(db.Model):
|
||||||
number = db.Column(db.Integer, nullable=False)
|
number = db.Column(db.Integer, nullable=False)
|
||||||
|
|
||||||
pc_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
|
pc_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
|
||||||
sandwitch_id = db.Column(db.Integer, db.ForeignKey("user.id"))
|
sandwich_id = db.Column(db.Integer, db.ForeignKey("user.id"))
|
||||||
client_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
|
client_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
|
||||||
|
|
||||||
date = db.Column(db.Date, default=datetime.datetime.now().date)
|
date = db.Column(db.Date, default=datetime.datetime.now().date)
|
||||||
|
@ -127,13 +127,13 @@ class Dessert(db.Model):
|
||||||
|
|
||||||
class Service(db.Model):
|
class Service(db.Model):
|
||||||
pc_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
pc_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
sandwitch1_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
sandwich1_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
sandwitch2_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
sandwich2_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
sandwitch3_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
sandwich3_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
commi1_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
commi1_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
commi2_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
commi2_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True)
|
||||||
date = db.Column(db.Date, default=datetime.datetime.now().date, primary_key=True, unique=True)
|
date = db.Column(db.Date, default=datetime.datetime.now().date, primary_key=True, unique=True)
|
||||||
|
|
||||||
sandwitch1 = db.Column(db.Boolean, default=False)
|
sandwich1 = db.Column(db.Boolean, default=False)
|
||||||
sandwitch2 = db.Column(db.Boolean, default=False)
|
sandwich2 = db.Column(db.Boolean, default=False)
|
||||||
sandwitch3 = db.Column(db.Boolean, default=False)
|
sandwich3 = db.Column(db.Boolean, default=False)
|
||||||
|
|
|
@ -22,7 +22,7 @@ def authenticated_only(f):
|
||||||
def command_json(c):
|
def command_json(c):
|
||||||
ingredient = " - ".join([s.id for s in c.content])
|
ingredient = " - ".join([s.id for s in c.content])
|
||||||
sauces = " - ".join([s.id for s in c.sauce])
|
sauces = " - ".join([s.id for s in c.sauce])
|
||||||
sandwitch = None
|
sandwich = None
|
||||||
if c.error:
|
if c.error:
|
||||||
state = "error"
|
state = "error"
|
||||||
elif c.give:
|
elif c.give:
|
||||||
|
@ -35,13 +35,13 @@ def command_json(c):
|
||||||
state = "waiting"
|
state = "waiting"
|
||||||
else:
|
else:
|
||||||
state = "unknown"
|
state = "unknown"
|
||||||
if c.sandwitch_id:
|
if c.sandwich_id:
|
||||||
try:
|
try:
|
||||||
sandwitch = User.query.get(c.sandwitch_id).username
|
sandwich = User.query.get(c.sandwich_id).username
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return {"id": c.number, "plate": c.plate_id, "ingredient": ingredient, "sauce": sauces, "drink": c.drink_id,
|
return {"id": c.number, "plate": c.plate_id, "ingredient": ingredient, "sauce": sauces, "drink": c.drink_id,
|
||||||
"dessert": c.dessert_id, "state": state, "sandwitch": sandwitch}
|
"dessert": c.dessert_id, "state": state, "sandwich": sandwich}
|
||||||
|
|
||||||
|
|
||||||
@socketio.on("connect")
|
@socketio.on("connect")
|
||||||
|
@ -120,9 +120,9 @@ def rmcmd(json):
|
||||||
c.error = False
|
c.error = False
|
||||||
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
||||||
if c.WIP and service:
|
if c.WIP and service:
|
||||||
sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id]
|
sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id]
|
||||||
if c.sandwitch_id in sandwitchs:
|
if c.sandwich_id in sandwichs:
|
||||||
setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False)
|
setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False)
|
||||||
c.WIP = False
|
c.WIP = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
emit("cleared command", {"id": json["id"]}, broadcast=True)
|
emit("cleared command", {"id": json["id"]}, broadcast=True)
|
||||||
|
@ -136,9 +136,9 @@ def donecmd(json):
|
||||||
c.done = datetime.datetime.now().time()
|
c.done = datetime.datetime.now().time()
|
||||||
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
||||||
if service and c.WIP:
|
if service and c.WIP:
|
||||||
sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id]
|
sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id]
|
||||||
if c.sandwitch_id in sandwitchs:
|
if c.sandwich_id in sandwichs:
|
||||||
setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False)
|
setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False)
|
||||||
c.WIP = False
|
c.WIP = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
emit("finish command", {"id": json["id"]}, broadcast=True)
|
emit("finish command", {"id": json["id"]}, broadcast=True)
|
||||||
|
@ -152,9 +152,9 @@ def givecmd(json):
|
||||||
c.give = datetime.datetime.now().time()
|
c.give = datetime.datetime.now().time()
|
||||||
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
||||||
if service and c.WIP:
|
if service and c.WIP:
|
||||||
sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id]
|
sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id]
|
||||||
if c.sandwitch_id in sandwitchs:
|
if c.sandwich_id in sandwichs:
|
||||||
setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False)
|
setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False)
|
||||||
c.WIP = False
|
c.WIP = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
emit("gave command", {"id": json["id"]}, broadcast=True)
|
emit("gave command", {"id": json["id"]}, broadcast=True)
|
||||||
|
@ -167,17 +167,17 @@ def wipcmd(json):
|
||||||
if c:
|
if c:
|
||||||
c.WIP = True
|
c.WIP = True
|
||||||
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
||||||
sandwitch = None
|
sandwich = None
|
||||||
if service:
|
if service:
|
||||||
sandwitchs = [service.sandwitch1, service.sandwitch2, service.sandwitch3]
|
sandwichs = [service.sandwich1, service.sandwich2, service.sandwich3]
|
||||||
for i, s in enumerate(sandwitchs):
|
for i, s in enumerate(sandwichs):
|
||||||
if not s:
|
if not s:
|
||||||
setattr(service, f"sandwitch{i+1}", True)
|
setattr(service, f"sandwich{i+1}", True)
|
||||||
c.sandwitch_id = getattr(service, f"sandwitch{i+1}_id")
|
c.sandwich_id = getattr(service, f"sandwich{i+1}_id")
|
||||||
sandwitch = User.query.get(c.sandwitch_id).username
|
sandwich = User.query.get(c.sandwich_id).username
|
||||||
break
|
break
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
emit("WIPed command", {"id": json["id"], "sandwitch": sandwitch}, broadcast=True)
|
emit("WIPed command", {"id": json["id"], "sandwich": sandwich}, broadcast=True)
|
||||||
|
|
||||||
|
|
||||||
@socketio.on("error command")
|
@socketio.on("error command")
|
||||||
|
@ -252,7 +252,7 @@ def lsservice():
|
||||||
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
service = Service.query.filter_by(date=datetime.datetime.now().date()).first()
|
||||||
s = []
|
s = []
|
||||||
if service:
|
if service:
|
||||||
for u in [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id]:
|
for u in [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id]:
|
||||||
try:
|
try:
|
||||||
s.append([u, User.query.get(u).username])
|
s.append([u, User.query.get(u).username])
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -4,14 +4,14 @@ let WIP = document.getElementById("encours");
|
||||||
let done = document.getElementById("realisee");
|
let done = document.getElementById("realisee");
|
||||||
let waiting = document.getElementById("attente");
|
let waiting = document.getElementById("attente");
|
||||||
|
|
||||||
function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch) {
|
function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) {
|
||||||
if (!sandwitch)
|
if (!sandwich)
|
||||||
sandwitch = "";
|
sandwich = "";
|
||||||
done.insertAdjacentHTML("beforeend", `<div id=cmd${id}> <h1>${id}</h1><h2>${sandwitch}</h2><p>${plate} | ${ingredient}</p><p>${sauce}</p><p>${drink}</p><p>${dessert}</p> </div>`);
|
done.insertAdjacentHTML("beforeend", `<div id=cmd${id}> <h1>${id}</h1><h2>${sandwich}</h2><p>${plate} | ${ingredient}</p><p>${sauce}</p><p>${drink}</p><p>${dessert}</p> </div>`);
|
||||||
let e = document.getElementById(`cmd${id}`);
|
let e = document.getElementById(`cmd${id}`);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "WIP":
|
case "WIP":
|
||||||
WIPed(e, sandwitch);
|
WIPed(e, sandwich);
|
||||||
break;
|
break;
|
||||||
case "waiting":
|
case "waiting":
|
||||||
wait(e);
|
wait(e);
|
||||||
|
@ -67,7 +67,7 @@ socket.on("list command", data => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let c of data.list) {
|
for (let c of data.list) {
|
||||||
addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwitch);
|
addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwich);
|
||||||
}
|
}
|
||||||
waiter();
|
waiter();
|
||||||
});
|
});
|
||||||
|
@ -81,7 +81,7 @@ socket.on("list service", data => {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("new command", data => {
|
socket.on("new command", data => {
|
||||||
addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwitch);
|
addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwich);
|
||||||
waiter();
|
waiter();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ socket.on("cleared command", data => {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("WIPed command", data => {
|
socket.on("WIPed command", data => {
|
||||||
WIPed(document.getElementById((`cmd${data.id}`)), data.sandwitch);
|
WIPed(document.getElementById((`cmd${data.id}`)), data.sandwich);
|
||||||
waiter();
|
waiter();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ let current = {"plate": null, "ingredient": [], "sauce": [], "drink": null, "des
|
||||||
let radios = {"plate": null, "drink": null, "dessert": null};
|
let radios = {"plate": null, "drink": null, "dessert": null};
|
||||||
|
|
||||||
|
|
||||||
function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch) {
|
function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) {
|
||||||
if (!sandwitch)
|
if (!sandwich)
|
||||||
sandwitch = "";
|
sandwich = "";
|
||||||
list.insertAdjacentHTML("beforeend", `<div class="com" id="cmd${id}"> <button class="donner">Donnée</button> <h1>${id}</h1> <div class="spec"> <h2>${sandwitch}</h2><p>${plate}</p><p>${ingredient}</p><p>${sauce}</p><p>${drink}</p><p>${dessert}</p><button class="annuler">Annuler</button><button class="erreur">Erreur</button> </div> </div>`);
|
list.insertAdjacentHTML("beforeend", `<div class="com" id="cmd${id}"> <button class="donner">Donnée</button> <h1>${id}</h1> <div class="spec"> <h2>${sandwich}</h2><p>${plate}</p><p>${ingredient}</p><p>${sauce}</p><p>${drink}</p><p>${dessert}</p><button class="annuler">Annuler</button><button class="erreur">Erreur</button> </div> </div>`);
|
||||||
let e = document.querySelector(`.liste #cmd${id}`);
|
let e = document.querySelector(`.liste #cmd${id}`);
|
||||||
e.addEventListener( "click" ,ev => {
|
e.addEventListener( "click" ,ev => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -32,7 +32,7 @@ function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch)
|
||||||
});
|
});
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "WIP":
|
case "WIP":
|
||||||
WIP(e, sandwitch);
|
WIP(e, sandwich);
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "done":
|
||||||
done(e);
|
done(e);
|
||||||
|
@ -172,7 +172,7 @@ socket.on("list command", data => {
|
||||||
child = list.lastElementChild;
|
child = list.lastElementChild;
|
||||||
}
|
}
|
||||||
for (let c of data.list) {
|
for (let c of data.list) {
|
||||||
addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwitch);
|
addcmd(c.id, c.plate, c.ingredient, c.sauce, c.drink, c.dessert, c.state, c.sandwich);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ socket.on("list dessert", data => {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("new command", data => {
|
socket.on("new command", data => {
|
||||||
addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwitch);
|
addcmd(data.id, data.plate, data.ingredient, data.sauce, data.drink, data.dessert, data.state, data.sandwich);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("cleared command", data => {
|
socket.on("cleared command", data => {
|
||||||
|
@ -240,7 +240,7 @@ socket.on("cleared command", data => {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("WIPed command", data => {
|
socket.on("WIPed command", data => {
|
||||||
WIP(document.querySelector(`.liste #cmd${data.id}`), data.sandwitch)
|
WIP(document.querySelector(`.liste #cmd${data.id}`), data.sandwich)
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("finish command", data => {
|
socket.on("finish command", data => {
|
||||||
|
|
Reference in a new issue