Skip to content

Instantly share code, notes, and snippets.

@crtr0
Created December 3, 2012 20:52
Show Gist options
  • Save crtr0/4197923 to your computer and use it in GitHub Desktop.
Save crtr0/4197923 to your computer and use it in GitHub Desktop.
Loads an event from CouchDB based on the "shortname" parameter in the URL
var event = function(req, res){
events.findBy('shortname', req.params.shortname, function(err, event) {
if (event) {
// remove sensitive data
event.voteoptions.forEach(function(vo){
delete vo.numbers;
});
res.render('event', {
name: event.name, shortname: event.shortname, state: event.state,
phonenumber: utils.formatPhone(event.phonenumber),
voteoptions: JSON.stringify(event.voteoptions)
});
}
else {
res.statusCode = 404;
res.send('We could not locate your event');
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment