Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency debug to v4 #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const usersRouter = require('./routes/users');
const requestsRouter = require('./routes/requests');
const furnitureRouter = require('./routes/furniture');
const reportsRouter = require('./routes/reports');
const textRouter = require('./routes/text');

const app = express();

Expand Down Expand Up @@ -150,7 +151,7 @@ app.use(async function(req, res, next){
});

// Set common helpers for the view
app.use(function(req, res, next){
app.use(async function(req, res, next){
res.locals.config = config;
res.locals.session = req.session;
res.locals.title = config.get('app.name');
Expand All @@ -168,6 +169,7 @@ app.use('/users', usersRouter);
app.use('/requests', requestsRouter);
app.use('/furniture', furnitureRouter);
app.use('/reports', reportsRouter);
app.use('/text', textRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
Expand Down
5 changes: 4 additions & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"app": {
"name": "APP_NAME",
"dbURL": "DATABASE_URL",
"dbSSL": "DATABASE_SSL",
"sessionType": "SESSION_TYPE",
"sessionSecret": "SESSION_SECRET",
"graphqlURL": "INTERCODE_GRAPHQL_URL",
"interconBaseURL": "INTERCON_BASE_URL",
"redisURL": "REDISTOGO_URL"
"redisURL": "REDISTOGO_URL",
"specialRequestsName": "SPECIAL_REQUEST_NAME",
"arisiaMode": "ARISIA_MODE"
},
"auth": {
"authorizationURL": "INTERCODE_URL",
Expand Down
4 changes: 3 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"graphqlURL": "graphqlURL",
"interconBaseURL": "interconBaseURL",
"redisURL": false,
"debug": true
"debug": true,
"specialRequestsName": "Other Notes",
"arisiaMode" : false
},
"auth": {
"authorizationURL": "authorizationURL",
Expand Down
7 changes: 7 additions & 0 deletions data/texts/intercon/requestFood.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
p.form-text.text-muted.my-1.
The hotel can provide food or food and bartending service at GM cost. <strong> INTERCON CANNOT PAY FOR THESE SERVICES.</strong> Do you need either of them?

p.form-text.text-muted.my-1.
Please note that these are the ONLY way you can serve food or alcohol at your game. As per the contract with the hotel, GMs cannot bring food or drink into your game or event, and NO alcohol is allowed in con space without a hotel bartender present. More information about pricing is available at <a href='#{config.app.interconBaseURL}/pages/gmpolicies#FoodService' target='_blank'> GM Benefits and Policies</a>, the menus are available at <a href='#{config.app.interconBaseURL}/pages/hotel/menu' target='_blank'>Hotel Menu</a>, or contact the <a href='mailto:hotel@interconlarp.org'>Hotel Liaison</a>
p.form-text.text-muted.my-1.
If you do not need food or bartending, please leave this field blank
10 changes: 10 additions & 0 deletions data/texts/intercon/requestIndex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
p.my-1.
Thanks for filling out this form. This will help us make sure that we're doing everything we can to allow you to run your game on time and seamlessly.
p.my-2.
Please select each of your functions that you are responsible for, and enter your furniture and food needs, or indicate that you have none.
p.my-2
strong.mr-1.
Please Note:
| Most furniture requests will be merged into a single request per room that meets the needs of all larps in that room for the entire weekend. We can not provide fully invidual setups for each event. You may end up with more funiture that you need for your game, if so, please fold it against a wall as best you can. Before Intercon, we will let you know what furniture will be in each room.
p.my-1.
A map of the hotel function space is available at the <a class='alert-link' href='#{config.app.interconBaseURL}/pages/hotel/layout' target='_blank'>Hotel Layout</a> page
12 changes: 12 additions & 0 deletions data/texts/intercon/requestShow.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
p.my-1.
Descriptions for items can be viewed by mousing over, clicking, or tapping the item name

p.my-1
span More information about some of the things on this form is available at the
a.alert-link.mx-1(href=`${config.app.interconBaseURL}/pages/gmpolicies` target="_blank") GM Benefits and Policies
span document.

p.my-1
span A map of the hotel function space is available at the
a.alert-link.mx-1(href=`${config.app.interconBaseURL}/pages/hotel/layout` target="_blank") Hotel Layout
span page
4 changes: 4 additions & 0 deletions data/texts/intercon/requestSpecial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
p.form-text.text-muted.my-1.
Is there anything else we need to know? Anything not covered by the previous sections, strange requests, and so on?
p.form-text.text-muted.my-1.
If you don't have anythig for this, please leave this field blank.
8 changes: 7 additions & 1 deletion lib/furniture-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const _ = require('underscore');
const pluralize = require('pluralize');
const async = require('async');
const pug = require('pug');

const models = {
runs: require('../models/runs'),
Expand Down Expand Up @@ -95,9 +96,14 @@ function findLatest(time, requests){
return time;
}

function renderText(content, res){
return pug.render(content, res.locals);
}

module.exports = {
getRunList: getRunList,
humanize: humanize,
setSection: setSection,
teamMembers: teamMembers
teamMembers: teamMembers,
renderText: renderText
};
28 changes: 15 additions & 13 deletions lib/intercode.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ class Intercode {
const result = await this.request(query, { conventionDomain: getConventionDomain() });
return result.convention.rooms;
}

async getConvention(){


const query = gql`query getConvention($conventionDomain: String!) {
convention: conventionByDomain(domain: $conventionDomain) {
id
name
starts_at
ends_at
}
}`;
const result = await this.request(query, { conventionDomain: getConventionDomain() });
return result.convention;
}
}


Expand Down Expand Up @@ -351,19 +366,6 @@ class Intercode {
// return result.convention.event;
// };

// TODO: Delete? This seems unused
// Intercode.prototype.getConvention = function(cb){
// const query = gql`query getConvention($conventionDomain: String!) {
// convention: conventionByDomain(domain: $conventionDomain) {
// id
// name
// starts_at
// ends_at
// }
// }`;
// request(this.accessToken, query, { conventionDomain: getConventionDomain() }, cb);
// };

Intercode.InvalidTokenError = InvalidTokenError;

module.exports = Intercode;
22 changes: 19 additions & 3 deletions lib/permission.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
'use strict';
const _ = require('underscore');
const config = require('config');

const permissionLookup = {
'GM Coordinator' : 'Div Head',
'Con Com': 'Hotel Team',
'Hotel Liaison': 'Administrator'
};

module.exports = function(permission, redirect){
return async function(req, res, next){
if (! (_.has(req, 'user') && _.has(req, 'intercode'))){
res.locals.checkPermission = getCheckPermission(req, {
privileges: [],
positions: []
permissions: {
privileges: [],
positions: []
},
events: []
});
if (!permission){ return next(); }
return fail(req, res, 'not logged in', redirect);
Expand Down Expand Up @@ -78,17 +88,23 @@ function check(req, data, permission){
return false;
}

// Override Intercon permissions for Arisia
if (config.get('app.arisiaMode') && _.has(permissionLookup, permission)){
permission = permissionLookup[permission];
}

// Check to see if logged in
if (permission === 'login'){
if (user) {
return true;

}

// Staff get all permissions
} else if (data.permissions.privileges.indexOf('staff') !== -1 || data.permissions.privileges.indexOf('site_admin') !== -1){
return true;
// Conchair and Webteam get all permissions
} else if (data.permissions.positions.indexOf('Con Chair') !== -1 || data.permissions.privileges.indexOf('Website Team') !== -1){
} else if (data.permissions.positions.indexOf('Con Chair') !== -1 || data.permissions.privileges.indexOf('Website Team') !== -1 || data.permissions.positions.indexOf('Administrator') !== -1){
return true;
// Check for specific permission in privileges
} else if (data.permissions.privileges.indexOf(permission) !== -1){
Expand Down
30 changes: 30 additions & 0 deletions migrations/1700051650158_textfields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable camelcase */
'use strict';

exports.up = pgm => {
pgm.createTable(
'display_text',
{
'id': {type: 'serial'},
'name': {type: 'varchar', notNull: true},
'description': {type: 'text', notNull: true},
'content': {type: 'text', notNull: true}
},
{ ifNotExists: true }
);

pgm.addConstraint('display_text', 'texts_pkey', {
primaryKey: 'id',
deferrable: false,
deferred:false
});
pgm.addConstraint('display_text', 'texts_name_uk', {
unique: 'name',
deferrable: false,
deferred:false
});
};

exports.down = pgm => {
pgm.dropTable('display_text');
};
47 changes: 47 additions & 0 deletions models/display_text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';
const database = require('../lib/database');
const validator = require('validator');


exports.get = async function(id){
return database.querySingle('select * from display_text where id = $1', [id]);
};

exports.getByName = async function(name){
console.log('getting ' + name);
return database.querySingle('select * from display_text where name = $1', [name]);
};

exports.list = async function(){
return database.queryRows('select * from display_text');
};

exports.create = async function(data){
if (!validate(data)){
throw new Error('Invalid Data');
}
const query = 'insert into display_text (name, description, content) values ($1, $2, $3) returning id';
const dataArr = [data.name, data.description, data.content];
return database.insertReturningId(query, dataArr);
};

exports.update = async function(id, data){
if (!validate(data)){
throw new Error('Invalid Data');
}
const query = 'update display_text set name = $2, description = $3, content = $4 where id = $1';
const dataArr = [id, data.name, data.description, data.content];
await database.query(query, dataArr);
};

exports.delete = async function(id){
const query = 'delete from display_text where id = $1';
await database.query(query, [id]);
};

function validate(data){
if (! validator.isLength(data.name, 2, 255)){
return false;
}
return true;
}
Loading