diff --git a/app.js b/app.js
index b062d04..368c626 100644
--- a/app.js
+++ b/app.js
@@ -9,12 +9,12 @@ let indexRouter = require("./routes/index");
let registerRouter = require("./routes/register");
let loginRouter = require("./routes/login");
let logoutRouter = require("./routes/logout");
-let commandRouter = require("./routes/command");
-let ordersRouter = require("./routes/commands");
+let orderRouter = require("./routes/order");
+let ordersRouter = require("./routes/orders");
let sandwichesRouter = require("./routes/sandwiches");
let profileRouter = require("./routes/profile");
let adminRouter = require("./routes/admin");
-let adminCommandsRouter = require("./routes/admin/commands");
+let adminOrdersRouter = require("./routes/admin/orders");
let app = express();
let sess = {
@@ -50,12 +50,12 @@ app.use("/", indexRouter);
app.use("/register", registerRouter);
app.use("/login", loginRouter);
app.use("/logout", logoutRouter);
-app.use("/command", commandRouter);
-app.use("/commands", ordersRouter);
+app.use("/order", orderRouter);
+app.use("/orders", ordersRouter);
app.use("/sandwiches", sandwichesRouter);
app.use("/profile", profileRouter);
app.use("/admin", adminRouter);
-app.use("/admin/commands", adminCommandsRouter);
+app.use("/admin/orders", adminOrdersRouter);
// catch 404 and forward to error handler
app.use((req, res) => {
diff --git a/locales/en.json b/locales/en.json
index 59a26af..95daf44 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -37,9 +37,9 @@
},
"admin": {
"title": "Administration",
- "commandsManagement": "Commands management",
+ "ordersManagement": "Orders management",
"ordersDate": "Orders date",
- "manageCommands": "Manage commands",
+ "manageOrders": "Manage orders",
"sandwichManagement": "Sandwich management",
"manageSandwiches": "Manage sandwiches",
"userManagement": "User management",
@@ -51,8 +51,8 @@
"password": "Password",
"email": "Email",
"department": "Department",
- "commands": "Commands",
+ "orders": "Orders",
"sandwiches": "Sandwiches",
"date": "Date",
- "command": "Command"
+ "order": "Order"
}
diff --git a/locales/fr.json b/locales/fr.json
index aca00ef..328a84a 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -14,7 +14,7 @@
"IT": "BDE Info",
"made": "Fait avec ❤️ par",
"contact": "Contact",
- "orderIssue": "Problème de ordere"
+ "orderIssue": "Problème de commande"
},
"index": {
"welcome": "Bienvenue sur Sandwiches Order Doua",
@@ -24,7 +24,7 @@
},
"login": {
"title": "Se connecter",
- "submit": "Connection"
+ "submit": "Connexion"
},
"register": {
"title": "S'inscrire",
@@ -37,9 +37,9 @@
},
"admin": {
"title": "Administration",
- "commandsManagement": "Gestion des orderes",
- "ordersDate": "Date des orderes",
- "manageCommands": "Gérer les orderes",
+ "ordersManagement": "Gestion des commandes",
+ "ordersDate": "Date des commandes",
+ "manageOrders": "Gérer les commandes",
"sandwichManagement": "Gestion des sandwichs",
"manageSandwiches": "Gérer les sandwichs",
"userManagement": "Gestion des utilisateurs",
@@ -51,8 +51,8 @@
"password": "Mot de passe",
"email": "Email",
"department": "Département",
- "commands": "Orderes",
+ "orders": "Commandes",
"sandwiches": "Sandwichs",
"date": "Date",
- "command": "Order"
+ "order": "Commande"
}
diff --git a/models/department.js b/models/department.js
index 10fc552..c5f2c48 100644
--- a/models/department.js
+++ b/models/department.js
@@ -5,7 +5,7 @@ const {
module.exports = (sequelize, DataTypes) => {
class Department extends Model {
static associate(models) {
- Department.hasMany(models.Command);
+ Department.hasMany(models.Order);
Department.hasMany(models.User);
}
}
diff --git a/models/command.js b/models/order.js
similarity index 64%
rename from models/command.js
rename to models/order.js
index 817d86a..709fc0a 100644
--- a/models/command.js
+++ b/models/order.js
@@ -3,14 +3,14 @@ const {
Model
} = require("sequelize");
module.exports = (sequelize, DataTypes) => {
- class Command extends Model {
+ class Order extends Model {
static associate(models) {
- Command.belongsToMany(models.Sandwich, {through: {model: models.SandwichCommand, unique: false}});
- Command.belongsTo(models.Department);
- Command.belongsTo(models.User);
+ Order.belongsToMany(models.Sandwich, {through: {model: models.SandwichOrder, unique: false}});
+ Order.belongsTo(models.Department);
+ Order.belongsTo(models.User);
}
}
- Command.init({
+ Order.init({
firstName: {
type: DataTypes.STRING,
allowNull: false
@@ -30,7 +30,7 @@ module.exports = (sequelize, DataTypes) => {
}
}, {
sequelize,
- modelName: "Command",
+ modelName: "Order",
});
- return Command;
+ return Order;
};
diff --git a/models/sandwich.js b/models/sandwich.js
index 8d1f1a7..d4e07a0 100644
--- a/models/sandwich.js
+++ b/models/sandwich.js
@@ -5,7 +5,7 @@ const {
module.exports = (sequelize, DataTypes) => {
class Sandwich extends Model {
static associate(models) {
- Sandwich.belongsToMany(models.Command, {through: {model: models.SandwichCommand, unique: false}});
+ Sandwich.belongsToMany(models.Order, {through: {model: models.SandwichOrder, unique: false}});
}
}
Sandwich.init({
diff --git a/models/sandwichCommand.js b/models/sandwichCommand.js
index 3e5ac9a..909da0a 100644
--- a/models/sandwichCommand.js
+++ b/models/sandwichCommand.js
@@ -3,11 +3,11 @@ const {
Model
} = require("sequelize");
module.exports = (sequelize, DataTypes) => {
- class SandwichCommand extends Model {
+ class SandwichOrder extends Model {
static associate(models) {
}
}
- SandwichCommand.init({
+ SandwichOrder.init({
id: {
type: DataTypes.INTEGER,
primaryKey: true,
@@ -20,7 +20,7 @@ module.exports = (sequelize, DataTypes) => {
}
}, {
sequelize,
- modelName: "SandwichCommand",
+ modelName: "SandwichOrder",
});
- return SandwichCommand;
+ return SandwichOrder;
};
diff --git a/models/user.js b/models/user.js
index ffeee53..e7c80b1 100644
--- a/models/user.js
+++ b/models/user.js
@@ -6,7 +6,7 @@ module.exports = (sequelize, DataTypes) => {
class User extends Model {
static associate(models) {
User.belongsTo(models.Department);
- User.hasMany(models.Command);
+ User.hasMany(models.Order);
}
checkPassword(password) {
diff --git a/public/javascripts/index.js b/public/javascripts/index.js
index fcc8f2a..eb9e52a 100644
--- a/public/javascripts/index.js
+++ b/public/javascripts/index.js
@@ -1,20 +1,20 @@
-const commandAction = document.getElementById("command-action");
-const rmButton = document.getElementById("remove-command");
+const orderAction = document.getElementById("order-action");
+const rmButton = document.getElementById("remove-order");
const locals = {
- command: document.querySelector("#command1>h2").innerHTML.replace(" 1", ""),
+ order: document.querySelector("#order1>h2").innerHTML.replace(" 1", ""),
sandwich: document.querySelector("label[for='sandwich1']").innerHTML,
day: document.querySelector("label[for='day1']").innerHTML
};
-function lastCommandId() {
- let list = document.querySelectorAll("div.command h2");
- return parseInt(list[list.length-1].innerText.replace("Command ", ""));
+function lastOrderId() {
+ let list = document.querySelectorAll("div.order h2");
+ return parseInt(list[list.length-1].innerText.replace(locals.order+" ", ""));
}
-document.getElementById("add-command").addEventListener("click", () => {
- let id = lastCommandId() + 1;
- commandAction.insertAdjacentHTML("beforebegin", `
-
${locals.command} ${id}
+document.getElementById("add-order").addEventListener("click", () => {
+ let id = lastOrderId() + 1;
+ orderAction.insertAdjacentHTML("beforebegin", `
`);
- document.getElementById("command"+lastCommandId()).scrollIntoView({behavior: "smooth"});
+ document.getElementById("order"+lastOrderId()).scrollIntoView({behavior: "smooth"});
rmButton.classList.remove("hide");
});
rmButton.addEventListener("click", () => {
- let id = lastCommandId();
- document.getElementById("command"+id).remove();
+ let id = lastOrderId();
+ document.getElementById("order"+id).remove();
if (id === 2)
rmButton.classList.add("hide");
});
diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css
index e21c4b6..f1e8cff 100644
--- a/public/stylesheets/style.css
+++ b/public/stylesheets/style.css
@@ -38,7 +38,7 @@ a {
text-decoration: none;
}
-#command {
+#order {
margin: auto;
display: flex;
flex-direction: column;
@@ -70,12 +70,12 @@ a {
border: none;
}
-#command-action {
+#order-action {
display: flex;
justify-content: space-around;
}
-#add-command, #remove-command {
+#add-order, #remove-order {
font-weight: bold;
font-size: 2em;
margin: auto auto 1em auto;
@@ -185,33 +185,33 @@ p.before-link a::before {
color: black;
}
-#userCommandList {
+#userOrderList {
max-height: 90%;
overflow-y: auto;
}
-#commandsManagement {
+#ordersManagement {
max-height: 90%;
}
-#commandsManagement h2 {
+#ordersManagement h2 {
margin: 0.2em 0 0 0;
}
-#commandsManagement>div {
+#ordersManagement>div {
overflow-y: auto;
}
-#commandsManagement .command {
+#ordersManagement .order {
box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2);
}
-#commandsManagement .command .title, #commandsManagement .sandwich {
+#ordersManagement .order .title, #ordersManagement .sandwich {
display: flex;
justify-content: center;
}
-#commandsManagement input[value="x"] {
+#ordersManagement input[value="x"] {
border: none;
background-color: unset;
cursor: pointer;
diff --git a/routes/admin/commands.js b/routes/admin/commands.js
deleted file mode 100644
index 42b4db3..0000000
--- a/routes/admin/commands.js
+++ /dev/null
@@ -1,40 +0,0 @@
-let express = require("express");
-let router = express.Router();
-let sessionCheck = require("../../middlewares/sessionCheck");
-let models = require("../../models");
-
-
-router.get("/", sessionCheck(3), async (req, res) => {
- res.render("admin/commands", {
- title: "SOD - Commands administration",
- user: req.session.user,
- commands: await models.Command.findAll({include: models.Sandwich, order: ["date"]})
- });
-}).post("/command/delete", sessionCheck(3), async (req, res) => {
- if (!req.body.id)
- res.render("error", {message: "Fail to remove command !", error: {status: "Missing args"}});
- try {
- await (await models.Command.findByPk(req.body.id)).destroy();
- res.redirect("/admin/commands");
- } catch (e) {
- res.render("error", {message: "Fail to remove command !", error: {}});
- throw e;
- }
-}).post("/sandwich/delete", sessionCheck(3), async (req, res) => {
- if (!req.body.id)
- res.render("error", {message: "Fail to remove sandwich !", error: {status: "Missing args"}});
- try {
- let sandwich = await models.SandwichCommand.findByPk(req.body.id);
- let command = await models.Command.findByPk(sandwich.CommandId, {include: models.Sandwich});
- await sandwich.destroy();
- await command.reload();
- if (!command.Sandwiches.length)
- await command.destroy();
- res.redirect("/admin/commands");
- } catch (e) {
- res.render("error", {message: "Fail to remove sandwich !", error: {}});
- throw e;
- }
-});
-
-module.exports = router;
diff --git a/routes/admin/orders.js b/routes/admin/orders.js
new file mode 100644
index 0000000..5b55054
--- /dev/null
+++ b/routes/admin/orders.js
@@ -0,0 +1,40 @@
+let express = require("express");
+let router = express.Router();
+let sessionCheck = require("../../middlewares/sessionCheck");
+let models = require("../../models");
+
+
+router.get("/", sessionCheck(3), async (req, res) => {
+ res.render("admin/orders", {
+ title: "SOD - Orders administration",
+ user: req.session.user,
+ orders: await models.Order.findAll({include: models.Sandwich, order: ["date"]})
+ });
+}).post("/order/delete", sessionCheck(3), async (req, res) => {
+ if (!req.body.id)
+ res.render("error", {message: "Fail to remove order !", error: {status: "Missing args"}});
+ try {
+ await (await models.Order.findByPk(req.body.id)).destroy();
+ res.redirect("/admin/orders");
+ } catch (e) {
+ res.render("error", {message: "Fail to remove order !", error: {}});
+ throw e;
+ }
+}).post("/sandwich/delete", sessionCheck(3), async (req, res) => {
+ if (!req.body.id)
+ res.render("error", {message: "Fail to remove sandwich !", error: {status: "Missing args"}});
+ try {
+ let sandwich = await models.SandwichOrder.findByPk(req.body.id);
+ let order = await models.Order.findByPk(sandwich.OrderId, {include: models.Sandwich});
+ await sandwich.destroy();
+ await order.reload();
+ if (!order.Sandwiches.length)
+ await order.destroy();
+ res.redirect("/admin/orders");
+ } catch (e) {
+ res.render("error", {message: "Fail to remove sandwich !", error: {}});
+ throw e;
+ }
+});
+
+module.exports = router;
diff --git a/routes/commands.js b/routes/commands.js
deleted file mode 100644
index 6285a3f..0000000
--- a/routes/commands.js
+++ /dev/null
@@ -1,29 +0,0 @@
-let express = require("express");
-let router = express.Router();
-let sessionCheck = require("../middlewares/sessionCheck");
-let models = require("../models");
-
-
-router.get("/", sessionCheck(2), async (req, res) => {
- let date = req.query.date ? req.query.date : (new Date()).toISOString().substring(0,10);
-
- let commands = {};
- for (let i of await models.SandwichCommand.findAll({where: {date: date}})) {
- i.Command = await models.Command.findByPk(i.CommandId);
- i.Sandwich = await models.Sandwich.findByPk(i.SandwichName);
- let name = i.Command.firstName + " " + i.Command.lastName;
-
- if (!(i.Command.DepartmentName in commands))
- commands[i.Command.DepartmentName] = {};
-
- if (!(name in commands[i.Command.DepartmentName]))
- commands[i.Command.DepartmentName][name] = {};
-
- if (!(i.Command.id in commands[i.Command.DepartmentName][name]))
- commands[i.Command.DepartmentName][name][i.Command.id] = [];
- commands[i.Command.DepartmentName][name][i.Command.id].push(i);
- }
- res.render("commands", {title: "SOD - Commands", user: req.session.user, commands: commands, date: date});
-});
-
-module.exports = router;
diff --git a/routes/command.js b/routes/order.js
similarity index 64%
rename from routes/command.js
rename to routes/order.js
index 6e60571..e016163 100644
--- a/routes/command.js
+++ b/routes/order.js
@@ -5,13 +5,13 @@ let models = require("../models");
router.post("/", async (req, res) => {
if (!req.body.department || !req.body.firstName || !req.body.lastName || !req.body.sandwich1 || !req.body.date1) {
- res.render("error", {message: "Invalid command !", "error": {status: "Missing arguments"}});
+ res.render("error", {message: "Invalid order !", "error": {status: "Missing arguments"}});
return;
}
let department = await models.Department.findByPk(req.body.department);
if (!department) {
- res.render("error", {message: "Invalid command !", error: {status: "Invalid department"}});
+ res.render("error", {message: "Invalid order !", error: {status: "Invalid department"}});
return;
}
@@ -19,14 +19,14 @@ router.post("/", async (req, res) => {
let price = 0;
for (let i = 1; req.body["sandwich" + i] !== undefined; i++) {
if (req.body["date" + i] === undefined) {
- res.render("error", {message: "Invalid command !", error: {status: "Sandwich without date"}});
+ res.render("error", {message: "Invalid order !", error: {status: "Sandwich without date"}});
return;
}
let sandwich = await models.Sandwich.findByPk(req.body["sandwich" + i]);
if (!sandwich) {
res.render("error", {
- message: "Invalid command !",
+ message: "Invalid order !",
error: {status: "Invalid sandwich: "+req.body["sandwich" + i]}
});
return;
@@ -35,21 +35,21 @@ router.post("/", async (req, res) => {
price += sandwich.price;
}
- let command = await models.Command.create({
+ let order = await models.Order.create({
firstName: req.body.firstName,
lastName: req.body.lastName,
price: price
});
let user = await models.User.findOne({where: {firstName: req.body.firstName, lastName: req.body.lastName}});
if (user)
- await command.setUser(user);
- await command.setDepartment(department);
+ await order.setUser(user);
+ await order.setDepartment(department);
for (let data of sandwiches)
try {
- await models.SandwichCommand.create({CommandId: command.id, SandwichName: data[0], date: data[1]});
+ await models.SandwichOrder.create({OrderId: order.id, SandwichName: data[0], date: data[1]});
} catch (e) {
- await command.destroy();
- res.render("error", {message: "Invalid command !", error: {status: "Invalid date"}});
+ await order.destroy();
+ res.render("error", {message: "Invalid order !", error: {status: "Invalid date"}});
throw e;
}
res.send("Ok");
diff --git a/routes/orders.js b/routes/orders.js
new file mode 100644
index 0000000..eab19d0
--- /dev/null
+++ b/routes/orders.js
@@ -0,0 +1,29 @@
+let express = require("express");
+let router = express.Router();
+let sessionCheck = require("../middlewares/sessionCheck");
+let models = require("../models");
+
+
+router.get("/", sessionCheck(2), async (req, res) => {
+ let date = req.query.date ? req.query.date : (new Date()).toISOString().substring(0,10);
+
+ let orders = {};
+ for (let i of await models.SandwichOrder.findAll({where: {date: date}})) {
+ i.Order = await models.Order.findByPk(i.OrderId);
+ i.Sandwich = await models.Sandwich.findByPk(i.SandwichName);
+ let name = i.Order.firstName + " " + i.Order.lastName;
+
+ if (!(i.Order.DepartmentName in orders))
+ orders[i.Order.DepartmentName] = {};
+
+ if (!(name in orders[i.Order.DepartmentName]))
+ orders[i.Order.DepartmentName][name] = {};
+
+ if (!(i.Order.id in orders[i.Order.DepartmentName][name]))
+ orders[i.Order.DepartmentName][name][i.Order.id] = [];
+ orders[i.Order.DepartmentName][name][i.Order.id].push(i);
+ }
+ res.render("orders", {title: "SOD - Orders", user: req.session.user, orders: orders, date: date});
+});
+
+module.exports = router;
diff --git a/routes/profile.js b/routes/profile.js
index c699955..9a28373 100644
--- a/routes/profile.js
+++ b/routes/profile.js
@@ -8,7 +8,7 @@ router.get("/", sessionCheck(0), async (req, res) => {
title: "SOD - Profile",
user: req.session.user,
departments: await models.Department.findAll(),
- commands: await models.Command.findAll({
+ orders: await models.Order.findAll({
where: {UserUsername: req.session.user.username},
include: models.Sandwich,
order: ["date"]
@@ -39,7 +39,7 @@ router.get("/", sessionCheck(0), async (req, res) => {
else {
user.firstName = req.body.firstName;
user.lastName = req.body.lastName;
- for (let c of await models.Command.findAll({where: {
+ for (let c of await models.Order.findAll({where: {
firstName: req.session.user.firstName,
lastName: req.session.user.lastName}})) {
c.firstName = user.firstName;
diff --git a/routes/register.js b/routes/register.js
index 2b54c61..807c834 100644
--- a/routes/register.js
+++ b/routes/register.js
@@ -40,7 +40,7 @@ router.get("/", async (req, res) => {
await user.setDepartment(department);
req.session.user = user;
res.redirect("/");
- for (let c of await models.Command.findAll({where: {
+ for (let c of await models.Order.findAll({where: {
firstName: user.firstName,
lastName: user.lastName,
UserUsername: null
diff --git a/routes/sandwiches.js b/routes/sandwiches.js
index 974ca92..571f41f 100644
--- a/routes/sandwiches.js
+++ b/routes/sandwiches.js
@@ -11,7 +11,7 @@ router.get("/", sessionCheck(1), async (req, res) => {
res.render("sandwiches", {
title: "SOD - Sandwiches",
user: req.session.user,
- sandwiches: await models.SandwichCommand.findAll({
+ sandwiches: await models.SandwichOrder.findAll({
attributes: ["SandwichName", [sequelize.fn("COUNT", sequelize.col("SandwichName")), "number"]],
where: {date: date},
group: "SandwichName"
diff --git a/test/database.js b/test/database.js
index 23267cb..537b5ba 100644
--- a/test/database.js
+++ b/test/database.js
@@ -174,7 +174,7 @@ describe("Database User test", () => {
});
});
-describe("Database Command tests", () => {
+describe("Database Order tests", () => {
let models;
before(async () => {
@@ -188,15 +188,15 @@ describe("Database Command tests", () => {
await wipeDatabase(models);
});
- it("Command creation", async () => {
- expect(await models.Command.create({
+ it("Order creation", async () => {
+ expect(await models.Order.create({
firstName: "Test",
lastName: "Test",
price: 1.5
- })).to.be.instanceOf(models.Command);
+ })).to.be.instanceOf(models.Order);
});
- it("Command associations", async () => {
- let testCommand = await models.Command.create({firstName: "Test", lastName: "Test", price: 1.5, },
+ it("Order associations", async () => {
+ let testOrder = await models.Order.create({firstName: "Test", lastName: "Test", price: 1.5, },
{include: [models.Department, models.Sandwich, models.User]});
let testDepartment = await models.Department.create({name: "TestDepartment"});
let testSandwich = await models.Sandwich.create({name: "TestSandwich", price: 1.5});
@@ -207,19 +207,19 @@ describe("Database Command tests", () => {
lastName: "Test",
passwordHash: "test"});
- await testCommand.setDepartment(testDepartment);
- await testCommand.reload();
- expect(testCommand.Department).to.be.instanceOf(models.Department);
- expect(testCommand.Department.name).to.be.equal(testDepartment.name);
+ await testOrder.setDepartment(testDepartment);
+ await testOrder.reload();
+ expect(testOrder.Department).to.be.instanceOf(models.Department);
+ expect(testOrder.Department.name).to.be.equal(testDepartment.name);
- await testCommand.addSandwiches(testSandwich);
- await testCommand.reload();
- expect(testCommand.Sandwiches[0]).to.be.instanceOf(models.Sandwich);
- expect(testCommand.Sandwiches[0].name).to.be.equal(testSandwich.name);
+ await testOrder.addSandwiches(testSandwich);
+ await testOrder.reload();
+ expect(testOrder.Sandwiches[0]).to.be.instanceOf(models.Sandwich);
+ expect(testOrder.Sandwiches[0].name).to.be.equal(testSandwich.name);
- await testCommand.setUser(testUser);
- await testCommand.reload();
- expect(testCommand.User).to.be.instanceOf(models.User);
- expect(testCommand.User.username).to.be.equal(testUser.username);
+ await testOrder.setUser(testUser);
+ await testOrder.reload();
+ expect(testOrder.User).to.be.instanceOf(models.User);
+ expect(testOrder.User.username).to.be.equal(testUser.username);
});
});
diff --git a/test/pages.js b/test/pages.js
index a62f924..dace703 100644
--- a/test/pages.js
+++ b/test/pages.js
@@ -80,9 +80,9 @@ describe("Public pages test", () => {
.get("/sandwiches")
.expect(302, done);
});
- it("Response to /commands", (done) => {
+ it("Response to /orders", (done) => {
request(app)
- .get("/commands")
+ .get("/orders")
.expect(302, done);
});
it("Response to /admin", (done) => {
@@ -90,9 +90,9 @@ describe("Public pages test", () => {
.get("/admin")
.expect(302, done);
});
- it("Response to /admin/commands", (done) => {
+ it("Response to /admin/orders", (done) => {
request(app)
- .get("/admin/commands")
+ .get("/admin/orders")
.expect(302, done);
});
it("404 everything else", (done) => {
@@ -169,9 +169,9 @@ for (let [p, a] of Object.entries({0: [403, 403, 403, 403], 1: [200, 403, 403, 4
.get("/sandwiches")
.expect(a[0]);
});
- it("Commands page", async () => {
+ it("Orders page", async () => {
await (await getLoginAgent(app))
- .get("/commands")
+ .get("/orders")
.expect(a[1]);
});
it("Admin page", async () => {
@@ -179,9 +179,9 @@ for (let [p, a] of Object.entries({0: [403, 403, 403, 403], 1: [200, 403, 403, 4
.get("/admin")
.expect(a[2]);
});
- it("Commands administration page", async () => {
+ it("Orders administration page", async () => {
await (await getLoginAgent(app))
- .get("/admin/commands")
+ .get("/admin/orders")
.expect(a[3]);
});
});
diff --git a/views/admin/commands.pug b/views/admin/commands.pug
deleted file mode 100644
index be1ceca..0000000
--- a/views/admin/commands.pug
+++ /dev/null
@@ -1,20 +0,0 @@
-extends ../layout
-
-block content
- div.card#commandsManagement
- h1=__("admin.commandsManagement")
- div
- each command in commands
- div.command
- div.title
- h2=command.id
- form(action="/admin/commands/command/delete" method="POST")
- input.hide(type="number" name="id" value=command.id)
- input(type="submit" value="x")
- h3 #{command.firstName} #{command.lastName}
- each sandwich in command.Sandwiches
- div.sandwich
- p #{sandwich.name} - #{sandwich.SandwichCommand.date}
- form(action="/admin/commands/sandwich/delete" method="POST")
- input.hide(type="number" name="id" value=sandwich.SandwichCommand.id)
- input(type="submit" value="x")
diff --git a/views/admin/index.pug b/views/admin/index.pug
index bfd5ff0..0c09ce2 100644
--- a/views/admin/index.pug
+++ b/views/admin/index.pug
@@ -4,12 +4,12 @@ block content
div.card
h1=__("admin.title")
div
- h2=__("admin.commandsManagement")
+ h2=__("admin.ordersManagement")
div.buttons
- a(href="/admin/commands/date")
+ a(href="/admin/orders/date")
button=__("admin.ordersDate")
- a(href="/admin/commands")
- button=__("admin.manageCommands")
+ a(href="/admin/orders")
+ button=__("admin.manageOrders")
div
h2=__("admin.sandwichManagement")
diff --git a/views/admin/orders.pug b/views/admin/orders.pug
new file mode 100644
index 0000000..e267522
--- /dev/null
+++ b/views/admin/orders.pug
@@ -0,0 +1,20 @@
+extends ../layout
+
+block content
+ div.card#ordersManagement
+ h1=__("admin.ordersManagement")
+ div
+ each order in orders
+ div.order
+ div.title
+ h2=order.id
+ form(action="/admin/orders/order/delete" method="POST")
+ input.hide(type="number" name="id" value=order.id)
+ input(type="submit" value="x")
+ h3 #{order.firstName} #{order.lastName}
+ each sandwich in order.Sandwiches
+ div.sandwich
+ p #{sandwich.name} - #{sandwich.SandwichOrder.date}
+ form(action="/admin/orders/sandwich/delete" method="POST")
+ input.hide(type="number" name="id" value=sandwich.SandwichOrder.id)
+ input(type="submit" value="x")
diff --git a/views/index.pug b/views/index.pug
index 13b50df..dbc99ef 100644
--- a/views/index.pug
+++ b/views/index.pug
@@ -4,7 +4,7 @@ block content
div.card
h1= title
p=__("index.welcome")
- form#command(action="/command" method="POST")
+ form#order(action="/order" method="POST")
div.field
label(for="department")=__("department")+":"
input#department(type="list" list="department-list" name="department" value=user ? user.DepartmentName : "" autocomplete="off" required)
@@ -19,8 +19,8 @@ block content
label(for="lastname")=__("lastName")+":"
input#lastname(type="text" name="lastName" value=user ? user.lastName : "" required)
- div#command1.command
- h2=__("command")+" 1"
+ div#order1.order
+ h2=__("order")+" 1"
div.field
label(for="sandwich1")=__("index.sandwich")+":"
input#sandwich1(type="list" list="sandwich-list" name="sandwich1" autocomplete="off" required)
@@ -28,9 +28,9 @@ block content
label(for="day1")=__("index.day")+":"
input#day1(type="date" name="date1" required)
- div#command-action
- a#add-command +
- a#remove-command.hide -
+ div#order-action
+ a#add-order +
+ a#remove-order.hide -
div.field
input#send(type="submit" value=__("index.pay"))
diff --git a/views/layout.pug b/views/layout.pug
index 9f86e2a..ff10c10 100644
--- a/views/layout.pug
+++ b/views/layout.pug
@@ -14,7 +14,7 @@ html
a(href="/sandwiches")=__("sandwiches")
if user.permissions >= 2
p -
- a(href="/commands")=__("commands")
+ a(href="/orders")=__("orders")
if user.permissions >= 3
p -
a(href="/admin")=__("admin.title")
diff --git a/views/commands.pug b/views/orders.pug
similarity index 64%
rename from views/commands.pug
rename to views/orders.pug
index a635aca..30d8f24 100644
--- a/views/commands.pug
+++ b/views/orders.pug
@@ -5,18 +5,18 @@ block content
label(for="date")=__("date")
input#date(type="date" value=date)
div#orders.card
- h1=__("commands")
- each user, department in commands
+ h1=__("orders")
+ each user, department in orders
div.department
h2= department
- each command, name in user
+ each orders, name in user
div.user
h3= name
- each order, id in command
+ each order, id in orders
div.order
- h4 #{__("command")} N°#{id}
+ h4 #{__("order")} N°#{id}
each sandwich in order
div.sandwich
h4= sandwich.Sandwich.name
- script(src="/javascripts/commands.js")
+ script(src="/javascripts/orders.js")
diff --git a/views/profile.pug b/views/profile.pug
index 50f1f0e..12a01be 100644
--- a/views/profile.pug
+++ b/views/profile.pug
@@ -30,10 +30,10 @@ block content
each department in departments
option(value=department.name)
- div.card#userCommandList
- h1=__("commands")
- each command in commands
+ div.card#userOrderList
+ h1=__("orders")
+ each order in orders
div
- h2=command.id
- each sandwich in command.Sandwiches
- p #{sandwich.name} - #{sandwich.SandwichCommand.date}
+ h2=order.id
+ each sandwich in order.Sandwiches
+ p #{sandwich.name} - #{sandwich.SandwichOrder.date}