-
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.
relates #12
- Loading branch information
Showing
39 changed files
with
828 additions
and
25 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
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,9 @@ | ||
const router = require('express').Router(); | ||
|
||
const user = require('./routes/user'); | ||
const admin = require('./routes/admin'); | ||
const { getSpecificCohort } = require('./routes/user/cohort'); | ||
|
||
router.use(user); | ||
router.get('/cohorts/:cohortid', getSpecificCohort); | ||
router.use(admin); | ||
|
||
module.exports = router; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { postCohort } = require('../../../../database/queries'); | ||
const cohortSchema = require('../../../../validation/cohortSchema '); | ||
|
||
const addCohort = async (req, res, next) => { | ||
try { | ||
await cohortSchema.validate(req.body, { abortEarly: false }); | ||
const { rows } = await postCohort(req.body); | ||
const { name } = rows[0]; | ||
res.status(201).json({ | ||
StatusCode: 201, | ||
data: { | ||
cohort: rows[0], | ||
message: `Cohort with Key (name)=(${name}) added successfully`, | ||
}, | ||
}); | ||
} catch (err) { | ||
if (err.errors) { | ||
res.status(400).json({ statusCode: 400, data: { message: err.errors } }); | ||
} else if (err.detail) { | ||
res.status(409).json({ | ||
statusCode: 409, | ||
data: { | ||
message: err.detail, | ||
}, | ||
}); | ||
} else { | ||
next(err); | ||
} | ||
} | ||
}; | ||
|
||
module.exports = addCohort; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { putSpecificCohort } = require('../../../../database/queries'); | ||
const { editCohortSchema } = require('../../../../validation/index'); | ||
|
||
const editCohort = async (req, res, next) => { | ||
try { | ||
const { cohortId } = req.params; | ||
const data = await editCohortSchema.validate( | ||
{ ...req.body, cohortId }, | ||
{ | ||
abortEarly: false, | ||
}, | ||
); | ||
const result = await putSpecificCohort(data); | ||
if (result.rowCount === 1) { | ||
res.json({ statusCode: 200, message: 'Changed Succefully' }); | ||
} else { | ||
res.status(404).json({ | ||
statusCode: 404, | ||
message: "Sorry There's no cohort for this id to change", | ||
}); | ||
} | ||
} catch (err) { | ||
if (err.errors) { | ||
res.status(400).json({ statusCode: 400, message: err.errors }); | ||
} else { | ||
next(err); | ||
} | ||
} | ||
}; | ||
|
||
module.exports = editCohort; |
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,3 +1,9 @@ | ||
const addCohort = require('./addCohort'); | ||
const deleteCohort = require('./deleteCohort'); | ||
const editCohort = require('./editCohort'); | ||
|
||
module.exports = { deleteCohort }; | ||
module.exports = { | ||
addCohort, | ||
deleteCohort, | ||
editCohort, | ||
}; |
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
30 changes: 30 additions & 0 deletions
30
server/controllers/routes/admin/project/deleteProjectData.js
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { deleteProject } = require('../../../../database/queries'); | ||
|
||
const deleteProjectData = async (req, res, next) => { | ||
try { | ||
const { projectId } = req.params; | ||
if (projectId > 0) { | ||
const check = await deleteProject(projectId); | ||
if (check.rowCount !== 0) { | ||
res.json({ | ||
StatusCode: 200, | ||
data: { message: 'Project deleted successfully' }, | ||
}); | ||
} else { | ||
res.status(404).json({ | ||
StatusCode: 404, | ||
data: { message: 'Project does not exist' }, | ||
}); | ||
} | ||
} else { | ||
res.status(404).json({ | ||
StatusCode: 404, | ||
data: { message: 'You enterd wrong project ID' }, | ||
}); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = deleteProjectData; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { editProjectQuery } = require('../../../../database/queries'); | ||
const { projectSchema } = require('../../../../validation'); | ||
|
||
const editProject = async (req, res, next) => { | ||
try { | ||
await projectSchema.validate( | ||
{ ...req.body, projectId: req.params.projectId }, | ||
{ abortEarly: false }, | ||
); | ||
await editProjectQuery(req.body); | ||
res.json({ | ||
StatusCode: 200, | ||
data: { message: 'project updated successfully' }, | ||
}); | ||
} catch (err) { | ||
if (err.errors) { | ||
res.json({ | ||
StatusCode: 400, | ||
data: { message: err.errors }, | ||
}); | ||
} else { | ||
next(err); | ||
} | ||
} | ||
}; | ||
|
||
module.exports = editProject; |
28 changes: 28 additions & 0 deletions
28
server/controllers/routes/admin/project/getCohortProjects.js
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { getCohortProjectsQuery } = require('../../../../database/queries'); | ||
|
||
const getCohortProjects = async (req, res, next) => { | ||
try { | ||
const { cohortId } = req.params; | ||
const projectType = req.query.type; | ||
if ( | ||
(cohortId > 0 && projectType.toLowerCase() === 'internal') || | ||
projectType.toLowerCase() === 'remotely' | ||
) { | ||
const { rows } = await getCohortProjectsQuery(cohortId, projectType); | ||
if (rows.length > 0) { | ||
res.json({ statusCode: 200, data: rows }); | ||
} else { | ||
res.json({ statusCode: 200, message: 'No Data' }); | ||
} | ||
} else { | ||
res.status(404).json({ | ||
statusCode: 404, | ||
message: 'Please check cohort ID you entered or project type', | ||
}); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = getCohortProjects; |
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,5 +1,11 @@ | ||
const addProject = require('./addProject'); | ||
const getCohortProjects = require('./getCohortProjects'); | ||
const editProject = require('./editProject'); | ||
const deleteProjectData = require('./deleteProjectData'); | ||
|
||
module.exports = { | ||
addProject, | ||
getCohortProjects, | ||
editProject, | ||
deleteProjectData, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { deleteStudentQuery } = require('../../../../database/queries'); | ||
|
||
const deleteStudent = async (req, res, next) => { | ||
try { | ||
const { studentId } = req.params; | ||
if (studentId > 0) { | ||
const check = await deleteStudentQuery(studentId); | ||
if (check.rowCount !== 0) { | ||
res.json({ | ||
StatusCode: 200, | ||
data: { message: 'Student deleted successfully' }, | ||
}); | ||
} else { | ||
res.status(404).json({ | ||
StatusCode: 404, | ||
data: { message: 'Student does not exist' }, | ||
}); | ||
} | ||
} else { | ||
res.status(404).json({ | ||
StatusCode: 404, | ||
data: { message: 'You enterd wrong student ID' }, | ||
}); | ||
} | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
|
||
module.exports = deleteStudent; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const deleteStudent = require('./deleteStudent'); | ||
|
||
module.exports = { | ||
deleteStudent, | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
const { getCohortsData } = require('./getCohortsData'); | ||
const getCohortsData = require('./getCohortsData'); | ||
const getSpecificCohort = require('./getSpecificCohort'); | ||
|
||
module.exports = { getCohortsData, getSpecificCohort }; | ||
module.exports = { | ||
getCohortsData, | ||
getSpecificCohort, | ||
}; |
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,8 +1,9 @@ | ||
const router = require('express').Router(); | ||
const { getProjectsData } = require('./project'); | ||
const { getCohortsData } = require('./cohort'); | ||
const { getCohortsData, getSpecificCohort } = require('./cohort'); | ||
|
||
router.get('/projects?type=', getProjectsData); | ||
router.get('/cohorts', getCohortsData); | ||
router.get('/cohorts/:cohortid', getSpecificCohort); | ||
|
||
module.exports = router; |
Empty file.
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,5 +1,7 @@ | ||
const { getProjectsData } = require('./getProjectsData'); | ||
const { getProjectById } = require('./getProjectById'); | ||
|
||
module.exports = { | ||
getProjectById, | ||
getProjectsData, | ||
}; |
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 |
---|---|---|
|
@@ -14,10 +14,36 @@ INSERT INTO project (name , description , img_url , github_link , website_link , | |
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA', | ||
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3', | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal',1), | ||
('ca-wiki', | ||
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page', | ||
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA', | ||
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3', | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal',2), | ||
('ca-wiki', | ||
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page', | ||
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA', | ||
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3', | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal',1), | ||
('ca-wiki', | ||
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page', | ||
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA', | ||
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3', | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal',2), | ||
|
||
('events-booker', | ||
'This app to help GSG organization in organizing the registration for the events that they do. So When they announced for an event, it will be known who would like to attend and they can ensure if this person attended or not. By this way, the GSG can have information about the people who attended and they can use it in the future as they want.', | ||
'https://d2slcw3kip6qmk.cloudfront.net/marketing/blog/2017Q2/[email protected]', | ||
'https://github.com/GSG-G8/events-booker', | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Remotely project',2); | ||
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Remotely',2), | ||
('room-booker', | ||
'Gaza sky Geeks (GSG) has many rooms and many staff members with the ability to book any room but there is no way to know who booked what', | ||
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA', | ||
'https://github.com/GSG-G8/room-booker', | ||
'https://github.com/GSG-G8/room-booker','Remotely',1), | ||
('Applicants System', | ||
'An application to facilitate code academy application process for applicants and help them to complete their applications easily and on time, also help code academy team to track , filter and create applications.', | ||
'https://d2slcw3kip6qmk.cloudfront.net/marketing/blog/2017Q2/[email protected]', | ||
'https://github.com/GSG-G8/applicants-system', | ||
'https://github.com/GSG-G8/applicants-system','Internal',2); | ||
|
||
INSERT INTO student_project (student_id , project_id) VALUES (1 , 1) , (2 , 2); |
Oops, something went wrong.