diff --git a/app/models.py b/app/models.py index 4f8d627..7077e98 100644 --- a/app/models.py +++ b/app/models.py @@ -17,7 +17,7 @@ class User(UserMixin, db.Model): 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") - 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): self.password_hash = generate_password_hash(password) @@ -39,7 +39,7 @@ class Command(db.Model): number = db.Column(db.Integer, 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) date = db.Column(db.Date, default=datetime.datetime.now().date) @@ -127,13 +127,13 @@ class Dessert(db.Model): class Service(db.Model): 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) - sandwitch2_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) + sandwich1_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) + 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) 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) - sandwitch1 = db.Column(db.Boolean, default=False) - sandwitch2 = db.Column(db.Boolean, default=False) - sandwitch3 = db.Column(db.Boolean, default=False) + sandwich1 = db.Column(db.Boolean, default=False) + sandwich2 = db.Column(db.Boolean, default=False) + sandwich3 = db.Column(db.Boolean, default=False) diff --git a/app/sockets.py b/app/sockets.py index aac0e9f..abc5e34 100644 --- a/app/sockets.py +++ b/app/sockets.py @@ -22,7 +22,7 @@ def authenticated_only(f): def command_json(c): ingredient = " - ".join([s.id for s in c.content]) sauces = " - ".join([s.id for s in c.sauce]) - sandwitch = None + sandwich = None if c.error: state = "error" elif c.give: @@ -35,13 +35,13 @@ def command_json(c): state = "waiting" else: state = "unknown" - if c.sandwitch_id: + if c.sandwich_id: try: - sandwitch = User.query.get(c.sandwitch_id).username + sandwich = User.query.get(c.sandwich_id).username except AttributeError: pass 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") @@ -120,9 +120,9 @@ def rmcmd(json): c.error = False service = Service.query.filter_by(date=datetime.datetime.now().date()).first() if c.WIP and service: - sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id] - if c.sandwitch_id in sandwitchs: - setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False) + sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id] + if c.sandwich_id in sandwichs: + setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False) c.WIP = False db.session.commit() emit("cleared command", {"id": json["id"]}, broadcast=True) @@ -136,9 +136,9 @@ def donecmd(json): c.done = datetime.datetime.now().time() service = Service.query.filter_by(date=datetime.datetime.now().date()).first() if service and c.WIP: - sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id] - if c.sandwitch_id in sandwitchs: - setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False) + sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id] + if c.sandwich_id in sandwichs: + setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False) c.WIP = False db.session.commit() emit("finish command", {"id": json["id"]}, broadcast=True) @@ -152,9 +152,9 @@ def givecmd(json): c.give = datetime.datetime.now().time() service = Service.query.filter_by(date=datetime.datetime.now().date()).first() if service and c.WIP: - sandwitchs = [service.sandwitch1_id, service.sandwitch2_id, service.sandwitch3_id] - if c.sandwitch_id in sandwitchs: - setattr(service, f"sandwitch{sandwitchs.index(c.sandwitch_id)+1}", False) + sandwichs = [service.sandwich1_id, service.sandwich2_id, service.sandwich3_id] + if c.sandwich_id in sandwichs: + setattr(service, f"sandwich{sandwichs.index(c.sandwich_id)+1}", False) c.WIP = False db.session.commit() emit("gave command", {"id": json["id"]}, broadcast=True) @@ -167,17 +167,17 @@ def wipcmd(json): if c: c.WIP = True service = Service.query.filter_by(date=datetime.datetime.now().date()).first() - sandwitch = None + sandwich = None if service: - sandwitchs = [service.sandwitch1, service.sandwitch2, service.sandwitch3] - for i, s in enumerate(sandwitchs): + sandwichs = [service.sandwich1, service.sandwich2, service.sandwich3] + for i, s in enumerate(sandwichs): if not s: - setattr(service, f"sandwitch{i+1}", True) - c.sandwitch_id = getattr(service, f"sandwitch{i+1}_id") - sandwitch = User.query.get(c.sandwitch_id).username + setattr(service, f"sandwich{i+1}", True) + c.sandwich_id = getattr(service, f"sandwich{i+1}_id") + sandwich = User.query.get(c.sandwich_id).username break 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") @@ -252,7 +252,7 @@ def lsservice(): service = Service.query.filter_by(date=datetime.datetime.now().date()).first() s = [] 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: s.append([u, User.query.get(u).username]) except AttributeError: diff --git a/app/static/js/kitchen.js b/app/static/js/kitchen.js index b34a6b9..9158027 100644 --- a/app/static/js/kitchen.js +++ b/app/static/js/kitchen.js @@ -4,14 +4,14 @@ let WIP = document.getElementById("encours"); let done = document.getElementById("realisee"); let waiting = document.getElementById("attente"); -function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch) { - if (!sandwitch) - sandwitch = ""; - done.insertAdjacentHTML("beforeend", `

${id}

${sandwitch}

${plate} | ${ingredient}

${sauce}

${drink}

${dessert}

`); +function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) { + if (!sandwich) + sandwich = ""; + done.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${plate} | ${ingredient}

${sauce}

${drink}

${dessert}

`); let e = document.getElementById(`cmd${id}`); switch (state) { case "WIP": - WIPed(e, sandwitch); + WIPed(e, sandwich); break; case "waiting": wait(e); @@ -67,7 +67,7 @@ socket.on("list command", data => { } } 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(); }); @@ -81,7 +81,7 @@ socket.on("list service", 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(); }); @@ -91,7 +91,7 @@ socket.on("cleared command", data => { }); socket.on("WIPed command", data => { - WIPed(document.getElementById((`cmd${data.id}`)), data.sandwitch); + WIPed(document.getElementById((`cmd${data.id}`)), data.sandwich); waiter(); }); diff --git a/app/static/js/pc.js b/app/static/js/pc.js index 14eead5..bd43e5a 100644 --- a/app/static/js/pc.js +++ b/app/static/js/pc.js @@ -9,10 +9,10 @@ let current = {"plate": null, "ingredient": [], "sauce": [], "drink": null, "des let radios = {"plate": null, "drink": null, "dessert": null}; -function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch) { - if (!sandwitch) - sandwitch = ""; - list.insertAdjacentHTML("beforeend", `

${id}

${sandwitch}

${plate}

${ingredient}

${sauce}

${drink}

${dessert}

`); +function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwich) { + if (!sandwich) + sandwich = ""; + list.insertAdjacentHTML("beforeend", `

${id}

${sandwich}

${plate}

${ingredient}

${sauce}

${drink}

${dessert}

`); let e = document.querySelector(`.liste #cmd${id}`); e.addEventListener( "click" ,ev => { ev.stopPropagation(); @@ -32,7 +32,7 @@ function addcmd(id, plate, ingredient, sauce, drink, dessert, state, sandwitch) }); switch (state) { case "WIP": - WIP(e, sandwitch); + WIP(e, sandwich); break; case "done": done(e); @@ -172,7 +172,7 @@ socket.on("list command", data => { child = list.lastElementChild; } 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 => { - 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 => { @@ -240,7 +240,7 @@ socket.on("cleared 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 => {