Added project view pagae

This commit is contained in:
Gregory Ballantine 2023-11-26 02:23:52 -05:00
parent ecc48226a7
commit e5602e660d
3 changed files with 28 additions and 0 deletions

View File

@ -40,6 +40,7 @@ const projectRoutes = require('./src/routes/project');
app.get('/', indexRoutes.getIndex);
app.get('/project', projectRoutes.getIndex);
app.get('/project/list', projectRoutes.getList);
app.get('/project/:project_id', projectRoutes.getView);
app.get('/project/add', projectRoutes.getAdd);
app.post('/project/add', projectRoutes.postAdd);

View File

@ -13,6 +13,18 @@ exports.getList = async function(req, res) {
});
};
// GET /project/:project_id - view information about a project
exports.getView = async function(req, res) {
var project = await Project.findAll({
where: {
id: req.params.project_id
}
});
res.render('project/view', {
project: project[0]
});
};
// GET /project/add - add a new project
exports.getAdd = async function(req, res) {
res.render('project/add');

15
views/project/view.twig Normal file
View File

@ -0,0 +1,15 @@
{% extends 'layouts/default.twig' %}
{% block title %}{{ project.title }}{% endblock %}
{% block content %}
<div class="row">
<h2>{{ project.title }}</h2>
<p>{{ project.description }}</p>
<hr>
<p><a href="/project">Back</a></p>
</div>
{% endblock %}