Skip to content

Commit

Permalink
Asi 07 04 changes 1 (#255)
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
  • Loading branch information
asihud authored and Netanel Ben committed Apr 8, 2017
1 parent 8820d82 commit 5091a9a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 161 deletions.
147 changes: 83 additions & 64 deletions public/scripts/controllers/camp_edit.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,88 @@
app.controller("campEditController", ($scope, $http, $filter) => {
var camp_id = document.querySelector('#meta__camp_id').value;
$scope.status_options = ['open', 'closed']
$scope.noise_level_options = ['quiet', 'medium', 'noisy', 'very noisy']

var _getMembers = () => {
$http.get(`/camps/${camp_id}/members`).then((res) => {
var members = res.data.members;
var _members = [];
var approved_members = [];
for (var i in members) {
if (['approved', 'pending', 'pending_mgr', 'approved_mgr', 'rejected'].indexOf(members[i].member_status) > -1) {
_members.push(members[i]);
}
if (['approved', 'approved_mgr'].indexOf(members[i].member_status) > -1) {
approved_members.push(members[i]);
}
var angular_getMembers = function ($http, $scope, camp_id) {
$http.get(`/camps/${camp_id}/members`).then((res) => {
var members = res.data.members;
var _members = [];
var approved_members = [];
for (var i in members) {
if (['approved', 'pending', 'pending_mgr', 'approved_mgr', 'rejected'].indexOf(members[i].member_status) > -1) {
_members.push(members[i]);
}
if (['approved', 'approved_mgr'].indexOf(members[i].member_status) > -1) {
approved_members.push(members[i]);
}
$scope.members = _members;
$scope.approved_members = approved_members;
}
$scope.members = _members;
$scope.approved_members = approved_members;
});
}
var angular_updateUser = function ($http, $scope, action_type, user_rec) {
var camp_id = user_rec.camp_id;
var user_name = user_rec.user_name;
var user_id = user_rec.user_id;
var lang = $scope.lang;
if (lang === undefined) {
lang = 'he';
}
var tpl;
if (lang === "he") {
tpl = {
alert_title: "האם את/ה בטוח?",
alert_text: "האם את/ה בטוח שתרצה לבצע " + action_type + " את משתמש " + user_name + "?",
alert_success_1: action_type + "!",
alert_success_2: "משתמש " + user_name + action_type,
alert_success_3: " בהצלחה",
};
} else {
tpl = {
alert_title: "Are you sure?",
alert_text: "Are you sure you would like to " + action_type + " " + user_name + "?",
alert_success_1: action_type + "!",
alert_success_2: user_name + "has been " + action_type,
alert_success_3: "success",
};
}

sweetAlert({
title: tpl.alert_title,
text: tpl.alert_text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
closeOnConfirm: false
},
() => {
var request_str = `/camps/${camp_id}/members/${user_id}/${action_type}`
$http.get(request_str).then((res) => {
sweetAlert(tpl.alert_success_1, tpl.alert_success_1, "success");
$scope.getMembers(camp_id);
}).catch((err) => {
sweetAlert("Error!", "Something went wrong, please try again later " + err, "error");
})
});
}

app.controller("campEditController", ($scope, $http, $filter) => {
var camp_id = document.querySelector('#meta__camp_id').value;
$scope.status_options = ['open', 'closed'];
$scope.noise_level_options = ['quiet', 'medium', 'noisy', 'very noisy'];
$scope.getMembers = () => {
angular_getMembers($http, $scope, camp_id);
setTimeout(() => {
innerHeightChange();
}, 500)
}
$scope.changeOrderBy = (orderByValue) => {
$scope.orderMembers = orderByValue;
}
if (typeof camp_id !== 'undefined') {
_getMembers();
$scope.current_camp_id=camp_id;
$scope.getMembers();
}
$scope.lang = document.getElementById('meta__lang').value;

$scope.addMember = () => {
var camp_id = document.querySelector('#meta__camp_id').value;
var camp_id = $scope.current_camp_id;
var new_user_email = $scope.camps_members_add_member

var data = {
Expand All @@ -37,55 +92,19 @@ app.controller("campEditController", ($scope, $http, $filter) => {

$http.post(`/camps/${camp_id}/members/add`, data).then(function (res) {
// update table with new data
_getMembers();
$scope.getMembers();
}).catch((err) => {
sweetAlert("Error!", "Something went wrong, please try again later " + err, "error");
});
}
$scope.updateUser = (user_name, user_id, action_type) => {
var camp_id = document.getElementById('meta__camp_id').value;
var lang = document.getElementById('meta__lang').value;
var tpl;
if (lang === "he") {
tpl = {
alert_title: "האם את/ה בטוח?",
alert_text: "האם את/ה בטוח שתרצה לבצע " + action_type + " את משתמש " + user_name + "?",
alert_success_1: action_type + "!",
alert_success_2: "משתמש " + user_name + action_type,
alert_success_3: " בהצלחה",
};
} else {
tpl = {
alert_title: "Are you sure?",
alert_text: "Are you sure you would like to " + action_type + " " + user_name + "?",
alert_success_1: action_type + "!",
alert_success_2: user_name + "has been " + action_type,
alert_success_3: "success",
};
var camp_id = $scope.current_camp_id;
var user_rec = {
camp_id: camp_id,
user_name: user_name,
user_id: user_id,
}

sweetAlert({
title: tpl.alert_title,
text: tpl.alert_text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
closeOnConfirm: false
},
() => {
var request_str = `/camps/${camp_id}/members/${user_id}/${action_type}`
$http.get(request_str).then((res) => {
sweetAlert(tpl.alert_success_1, tpl.alert_success_1, "success");
// TODO - check if table update is needed
setTimeout(() => {
innerHeightChange()
}, 500)
_getMembers();
}).catch((err) => {
sweetAlert("Error!", "Something went wrong, please try again later " + err, "error");
})
});
angular_updateUser($http, $scope, action_type, user_rec);
}

});
55 changes: 33 additions & 22 deletions public/scripts/controllers/camp_manage.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
app.controller("manageCampsController", function($scope, $http, $filter) {
$http.get('/camps').then(function(res) {
app.controller("manageCampsController", function ($scope, $http, $filter) {
$http.get('/camps_all').then(function (res) {
$scope.camps = res.data.camps;
setTimeout(() => {
innerHeightChange()
}, 500)
innerHeightChange()
}, 500)
});

$scope.removeCamp = (camp_id) => {
var agree_remove = confirm('Remove camp\n\n\nThis action will remove camp #' + camp_id + '.\n\n\n---\n Are you sure?');
if (agree_remove) {
// NOT WORKING SOMEHOW
// $http.post(`/camps/${camp_id}/remove`, (res) => {
// console.log(res);
// window.location.reload();
// });
$.post('/camps/' + camp_id + '/remove', (res) => {
window.location.reload();
})
}
var agree_remove = confirm('Remove camp\n\n\nThis action will remove camp #' + camp_id + '.\n\n\n---\n Are you sure?');
if (agree_remove) {
// NOT WORKING SOMEHOW
// $http.post(`/camps/${camp_id}/remove`, (res) => {
// console.log(res);
// window.location.reload();
// });
$.post('/camps/' + camp_id + '/remove', (res) => {
window.location.reload();
})
}
}

$scope.changeOrderBy = function(orderByValue) {
$scope.changeOrderBy = function (orderByValue) {
$scope.orderCamps = orderByValue;
}
});
Expand All @@ -33,14 +33,25 @@ app.controller("membersController", ($scope, $http) => {

$scope.getMembers = (camp_id) => {
if (typeof camp_id !== 'undefined') {
$http.get(`/camps/${camp_id}/members`).then((res) => {
$scope.members = res.data.members;
setTimeout(() => {
innerHeightChange()
}, 500)
});
$scope.current_camp_id = camp_id;
angular_getMembers($http, $scope, camp_id);
setTimeout(() => {
innerHeightChange()
}, 500);
}
}
$scope.updateUser = (user_name, user_id, action_type) => {
var camp_id = $scope.current_camp_id;
var lang = 'he';
var user_rec = {
camp_id: camp_id,
user_name: user_name,
user_id: user_id,
lang: lang,
}
angular_updateUser($http, $scope, action_type, user_rec);
}

$scope.changeOrderBy = (orderByValue) => {
$scope.orderMembers = orderByValue;
}
Expand Down
4 changes: 2 additions & 2 deletions routes/api_camps_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ var Camp = require('../models/camp').Camp;
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');

Expand Down Expand Up @@ -252,6 +250,7 @@ module.exports = (app, passport) => {
new_status = 'pending';
} else if (action === "request_mgr") {
new_status = 'pending_mgr';
mail_delivery.to_mail = user.email;
mail_delivery.subject = 'Spark: you have been requested to join camp';
mail_delivery.template = 'emails/camps/member_request';
if (!user) {
Expand Down Expand Up @@ -590,6 +589,7 @@ module.exports = (app, passport) => {
* notifiying a user wants to join his camp
* @return {boolean} should return true if mail delivered. FIXME: in mail.js
*/
console.log('Trying to send mail to '+recipient+' from '+mailConfig.from+': '+subject+', template '+template);
mail.send(
recipient,
mailConfig.from,
Expand Down
34 changes: 1 addition & 33 deletions views/pages/camps/edit.jade
Original file line number Diff line number Diff line change
Expand Up @@ -252,39 +252,7 @@ block content

.row
.col-xs-12
table.table.table-striped.table-hover
thead
tr
th(ng-click='changeOrderBy("id")') #
th(ng-click='changeOrderBy("name")')=t('camps:members.name')
th(ng-click='changeOrderBy("email")')=t('camps:members.email')
th(ng-click='changeOrderBy("phone")')=t('camps:members.phone')
th(ng-click='changeOrderBy("status")')=t('camps:members.status')
th(ng-click='changeOrderBy("hasTicket")')=t('camps:members.ticket_count')
//- th(ng-click='changeOrderBy("earlyArrival")')=t('camps:members.early_arrival')
th()=t('camps:members.actions')
tbody
tr(ng-repeat="member in members | filter: searchMembers | orderBy: orderMembers")
td {{member.user_id}}
td {{member.name}}
td {{member.email}}
td {{member.cell_phone}}
td {{member.member_status_i18n}}
td {{member.hasTicket}}
//- td {{member.earlyArrival ? 'yes':'no'}}
td
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "reject")', ng-if="member.can_reject")
span(class='glyphicon glyphicon-remove')
span(class='sr-only' aria-hidden='false') Reject user
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "approve")', ng-if="member.can_approve")
span(class='glyphicon glyphicon-ok')
span(class='sr-only' aria-hidden='false') Approve user
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "manager")', ng-if="member.can_approve_mgr")
span(class='glyphicon glyphicon-king')
span(class='sr-only' aria-hidden='false') Approve user as manager
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "remove")', ng-if="member.can_remove")
span(class='glyphicon glyphicon-remove')
span(class='sr-only' aria-hidden='false') Remove user
include partials/members_table
//- Card 4
.card.card-forth.card-hide
h4=t('camps:edit.upload_header')
Expand Down
16 changes: 1 addition & 15 deletions views/pages/camps/index_admin.jade
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,7 @@ block content
//- Card 3
.card.card-third.card__padding--even.card-hide.col-xs-12.table-responsive
h4=t('camps:admin_index.docs_table')
table.table.table-striped.table-hover
thead
tr.headers
//- TODO - fix header names
th #
th.camp_name_en=t('camps:stats.name_en')
th.contact_person=t('camps:stats.contact_person')
th.status=t('camps:stats.status')
th.hidden-xs=t('camps:stats.last_update')
th.hidden-xs=t('camps:stats.created_at')
th.published=t('camps:stats.published')
th.facebook_page_url=t('camps:stats.facebook_page_url')
th.admin-edit=t('camps:stats.edit')
th.admin-remove=t('camps:stats.remove')
tbody

//- Card 4
.choose_name.card.card-forth.card__padding--even.card-hide.col-xs-12
h2=t('camps:new.header_title')
Expand Down
57 changes: 32 additions & 25 deletions views/pages/camps/partials/members_table.jade
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
table.table.table-striped.table-hover
thead
tr
th(ng-click='changeOrderBy("id")') #
th(ng-click='changeOrderBy("name")')=t('camps:members.name')
if userIs('admin')
th(ng-click='changeOrderBy("email")')=t('camps:members.email')
th(ng-click='changeOrderBy("phone")')=t('camps:members.phone')
if userIs('admin')
th(ng-click='changeOrderBy("status")')=t('camps:members.status')
if userIs('admin')
th(ng-click='changeOrderBy("hasTicket")')=t('camps:members.ticket_count')
th(ng-click='changeOrderBy("earlyArrival")')=t('camps:members.early_arrival')
tbody
tr(ng-repeat="member in members | filter: searchMembers | orderBy: orderMembers")
td {{member.user.user_id}}
td {{[member.user.first_name, member.user.last_name].join(' ')}}
if userIs('admin')
td {{member.user.email}}
td {{member.user.cell_phone}}
if userIs('admin')
td
span.label(ng-class="member.status === 'approved' ? 'label-success':'label-default'") {{member.status}}
if userIs('admin')
td {{member.user.hasTicket}}
td {{member.user.earlyArrival ? 'yes':'no'}}
thead
tr
th(ng-click='changeOrderBy("id")') #
th(ng-click='changeOrderBy("name")')=t('camps:members.name')
th(ng-click='changeOrderBy("email")')=t('camps:members.email')
th(ng-click='changeOrderBy("phone")')=t('camps:members.phone')
th(ng-click='changeOrderBy("status")')=t('camps:members.status')
th(ng-click='changeOrderBy("hasTicket")')=t('camps:members.ticket_count')
//- th(ng-click='changeOrderBy("earlyArrival")')=t('camps:members.early_arrival')
th()=t('camps:members.actions')
tbody
tr(ng-repeat="member in members | filter: searchMembers | orderBy: orderMembers")
td {{member.user_id}}
td {{member.name}}
td {{member.email}}
td {{member.cell_phone}}
td {{member.member_status_i18n}}
td {{member.hasTicket}}
//- td {{member.earlyArrival ? 'yes':'no'}}
td
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "reject")', ng-if="member.can_reject")
span(class='glyphicon glyphicon-remove')
span(class='sr-only' aria-hidden='false') Reject user
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "approve")', ng-if="member.can_approve")
span(class='glyphicon glyphicon-ok')
span(class='sr-only' aria-hidden='false') Approve user
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "manager")', ng-if="member.can_approve_mgr")
span(class='glyphicon glyphicon-king')
span(class='sr-only' aria-hidden='false') Approve user as manager
a.cursor-p(ng-click='updateUser(member.name, member.user_id, "remove")', ng-if="member.can_remove")
span(class='glyphicon glyphicon-remove')
span(class='sr-only' aria-hidden='false') Remove user

0 comments on commit 5091a9a

Please sign in to comment.