Example #1
0
  talkDb.view('user', 'byid', options, function(err, data) {

    // Swap out the value for an easier to read name
    for (i = 0; i < data.rows.length; i++) {
      for (j = 0; j < talkTypes.length; j++) {
        if (talkTypes[j].value == data.rows[i].doc.talk.type) {
          data.rows[i].doc.talk.typeText = talkTypes[j].name;
        }
      }

      if (data.rows[i].doc.vote) {
        if (req.cfpSettings.admins.indexOf(userId) >= 0) {
          data.rows[i].doc.voted = data.rows[i].doc.vote;
        }
        else if (req.cfpSettings.voters.indexOf(userId) >= 0) {
          data.rows[i].doc.voted = (data.rows[i].doc.vote.indexOf(userId) >= 0) ? ['1'] : false;
        }
      }
    }

    if (!utils.viewAllSubmissions(userId, req.cfpSettings)) {
      data.rows = utils.arrayShuffle(data.rows);
    }

    res.render('talk/index', { title: title, submissions: data.rows, talkTypes: talkTypes });

  });
Example #2
0
router.get('/', function(req, res) {

  // The page title
  var title = 'Review talks';

  // make the userId easier to handle
  var userId = req.user.id;

  // View options
  var options = {
    include_docs: true
  };

  if (utils.viewAllSubmissions(userId, req.cfpSettings)) {
    options.key = userId;
    title += ' you have submitted';
  }

  // Grab the talks
  talkDb.view('user', 'byid', options, function(err, data) {

    // Swap out the value for an easier to read name
    for (i = 0; i < data.rows.length; i++) {
      for (j = 0; j < talkTypes.length; j++) {
        if (talkTypes[j].value == data.rows[i].doc.talk.type) {
          data.rows[i].doc.talk.typeText = talkTypes[j].name;
        }
      }

      if (data.rows[i].doc.vote) {
        if (req.cfpSettings.admins.indexOf(userId) >= 0) {
          data.rows[i].doc.voted = data.rows[i].doc.vote;
        }
        else if (req.cfpSettings.voters.indexOf(userId) >= 0) {
          data.rows[i].doc.voted = (data.rows[i].doc.vote.indexOf(userId) >= 0) ? ['1'] : false;
        }
      }
    }

    if (!utils.viewAllSubmissions(userId, req.cfpSettings)) {
      data.rows = utils.arrayShuffle(data.rows);
    }

    res.render('talk/index', { title: title, submissions: data.rows, talkTypes: talkTypes });

  });
});