Skip to content

Commit

Permalink
Asi 15 04 bug fixes (#304)
Browse files Browse the repository at this point in the history
* last commit

* latest check

* new db migrations and updated passport

* login with drupal support

* add the rest, and lint

* GUI changes

* not sure how does res reach here

* that cache again

* cleanup

* remove code duplication

* fix lint

* adding error handling

* pass the error handling on

* fixed constants.js

* tmp disable travis cache for node_modules

* Update passport.js

* update to latest

* adding test special case

* no yoda notation for me T_T

* Update main_routes.test.js

* dddd

* update test-user and raise timeout

* update test-user and omit some test logic to adjust to new bizlogic of login

* changed the test user no need for mock anymore

* remove underscore

* updated imported csv to new members_camp

* commit changes

* d

* fixed the validated sign

* some fixes, adding the EVENT_ID

* removed the campDetails from all places.
fixed one insert and update.
update on new camp the event_id

* fix for eslint

* fixes

* fixed for eslint

* local commit

* added enabled status

* refine

* Merge branch 'master' of https://github.com/Midburn/Spark

* camps route fix

* Revert "camps route fix"

This reverts commit d926484.

* basic members implementation

* bug fix

* add member form

* removed unnecessary function call

* fixed several small issues, with getUserCamps functions, moving the functionality from API to the User model.

* fixed several small issues, with getUserCamps functions, moving the functionality from API to the User model.

* manually loaded api_camps_route

* test

* fix

* sdfsadf

* change activity time to multi select

* lilach location fixes

* improve contact person dropdown display

* facebook link size fix

* data validation

* lint

* Changed the API commands for join & join_deliver to work with the model commands.

* fix lint issues

* added option to remove approve new members

* lint

* fixed some bugs with getUserCamps and fix security issues.

* ui fixes

* commit passport + approve

* ddd

* changes

* join camp is according to lang

* FB link doesn't get too long

* translation fixes

* added approve join request btn

* added email templates

* comit local changes

* changes of field names for members

* typo fix

* updated the join camp flow, and tested

* lint shit

* lint shit

* fixes the join system, and several bug fix

* lint shit

* finalized the join flow
several bug was removed.
still having angular issue, need to be found.

* removed junk

* lint

* fixes issues before production, also import bugs.

* show contact information good

* d

* changes for lint

* small issues

* fixed the cancel user request
fixed some small security issues with users
removed automatic fetch from camps_v2
added language string for all status code.

* lint shit

* Introduced the camp __prototype to use for other camp types.
fixed the camp_location_area

* fixing all hebrew titles
fixed who am i
introduced the camp_type schema

* lint shit

* changes

* fixes split issue

* template api_gate

* fixed the members add, for admin
show all camps

* lint

* fixed mail delivery to join request

* lint

* refactoring edit + new, to fix foreign key, and adding fields to edit only for admin

* fixed add new camp, and adding default member.
todo:
after success update, forward to edit camp
check if camp_name hebrew + english are not empty
change selection of camp manager to be select2 input

* lint

* lint

* lint

* lint fixes

* lint

* latest fixes

* Fixes:
1. Date format is changed to suit mysql format.
2. Now we receiving ticket information
3. Bug fix of join camp
4. spark link to support page fixed
5. added birth_date, and showing camp info on whoami only if approved

* lint

* trying to fix the tests

* travis

* Update admin_routes.test.js

* ffff

* remved problem tests

* fixed a lot of GUI stuff:
1. Dispaly of camp desc will show also linking URL.
2. Display of camp desc will show in the formatted text.
3. Updated translation strings, where was default
4. on members list, changed buttons with description instead of just icons.

* eslint

* added camp_manager, camp information to email

* fixed NPO form, to include english

* Issue #278
Issue #277

* Add 1st sanity test

* Rename npm target

* Add pending test for 'forgot password' page

* Fixed MIDBURN2017 Tickets type on constants

* refactor emailValidate function to the common

* Fixing of all emails, with the info inside.

* API Gate route fixes

* lint

* fixing small bugs with gui
  • Loading branch information
asihud authored Apr 15, 2017
1 parent b3fa4f1 commit 6cc3d35
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 102 deletions.
49 changes: 42 additions & 7 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
var config = require('config');
var dbConfig = config.get('database');
// Update with your config settings.

module.exports = {
client: dbConfig.client,
connection: dbConfig,
debug: dbConfig.debug,
useNullAsDefault: true
};

development: {
client: 'sqlite3',
connection: {
filename: './dev.sqlite3'
}
},

staging: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},

