Skip to content
Snippets Groups Projects
Commit a639b40c authored by poiuztrewq1's avatar poiuztrewq1
Browse files

last touches

parent 931a3acb
Branches
No related tags found
No related merge requests found
......@@ -14,7 +14,6 @@ module.exports = function (objectrepository) {
FoodModel.find({},(err,foods) =>{
if(err) return next(err);
res.locals.foods = foods;
return next();
......
const requireOption = require('../common/requireOption');
/**
* Handles the no food error (When one ants to add storage item, but there are no food types in database)
*/
module.exports = function (objectrepository) {
const FoodModel = requireOption(objectrepository, 'FoodModel');
return function (req, res, next) {
if(req.query.nofood) res.locals.warning = "Először létre kell hozni egy étel típust az adatbázisban!";
return next();
}
};
\ No newline at end of file
const requireOption = require('../common/requireOption');
/**
* Deletes food from database, using foodid param
*/
module.exports = function (objectrepository) {
return function (req, res, next) {
if(res.locals.foods.length == 0){
return res.redirect('/foods/new?nofood=1');
}
return next();
};
};
......@@ -7,7 +7,7 @@ const getFoodListMW = require('../middleware/food/getFoodList');
const saveFoodMW = require('../middleware/food/saveFood');
const getFoodMW = require('../middleware/food/getFood');
const deleteFoodMW = require('../middleware/food/deleteFood');
const handleNoFoodMW = require('../middleware/food/handleNoFood');
module.exports = function (app, objectRepository) {
app.get('/foods',
......@@ -18,6 +18,7 @@ module.exports = function (app, objectRepository) {
app.use('/foods/new',
authMW(objectRepository),
handleNoFoodMW(objectRepository),
saveFoodMW(objectRepository),
renderMW(objectRepository,'foodeditcreate')
);
......
......@@ -8,6 +8,7 @@ const getFoodListMW = require('../middleware/food/getFoodList');
const addStorageItemMW = require('../middleware/storage/addStorageItem');
const deletStorageItemMW = require('../middleware/storage/deleteStorageItem');
const updateBunkerStatsMW = require('../middleware/storage/updateBunkerStats');
const checkFoodListMW = require('../middleware/storage/checkFoodList');
module.exports = function (app,objectRepository) {
......@@ -16,6 +17,7 @@ module.exports = function (app,objectRepository) {
authMW(objectRepository),
getBunkerMW(objectRepository),
getFoodListMW(objectRepository),
checkFoodListMW(objectRepository),
addStorageItemMW(objectRepository),
updateBunkerStatsMW(objectRepository),
function(req,res,next){
......
......@@ -4,7 +4,6 @@
<% if(typeof warning != 'undefined'){ %>
<div class="alert alert-warning" role="alert">
<h2>A mentés nem sikerült</h2>
<p><%= warning %></p>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment