Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
const should = require('chai').should();
const app = require('widget-cms');
const NodeEvent = app.getModel('Event');
const eventsData = require('../sql/data/events');
const moment = require('moment');
describe('Event', function(){
var eventData = eventsData[0];
var event = new NodeEvent();
describe('#set #save', function() {
it('should create a new event', function(done){
event.set(eventData);
event.save()
"use strict";
const should = require('chai').should();
const app = require('widget-cms');
const Meetup = app.getModel('Meetup');
const meetupsData = require('../sql/data/meetups');
describe('Meetup', function(){
let meetupData = meetupsData[0];
let meetup = new Meetup();
describe('#set #save', function() {
it('should create a new meetup', function(done){
meetup.set(meetupData);
meetup.save()
"use strict";
const should = require('chai').should();
const app = require('widget-cms');
const User = app.getModel('User');
describe('Roles', function(){
describe('#fetch', function() {
it('should fetch a role from a user', function(done){
User.forge({id: 1})
.fetch({withRelated: ['role']})
.then(function(user) {
let role = user.related('role');
role.get('id').should.equal(3);
role.get('name').should.equal('Super Administrator');
done();
})
.catch(function (error) {
done(error);
"use strict";
const should = require('chai').should();
const app = require('widget-cms');
const User = app.getModel('User');
function createFakeUser() {
let user = {};
user.name = 'John Doe';
user.email = 'user_' + Date.now() + '@none.com';
user.password = 'juliet';
user.role_id = 1;
return user;
}
describe('User', function(){
client.post('statuses/update', { status: tweet }, function(err, data, response) {
if (err) {
console.error(err)
}
else {
const Tweet = App.getModel('Tweet');
Tweet.forge({type: type, payload: payload})
.save()
.then(function (tweet) {
console.error('Tweet saved to db')
})
.catch(function (error) {
console.error(error)
});
}
});
}
postMessageToAll: async function(req, res, next) {
req.assert('message', 'Message must be at least 12 characters long').len(2);
let errors = req.validationErrors();
if (errors) {
req.flash('errors', errors);
return res.redirect('back');
}
try {
let Users = App.getCollection('Users');
let Conversation = App.getModel('Conversation');
let Message = App.getModel('Message');
let from = req.user;
let allusers = await Users.forge().query('where', 'id', '!=', from.get('id')).fetch();
allusers.each(function (user) {
let sentmessage = sendMessage(req.user, user, req.body.message, req.headers.host);
});
return res.redirect('back');
}
catch (e) {
console.error(e);
return res.redirect('back');
}
}
postMessageToAll: async function(req, res, next) {
req.assert('message', 'Message must be at least 12 characters long').len(2);
let errors = req.validationErrors();
if (errors) {
req.flash('errors', errors);
return res.redirect('back');
}
try {
let Users = App.getCollection('Users');
let Conversation = App.getModel('Conversation');
let Message = App.getModel('Message');
let from = req.user;
let allusers = await Users.forge().query('where', 'id', '!=', from.get('id')).fetch();
allusers.each(function (user) {
let sentmessage = sendMessage(req.user, user, req.body.message, req.headers.host);
});
return res.redirect('back');
}
catch (e) {
console.error(e);
return res.redirect('back');
}
}
});
"use strict";
const App = require('widget-cms');
const Categories = App.getCollection('Categories');
const Posts = App.getCollection('Posts');
const Post = App.getModel('Post');
const User = App.getModel('User');
function processTags(tags) {
if (!tags) {
return [{name: 'uncategorised'}];
}
tags = tags.split(',');
tags = tags.map(function (tag) {
return {name: tag.trim()};
});
return tags;
}
"use strict";
/**
* Blog tags collection
**/
const App = require('widget-cms');
const Tag = App.getModel('Tag');
const Tags = App.Collection.extend({
model: Tag,
limit: 5,
/**
* Fetches featured front page posts
*/
fetchTags: function (limit, options) {
"use strict";
/**
* Users collection
**/
const App = require('widget-cms');
const Role = App.getModel('Role');
const Roles = App.Collection.extend({
model: Role
});
module.exports = App.addCollection('Roles', Roles);