Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated contenders json file format #121

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/app/components/Admin/SignupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ class SignupForm extends Component {
var reader = new FileReader();
reader.onload = function (file) {
var data = JSON.parse(file.target.result);
data=data["_default"];
for (var key in data) {
// console.log(key + " -> " + data[key]);
var body = "usn=" + key;
var body = "usn=" + data[key].usn;
body += "&name=" + data[key].name;
body += "&email=" + data[key].email;
body += "&rating=" + data[key].rating;
Expand Down
7 changes: 7 additions & 0 deletions server/routes/api/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ module.exports = (app) => {
var role = req.body.role;

if (!firstName) {
console.log("Error: First name cannot be blank");
return res.status(400).send({
success: false,
message: 'Error: First name cannot be blank.'
});
}
if (!usn) {
console.log("Error: usn cannot be blank");
return res.status(400).send({
success: false,
message: 'Error: usn cannot be blank.'
Expand All @@ -46,6 +48,7 @@ module.exports = (app) => {
message: 'Error: Server find error'
});
} else if (previousUsers.length > 0) {
console.log(`Error: ${usn} already exists`);
return res.status(409).send({
success: false,
message: 'Error: Account already exists.'
Expand Down Expand Up @@ -132,20 +135,23 @@ module.exports = (app) => {

app.post('/api/admin/createGroup', requireRole('admin'), function (req, res) {
if (!req.body.name) {
console.log("Error: Name not recieved");
return res.status(400).send({
success: false,
message: "Error: name not recieved"
});
}

if (!req.body.usn) {
console.log("Error: usn not recieved");
return res.status(400).send({
success: false,
message: "Error: usn not recieved"
});
}

if (!req.body.graduating) {
console.log("Error: graduating year not recieved");
return res.status(400).send({
success: false,
message: "Error: graduating year not recieved"
Expand All @@ -164,6 +170,7 @@ module.exports = (app) => {
});
}
if (!user) {
console.log(`Error: ${req.body.usn} not found`)
return res.status(404).send({
success: false,
message: 'Error: User not found'
Expand Down
2 changes: 1 addition & 1 deletion server/routes/api/contests.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ module.exports = (app) => {
var timesPlayed = req.body.timesPlayed;
var lastFive = req.body.lastFive;
var best = req.body.best;

if (!usn) {
return res.status(400).send({
success: false,
Expand Down Expand Up @@ -254,6 +253,7 @@ module.exports = (app) => {
});
}
else {
console.log(`Error: ${usn} not found`)
return res.status(400).send({
success: false,
message: 'Error: User not found.'
Expand Down