Skip to content

Commit

Permalink
Adds different texts for OBSERVER and PARTICIPANT
Browse files Browse the repository at this point in the history
Adds dummy check for confirmed email, needs further work to check if emails are confirmed
  • Loading branch information
mheimbuc committed Apr 24, 2016
1 parent 86d3867 commit 36be39e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
24 changes: 19 additions & 5 deletions routes/dynamic.js
@@ -1,9 +1,11 @@
'use strict'; const express = require('express');
'use strict';
const express = require('express');
const router = express.Router();
const co = require('co');
const multer = require('multer');
const upload = multer({ inMemory: true });
const passport = requireLocal('controller/auth');
const _ = require('lodash');

const registration = requireLocal('controller/page-controller/registration');

Expand All @@ -21,14 +23,26 @@ const isParticipant = generalAuth('/selection', 'ein Teilnehmer', (me) => !!me.p
const isSponsor = generalAuth('/selection', 'ein Sponsor', (me) => !!me.sponsor);
const hasTeam = generalAuth('/team-invite', 'Teil eines Teams', (me) => !!me.participant.teamId);

const funnelTemplate = (template) => (req, res) =>
const funnelTemplate = (template) => (req, res) => {

let status = 'OBSERVER';
if (req.user.me.roles === []) {
status = 'OBSERVER';
} else if (_.includes(req.user.me.roles, 'PARTICIPANT')) {
status = 'PARTICIPANT';
} else {
logger.error('No valid user role found for', req.user);
}

res.render(`dynamic/register/${template}`,
{
error: req.flash('error'),
layout: 'funnel',
lang: req.lang
}
);
lang: req.lang,
emailConfirmed: false,
status: status
});
};

//GET
router.get('/', funnelTemplate('register'));
Expand Down
8 changes: 8 additions & 0 deletions services/helpers.js
Expand Up @@ -4,6 +4,14 @@ let i18n = requireLocal('services/i18n');

exports.concat = (first, second) => first + second;

exports.ifCond = function (v1, v2, options) {
if (v1 === v2) {
return options.fn(this);
}

return options.inverse(this);
};

exports.__ = (text, options) => {

if (!options.data.root.lang) {
Expand Down
6 changes: 5 additions & 1 deletion services/translations.js
Expand Up @@ -13,10 +13,14 @@ module.exports = {
de: 'Du hast den ersten Schritt geschafft! Wir haben Dir eine E-Mail mit einem Link geschickt, mit dem Du Deine E-Mail Adresse bestätigen kannst. Dieser Schritt ist notwendig, damit wir überprüfen können, ob Du wirklich der Inhaber der E-Mail Adresse bist.',
en: 'You have completed the first step! We have sent you an email with a link to verify your email address. This important step allows us to confirm that the email address is actually yours.'
},
DESCRIPTION_2: {
DESCRIPTION_OBSERVER: {
de: 'Dein aktueller Status ist: <strong>Zuschauer</strong>. Damit kannst Du nicht nur alle Posts und Updates von teilnehmenden Teams sehen, sondern auch mit den Teams über Kommentare und Likes interagieren.',
en: 'Your current status is: <Strong>Observer</Strong>. With this you can not only see all of the posts and updates from participating teams, but also interact with them by liking and commenting on their posts.'
},
DESCRIPTION_PARTICIPANT: {
de: 'Dein aktueller Status ist: <strong>Teilnehmer</strong>. DUMMY',
en: 'Your current status is: <Strong>PARTICIPANT</Strong>. DUMMY'
},
DESCRIPTION_3: {
de: 'Das ist Dir noch nicht genug? Wir bieten auf unserer Plattform auch noch weitere Accounts an:',
en: 'Thats not enough? On our platform we also offer other accounts:'
Expand Down
44 changes: 27 additions & 17 deletions views/dynamic/register/selection.handlebars
Expand Up @@ -13,21 +13,36 @@
</div>
<div class="row">
<div class="col-xs-12">
<p>{{__ 'DESCRIPTION_1'}}</p>
<p>{{{__ 'DESCRIPTION_2'}}}</p>
<p>{{__ 'DESCRIPTION_3'}}</p>
{{#unless emailConfirmed }}
<p>{{__ 'DESCRIPTION_1'}}</p>
{{/unless}}

{{!-- Searches for DESCRIPTION_$USERSTATUS --}}
<p>{{{__ (concat 'DESCRIPTION_' status)}}}</p>

{{#ifCond status 'OBSERVER'}}
<p>{{__ 'DESCRIPTION_3'}}</p>
{{/ifCond}}
</div>
</div>
<div class="row">
<div class="col-xs-12">
<a href="/participant" class="no-underline">
<div class="bo-reg-well-selection bo-reg-well-selection-hover">
<h4><strong>{{__ 'PARTICIPANT_H'}}</strong></h4>
<p>{{__ 'PARTICIPANT'}}</p>
</div>
</a>

{{#ifCond status 'OBSERVER'}}
<div class="row">
<div class="col-xs-12">
<a href="/participant" class="no-underline">
<div class="bo-reg-well-selection bo-reg-well-selection-hover">
<h4><strong>{{__ 'PARTICIPANT_H'}}</strong></h4>
<p>{{__ 'PARTICIPANT'}}</p>
</div>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h5><a href="/spectator-success">{{__ 'OBSERVER'}}</a></h5>
</div>
</div>
{{/ifCond}}
<!--
<div class="row">
<div class="col-xs-12">
Expand All @@ -40,10 +55,5 @@
</div>
</div>
-->
<div class="row">
<div class="col-xs-12">
<h5><a href="/spectator-success">{{__ 'OBSERVER'}}</a></h5>
</div>
</div>
</div>
</div>

0 comments on commit 36be39e

Please sign in to comment.