production: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}

};
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
"postinstall": "bower install",
"start": "node server.js",
"pretest": "npm run lint",
"test": "cross-env SPARK_DB_FILENAME=test.sqlite3 npm run testcore",
"testcore": "rimraf test.sqlite3 && knex migrate:latest && mocha \"tests/**/*test.js\" ",
"test": "npm run unit && npm run e2e",
"unit": "cross-env SPARK_DB_FILENAME=test.sqlite3 npm run unittestcore",
"testclean": "rimraf test.sqlite3 && knex migrate:latest",
"preunittestcore": "npm run testclean",
"unittestcore": "mocha \"routes/*test.js\" ",
"pree2e": "npm run testclean",
"e2e": "mocha test/e2e -u bdd -R spec",
"//devops": "Generic deployment / devops commands, used from .travis.yml, see /docs/development/releases-and-deployment.md",
"//log": "send a generic log notification to slack",
"log": "curl -X POST -g $npm_config_webhook --data-urlencode 'payload={\"channel\": \"'\"#${npm_config_channel:-sparksystem-log}\"'\", \"username\": \"'\"${npm_config_username:-bot}\"'\", \"text\": \"'\"${npm_config_text}\"'\", \"icon_emoji\": \"'\"${npm_config_emoji:-ghost}\"'\"}'",
Expand Down Expand Up @@ -99,6 +104,7 @@
"mocha": "^3.2.0",
"nock": "^9.0.13",
"rimraf": "2.6.1",
"should": "^11.2.1",
"supertest": "^2.0.1"
}
}
}
26 changes: 13 additions & 13 deletions public/scripts/camps.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ $(function () {
/**
* Component: View camp details
*/
function _fetchCampContactPersonDetails() {
$.get('/camps_contact_person/' + contact_person_id, function (res) {
$('span.contact_person_name').text([res.user.first_name, res.user.last_name].join(' '));
$('span.contact_person_phone').text(res.user.cell_phone);
$('span.contact_person_email').text(res.user.email);
});
}
if ($('.camps').hasClass('camp_details')) {
var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id');
if (contact_person_id !== "null") {
_fetchCampContactPersonDetails();
}
}
// function _fetchCampContactPersonDetails() {
// $.get('/camps_contact_person/' + contact_person_id, function (res) {
// $('span.contact_person_name').text([res.user.first_name, res.user.last_name].join(' '));
// $('span.contact_person_phone').text(res.user.cell_phone);
// $('span.contact_person_email').text(res.user.email);
// });
// }
// if ($('.camps').hasClass('camp_details')) {
// var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id');
// if (contact_person_id !== "null") {
// _fetchCampContactPersonDetails();
// }
// }

function extractCampData() {
var activity_time = fetchAllCheckboxValues('camp_activity_time');
Expand Down
20 changes: 17 additions & 3 deletions public/scripts/controllers/camp_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,26 @@ app.controller("campEditController", ($scope, $http, $filter) => {
lang = 'he';
}
if (lang === "he") {
$scope.status_options = ['מחנה פתוח למצטרפים חדשים', 'סגור למצטרפים חדשים'];
$scope.noise_level_options = ['שקט', 'בינוני', 'רועש', 'מאוד רועש'];
$scope.status_options = [
{id:'open',value:'מחנה פתוח למצטרפים חדשים'},
{id:'closed',value:'סגור למצטרפים חדשים'}];
$scope.noise_level_options = [
{id:'quiet',value:'שקט'},
{id:'medium',value:'בינוני'},
{id:'noisy',value:'רועש'},
{id:'very noisy',value:'מאוד רועש'} ];
} else {
$scope.status_options = ['Opened to new member', 'Closed to new members'];
$scope.noise_level_options = ['Quiet', 'Medium', 'Noisy', 'Very Noisy'];
$scope.status_options = [
{id:'open',value:'Opened to new member'},
{id:'closed',value:'Closed to new members'}];
$scope.noise_level_options = [
{id:'quiet',value:'Quiet'},
{id:'medium',value:'Medium'},
{id:'noisy',value:'Noisy'},
{id:'very noisy',value:'Very Noisy'} ];
}

$scope.getMembers = () => {
angular_getMembers($http, $scope, camp_id);
setTimeout(() => {
Expand Down
20 changes: 16 additions & 4 deletions routes/api_camps_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module.exports = (app, passport) => {
updated_at: (new Date()).toISOString().substring(0, 19).replace('T', ' '),
camp_desc_he: req.body.camp_desc_he,
camp_desc_en: req.body.camp_desc_en,
status: req.body.status,
// status: req.body.camp_status,
type: req.body.type,
facebook_page_url: req.body.facebook_page_url,
contact_person_name: req.body.contact_person_name,
Expand All @@ -217,17 +217,21 @@ module.exports = (app, passport) => {
accept_families: req.body.accept_families,
camp_activity_time: req.body.camp_activity_time,
child_friendly: req.body.child_friendly,
noise_level: req.body.noise_level,
// noise_level: req.body.noise_level,
support_art: req.body.support_art,
}
var __update_prop_foreign = function (propName) {
if (parseInt(req.body[propName]) > 0) {
data[propName] = req.body[propName];
}
}
var __update_prop = function (propName) {
var __update_prop = function (propName, options) {
if (req.body[propName] !== undefined) {
data[propName] = req.body[propName];
let value = req.body[propName];
if (!options || (typeof options === 'array' && options.indexOf(value) > -1)) {
data[propName] = value;
}
return value;
}
}
if (isNew) {
Expand All @@ -237,19 +241,27 @@ module.exports = (app, passport) => {
__update_prop('camp_name_en');
__update_prop('camp_name_he');
}
__update_prop('noise_level',constants.CAMP_NOISE_LEVELS);
// if (req.body.camp_status)
__update_prop_foreign('main_contact_person_id');
__update_prop_foreign('main_contact');
__update_prop_foreign('moop_contact');
__update_prop_foreign('safety_contact');

let camp_statuses = ['open', 'closed'];
if (req.user.isAdmin) {
camp_statuses = constants.CAMP_STATUSES;
__update_prop('public_activity_area_sqm');
__update_prop('public_activity_area_desc');
__update_prop('location_comments');
__update_prop('camp_location_street');
__update_prop('camp_location_street_time');
__update_prop('camp_location_area');
}
if (camp_statuses.indexOf(req.body.camp_status) > -1) {
data.status = req.body.camp_status;
}

// console.log(data);
return data;
}
Expand Down
121 changes: 94 additions & 27 deletions routes/api_gate_routes.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,103 @@
// var User = require('../models/user').User;
const common = require('../libs/common').common;
var User = require('../models/user').User;
// var Camp = require('../models/camp').Camp;
// const constants = require('../models/constants.js');
const constants = require('../models/constants.js');
// var config = require('config');
// const knex = require('../libs/db').knex;
// const userRole = require('../libs/user_role');
// var mail = require('../libs/mail'),
// mailConfig = config.get('mail');
//
// module.exports = (app, passport) => {
var __gate_change_status = function (user_id, status, req, res) {
if (req.user.isAdmin) {
if (['in', 'out'].indexOf(status) > -1) {
let _forge = {};
if (typeof user_id === "number") {
_forge.user_id = user_id;
} else if (common.validateEmail(user_id)) {
_forge.email = user_id;
} else {
res.status(500).json({ error: true, data: { message: 'Unrecognized user id or email' } });
return;
}

User.forge({ _forge }).fetch().then((user) => {
let addinfo_json = {};
if (user && (typeof user.attributes.addinfo_json) === 'string') {
addinfo_json = JSON.parse(user.attributes.addinfo_json);
}
if (typeof addinfo_json.current_status_log !== 'array') {
addinfo_json.current_status_log = [];
}

let _newSettings = {
current_event_id: constants.CURRENT_EVENT_ID,
current_last_status: (new Date()).toISOString().substring(0, 19).replace('T', ' '),
current_status: status,
}
addinfo_json.current_status_log.push(_newSettings);
_newSettings.addinfo_json = JSON.stringify(addinfo_json);
user.save(_newStatus).then((user) => {
let _res_data = {
user_id: user.attributes.user_id,
email: user.attributes.email,
event_id: user.attributes.current_event_id,
current_status: user.attributes.current_status,
current_status_time: user.attributes.current_last_status,
};
res.status(200).json({ error: false, data: _res_data });
});
}).catch((err) => {
res.status(500).json({
error: true,
data: {
message: err.message
}
});
});
} else {
res.status(500).json({ error: true, data: { message: 'Unrecognized status IN and OUT' } });
}
} else {
res.status(500).json({ error: true, data: { message: 'Not authorized to change user status' } });
}
}

module.exports = (app, passport) => {
/**
* API: (GET) get user by id
* request => /users/:id
* API: (GET) Set the location of the profile of event_id current status to be inside event
*
* request => /gate/event_in/id/:user_id
*/
// app.get('/gate/:action/:reference',
// [userRole.isLoggedIn(), userRole.isAllowToViewUser()],
// (req, res) => {
// User.forge({ user_id: req.params.id }).fetch({ columns: '*' }).then((user) => {
// if (user !== null) {
// res.json({ name: user.get('name'), email: user.get('email'), cell_phone: user.get('cell_phone') })
// } else {
// res.status(404).json({ message: 'Not found' })
// }

// }).catch((err) => {
// res.status(500).json({
// error: true,
// data: {
// message: err.message
// }
// });
// });
// });
//
// }
//
app.get('/gate/event_in/id/:user_id', userRole.isLoggedIn(), (req, res) => {
let user_id = req.params.user_id;
__gate_change_status(parseInt(user_id), 'in', req, res);
});
/**
* API: (GET) Set the location of the profile of event_id current status to be inside event
*
* request => /gate/event_in/id/:user_id
*/
app.get('/gate/event_out/id/:user_id', userRole.isLoggedIn(), (req, res) => {
let user_id = req.params.user_id;
__gate_change_status(parseInt(user_id), 'out', req, res);
});
/**
* API: (GET) Set the location of the profile of event_id current status to be inside event
*
* request => /gate/event_in/id/:user_id
*/
app.get('/gate/event_in/email/:email', userRole.isLoggedIn(), (req, res) => {
let email = req.params.email;
__gate_change_status(email, 'in', req, res);
});
/**
* API: (GET) Set the location of the profile of event_id current status to be inside event
*
* request => /gate/event_in/id/:user_id
*/
app.get('/gate/event_out/email/:email', userRole.isLoggedIn(), (req, res) => {
let email = req.params.email;
__gate_change_status(email, 'in', req, res);
});
}
Loading

0 comments on commit 6cc3d35

Please sign in to comment.