Started work on adding license tracking
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
const db = require('../models');
|
||||
const Item = db.items;
|
||||
const License = db.licenses;
|
||||
|
||||
// GET - /
|
||||
exports.getIndex = async function(req, res) {
|
||||
// fetch inventory items from database
|
||||
const items = await Item.findAll({
|
||||
limit: 10,
|
||||
order: [
|
||||
@ -10,9 +12,18 @@ exports.getIndex = async function(req, res) {
|
||||
],
|
||||
});
|
||||
|
||||
// fetch licenses from database
|
||||
const licenses = await License.findAll({
|
||||
limit: 10,
|
||||
order: [
|
||||
['updatedAt', 'DESC'],
|
||||
],
|
||||
});
|
||||
|
||||
// req.flash('info', 'This is a test flash message.');
|
||||
|
||||
res.render('index.twig', {
|
||||
inventory: items,
|
||||
licenses: licenses,
|
||||
});
|
||||
};
|
||||
|
22
src/routes/license.js
Normal file
22
src/routes/license.js
Normal file
@ -0,0 +1,22 @@
|
||||
const db = require('../models');
|
||||
const License = db.licenses;
|
||||
|
||||
// GET - /license/add
|
||||
exports.getAdd = async function(req, res) {
|
||||
res.render('license/add.twig');
|
||||
};
|
||||
|
||||
// POST - /license/add
|
||||
exports.postAdd = async function(req, res) {
|
||||
const license = await License.create({
|
||||
name: req.body.license_name,
|
||||
key: req.body.license_key,
|
||||
manufacturer: req.body.license_manufacturer,
|
||||
purchasedFrom: req.body.license_purchase_from,
|
||||
purchasedAt: req.body.license_purchase_date,
|
||||
});
|
||||
|
||||
console.log(`Saved license ${license.name} to the database.`);
|
||||
|
||||
res.redirect('/');
|
||||
};
|
Reference in New Issue
Block a user