Skip to content
Draft
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
8 changes: 8 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ app.get('/program_add', [authJwt.verifyToken, authJwt.isAdmin], program.addProgr
app.get('/program_edit/:id', [authJwt.verifyToken, authJwt.isAdmin], program.editProgramPage);
app.post('/program_add', [authJwt.verifyToken, authJwt.isAdmin], program.addProgram);
app.post('/program_edit/:id', [authJwt.verifyToken, authJwt.isAdmin], program.editProgram);
app.get('/view_program/:id', [authJwt.verifyToken], program.viewProgramPage);

app.get('/applications', [authJwt.verifyToken, authJwt.isAdmin], application.getApplications);
app.get('/application/accept/:id', [authJwt.verifyToken, authJwt.isAdmin], application.acceptApplication);
app.get('/application/deny/:id', [authJwt.verifyToken, authJwt.isAdmin], application.denyApplication);
app.get('/application_apply/:id/:program_id', [authJwt.verifyToken, authJwt.isStudentOrAdmin], application.addApplication);



function listenCallback() {
console.log(`Server Running on http://${hostname}:${port}`);
Expand Down
4 changes: 2 additions & 2 deletions database/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ module.exports = {
},

getStudentsList: async function() {
return await Student.find({})
return await Student.find({});
},

getStudentById: async function(studentId) {
return await Student.findOne({
_id: studentId
})
});
},

editStudentById: async function(studentId, newStudentObj) {
Expand Down
2 changes: 1 addition & 1 deletion database/program_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
return await Program.find({title : currentTitle}).countDocuments() + 1
},
getProgramsList: async function() {
return await Program.find({})
return await Program.find({});
},
getProgramById: async function(programId) {
return await Program.findOne({
Expand Down
24 changes: 4 additions & 20 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const jwt = require('jsonwebtoken');
const userDb = require("../auth/models");
const User = userDb.user;
const config = require('../auth/config/auth.config');
const db = require("../database/db")
const jwt = require('jsonwebtoken')
const userDb = require("../auth/models")
const User = userDb.user
const config = require('../auth/config/auth.config')
const programFile = require("./program")
const registrationFile = require("./registration")
const program_db = require("../database/program_db")
Expand Down Expand Up @@ -203,19 +203,3 @@ module.exports = {
return programTitles
},
};

async function getProgramTitles(activeStudents, activeRegistrations) {
let programTitles = []
for (let i = 0; i < activeStudents.length; i++) {
let registrations = await registration_db.getRegistrationsByParams({
status: 'active',
student: activeStudents[i].id
})

for (let j = 0; j < registrations.length; j++) {
let programObj = await program_db.getProgramById(registrations[j].program)
programTitles.push(programObj.title)
}
}
return programTitles
}
1 change: 1 addition & 0 deletions routes/program_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = {
}
let token = request.headers['cookie']

let token = request.headers['cookie']
if (!token) {
let renderData = {
message: ""
Expand Down
2 changes: 1 addition & 1 deletion views/edit-student.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="form-group col-md-6">
<label for="email">Email</label>
<input type="email" class="form-control" name="email" id="email" maxlength = "50" value="<%=student.email%>" required <% if (view) { %> readonly <% } %>>
<input type="email" class="form-control" name="email" value="<%=student.email%>" required <% if (view) { %> readonly <% } %>>
</div>
<div class="form-group col-md-6">
<label for="guardianEmail">Guardian Email</label>
Expand Down
1 change: 1 addition & 0 deletions views/program_index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<th>End Date</th>
<th>Minimum Grade Level</th>
<th>Maximum Grade Level</th>
<th>Action</th>
<th>Students Involved</th>
</tr>
</thead>
Expand Down