<commit_before>/* jshint node: true */
'use strict';

var Q = require('q');
var router = require('express').Router();
var participants = require('../../service/participants');
var accesscontrol = require('../../acl/accesscontrol');
var editUrlGenerator = require('../../domain/editUrlGenerator');
var participant = require('../domain/participant');

var canViewParticipantDetails = function(role) {
  return accesscontrol.hasPermissionTo(role, 'view participant details');
};

var useDefaultAuthentication = function(req, res, next){
  if(req.user) {
    return next();
  } else {
    var user = {username: 'guest', role: 'guest'};
    req.logIn(user, next);
  }
};

var addEditUrlTo = function (participants) {
  participants.map(function(participant) {
    participant.editUrl = editUrlGenerator.generateEncryptedUrl(participant.id.toString());
    return participant;
  });
};

router.get('/', useDefaultAuthentication, function (req, res) {
  if(canViewParticipantDetails(req.user.role)) {
    participants.getConfirmed().then(function (result) {
      var allParticipants = result;
      participants.getRegistered().then(function (result) {
        allParticipants = allParticipants.concat(result);
        addEditUrlTo(allParticipants);
        Q.all(allParticipants.map(participant.addTshirtDetailsTo)).then( function () {
          return res.render('participants/list', {participants: allParticipants, isAdmin: true});
        });
      });
    });
  } else {
    participants.getConfirmed().then(function (result) {
      return res.render('participants/list', {participants: result, isAdmin: false});
    });
  }
});

module.exports = router;
<commit_msg>Fixed the path<commit_after>/* jshint node: true */
'use strict';

var Q = require('q');
var router = require('express').Router();
var participants = require('../../service/participants');
var accesscontrol = require('../../acl/accesscontrol');
var editUrlGenerator = require('../../domain/editUrlGenerator');
var participant = require('../../domain/participant');

var canViewParticipantDetails = function(role) {
  return accesscontrol.hasPermissionTo(role, 'view participant details');
};

var useDefaultAuthentication = function(req, res, next){
  if(req.user) {
    return next();
  } else {
    var user = {username: 'guest', role: 'guest'};
    req.logIn(user, next);
  }
};

var addEditUrlTo = function (participants) {
  participants.map(function(participant) {
    participant.editUrl = editUrlGenerator.generateEncryptedUrl(participant.id.toString());
    return participant;
  });
};

router.get('/', useDefaultAuthentication, function (req, res) {
  if(canViewParticipantDetails(req.user.role)) {
    participants.getConfirmed().then(function (result) {
      var allParticipants = result;
      participants.getRegistered().then(function (result) {
        allParticipants = allParticipants.concat(result);
        addEditUrlTo(allParticipants);
        Q.all(allParticipants.map(participant.addTshirtDetailsTo)).then( function () {
          return res.render('participants/list', {participants: allParticipants, isAdmin: true});
        });
      });
    });
  } else {
    participants.getConfirmed().then(function (result) {
      return res.render('participants/list', {participants: result, isAdmin: false});
    });
  }
});

module.exports = router;

{'fraction_non_alphanumeric': 0.1554823247453565, 'fraction_numerical': 0.0, 'mean_word_length': 4.233542319749216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997433', 'n_tokens_mistral': 983, 'n_tokens_neox': 944, 'n_words': 188}