Skip to content

Commit

Permalink
published camps & view/edit improve
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelben committed Feb 6, 2017
1 parent d8520dc commit 3f86cbd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
8 changes: 5 additions & 3 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const opsworks = require('../opsworks.js');

module.exports = {
database: opsworks.db,

server: opsworks.server,

mail: opsworks.mail,
Expand All @@ -14,12 +14,14 @@ module.exports = {
payment: opsworks.payment,

npo: opsworks.npo,

facebook: opsworks.facebook,

recaptcha: {
sitekey: opsworks.recaptcha.sitekey,
secretkey: opsworks.recaptcha.secretkey,
ignore: opsworks.recaptcha.ignore
}
},

published_camps_origin: 'http://54.194.247.12'
};
6 changes: 4 additions & 2 deletions public/scripts/camps.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ $('.camp_index .join_camp select[name="camp_name_en"]').focus(function() {
* Component: View camp details
*/
function _fetchCampContactPersonDetails() {
var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id');
$.get('/camps_contact_person/' + contact_person_id, function(res) {
$('span.contact_person_name').text(res.user.name);
$('span.contact_person_phone').text(res.user.phone);
$('span.contact_person_email').text(res.user.email);
});
}
if ($('.camps').hasClass('camp_details')) {
_fetchCampContactPersonDetails();
var contact_person_id = $('.contact-person').attr('data-camp-contact-person-id');
if (contact_person_id !== "null") {
_fetchCampContactPersonDetails();
}
}
/**
* Component: Editing camp
Expand Down
7 changes: 4 additions & 3 deletions routes/api_camps_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ module.exports = function(app, passport) {
*/
app.get('/camps_published', (req, res, next) => {
// Allow this address to http-request to this endpoint.
var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = 'http://10.0.0.12:8080';
// TODO: add env check - if (app.get('env') === 'development')
var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = config.get('published_camps_origin');

res.header('Access-Control-Allow-Origin', API_PUBLISHED_CAMPS_ALLOW_ORIGIN);
res.header('Access-Control-Allow-Methods', 'GET');
res.header('Access-Control-Allow-Headers', 'Content-Type');
Camp.fetchAll().then((camp) => {
var published_camps = [];
for (var i = 0; i < camp.models.length; i++) {
if (camp.models[i].attributes.enabled == '1') {
if (camp.models[i].attributes.enabled == '1' && camp.models[i].attributes.status != 'inactive') {
var fetched_camp = {
id: camp.models[i].attributes.id,
name_en: camp.models[i].attributes.camp_name_en,
Expand Down Expand Up @@ -230,7 +231,7 @@ module.exports = function(app, passport) {
*/
app.get('/camps_contact_person/:id', (req, res, next) => {
// Allow this address to http-request to this endpoint.
var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = 'http://10.0.0.12:8080';
var API_PUBLISHED_CAMPS_ALLOW_ORIGIN = config.get('published_camps_origin');

res.header('Access-Control-Allow-Origin', API_PUBLISHED_CAMPS_ALLOW_ORIGIN);
res.header('Access-Control-Allow-Methods', 'GET');
Expand Down
6 changes: 4 additions & 2 deletions views/pages/camps/camp.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ block content
li.list-group-item
span Status
if camp.status == 'open'
span.badge.bg__teal Open
span.badge.bg__green Open
if camp.status == 'closed'
span.badge.bg__red Closed
else
span.badge.bg__red Close
span.badge.bg__teal Inactive
li.list-group-item
span Accept Families?
span.badge #{camp.accept_families}
Expand Down
6 changes: 4 additions & 2 deletions views/pages/camps/edit.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ block content
section
meta.hidden.meta(id='meta__camp_name_en', value='#{camp.camp_name_en}')
.heading.card.card__shad.row
.col-md-12
.col-xs-12.col-sm-8
h2 #{t('camps:edit.title')}: #{camp.camp_name_en}
span.label.label-info #{t('camps:edit.camp')} # #{camp.id}
h6 #{t('camps:edit.since')}: #{camp.created_at}
.col-xs-12.col-sm-4
a.Btn.Btn__sm(href='/#{language}/camps/#{camp.id}') View camp
.controls.row
.col-xs-12
//- Card switcher
Expand All @@ -31,7 +33,7 @@ block content
label(for='edit_camp_desc_en')=t('camps:edit.desc_en')
textarea.form-control(id='edit_camp_desc_en', name='camp_desc_en') #{camp.camp_desc_en}
.col-xs-12
label(for='edit_camp_desc_he')=t('camps:edit.name_he')
label(for='edit_camp_desc_he')=t('camps:edit.desc_he')
textarea.form-control(id='edit_camp_desc_he', name='camp_desc_he') #{camp.camp_desc_he}
h4=t('camps:edit.website_publication')
.camp-publication.panel
Expand Down

0 comments on commit 3f86cbd

Please sign in to comment.