-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
210284d
commit 12b7266
Showing
17 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
var mongoose = require('mongoose'); | ||
var mongoose_csv = require('mongoose-csv'); | ||
|
||
var contactSchema = mongoose.Schema({ | ||
name : String, | ||
email : String, | ||
query : String, | ||
}); | ||
|
||
contactSchema.plugin(mongoose_csv); | ||
// create the model for users and expose it to our app | ||
module.exports = mongoose.model('Contact', contactSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ var PaymentDB = require('../models/payment'); | |
var PaymentMUN = require('../models/paymentMUN'); | ||
var PaymentSIF = require('../models/paymentSIF'); | ||
var EventURL = require('../config/eventURL'); | ||
var mongoose_csv = require('mongoose-csv'); | ||
|
||
|
||
|
||
router.get('/sif/startup', Verify.verifyOrdinaryUser ,function(req, res) { | ||
|
@@ -280,5 +282,89 @@ router.get('/user/registered', Verify.verifyOrdinaryUser ,function(req, res) { | |
}); | ||
}); | ||
|
||
router.get('/user/registered/csv', Verify.verifyOrdinaryUser ,function(req, res) { | ||
var poc = authUser.poc; | ||
if(req.decoded.sub === "" || (poc.indexOf(req.decoded.sub) === -1)){ | ||
res.end("You are not authorized. Login and try"); | ||
return; | ||
} | ||
res.writeHead(200, { | ||
'Content-Type': 'text/csv', | ||
'Content-Disposition': 'attachment; filename=registereduser.csv' | ||
}); | ||
// pipe file using mongoose-csv | ||
User.find().csv(res); | ||
}); | ||
|
||
|
||
router.get('/csv/*', Verify.verifyOrdinaryUser ,function(req, res) { | ||
var poc = authUser.poc; | ||
var allowedUser = ['[email protected]']; | ||
var paymentUser = poc.slice(0); | ||
|
||
if(EventURL[req.query.event] === undefined){ | ||
res.end('Please Check the link once again there may some typo in event name'); | ||
return; | ||
} | ||
|
||
switch(req.params['0']) { | ||
case "astronomy": | ||
eventx = Astronomy; | ||
allowedUser = authUser.astronomy; | ||
paymentUser = paymentUser.concat(allowedUser[0]); | ||
break; | ||
case "coding": | ||
eventx = Cybros; | ||
allowedUser = authUser.cybros; | ||
paymentUser = paymentUser.concat(allowedUser[0]); | ||
break; | ||
case "literature": | ||
eventx = Literary; | ||
break; | ||
case "robotics": | ||
eventx = Robotics; | ||
allowedUser = authUser.robotics; | ||
paymentUser = paymentUser.concat(allowedUser[0]); | ||
break; | ||
case "management": | ||
eventx = Ecell; | ||
allowedUser = authUser.ecell; | ||
paymentUser = paymentUser.concat(allowedUser[0]); | ||
break; | ||
case "quizzing": | ||
eventx = Quiz; | ||
allowedUser = authUser.quiz; | ||
paymentUser = paymentUser.concat(allowedUser[0]); | ||
break; | ||
case "workshop": | ||
eventx = Workshop; | ||
allowedUser = authUser.admin; | ||
break; | ||
default: | ||
res.end('Please Check the link once again there may some typo in club name'); | ||
return; | ||
break; | ||
} | ||
if(req.decoded.sub === "" || (poc.indexOf(req.decoded.sub) === -1 && allowedUser.indexOf(req.decoded.sub) === -1)){ | ||
res.end("You are not authorized. Login and try"); | ||
return; | ||
} | ||
|
||
User.findOne({'email' : req.decoded.sub }, function(err, user) { | ||
// if there are any errors, return the error | ||
if (err){ | ||
return done(err); | ||
} | ||
// check to see if theres already a user with that email | ||
if (user){ | ||
res.writeHead(200, { | ||
'Content-Type': 'text/csv', | ||
'Content-Disposition': 'attachment; filename=' + req.query.event + '.csv' | ||
}); | ||
eventx.find({'eventName' : req.query.event}).csv(res); | ||
} | ||
}); | ||
}); | ||
|
||
|
||
module.exports = router; |