mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:57:07 +00:00
Use default Nunjucks template if necessary.
If the survey configuration does not itself have a template we will use the one in etc/defaults/templates/sequence.html.njk. It is not very likely that the template will be changed all that often and it avoids issues when people forget to copy it across to a new survey, etc.
This commit is contained in:
@@ -2,14 +2,17 @@ const { configuration } = require('../../../../lib/db');
|
||||
const { transform, prepare } = require('../../../../lib/sse');
|
||||
const render = require('../../../../lib/render');
|
||||
|
||||
// FIXME Refactor when able
|
||||
const defaultTemplatePath = require('path').resolve(__dirname, "../../../../../../../etc/default/templates/sequence.html.njk");
|
||||
|
||||
const html = async function (req, res, next) {
|
||||
try {
|
||||
const query = req.query;
|
||||
query.sequence = req.params.sequence;
|
||||
const {events, sequences} = await prepare(req.params.project, query);
|
||||
const seis = transform(events, sequences, {projectId: req.params.project});
|
||||
const templates = await configuration.get(req.params.project, "sse/templates");
|
||||
const template = templates[0].template;
|
||||
const template = (await configuration.get(req.params.project, "sse/templates/0/template")) || defaultTemplatePath;
|
||||
console.log("TEMPLATE", template);
|
||||
|
||||
const response = await render(seis, template);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user