Skip to content

Commit

Permalink
Create a new staff scope
Browse files Browse the repository at this point in the history
  • Loading branch information
josh1248 committed Sep 8, 2024
1 parent e84c941 commit 6b7e54e
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions lib/cadet_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ defmodule CadetWeb.Router do
plug(:assign_course)
end

pipeline :ensure_admin do
plug(:ensure_role, [:admin])
end

pipeline :ensure_staff do
plug(:ensure_role, [:staff, :admin])
end
Expand Down Expand Up @@ -119,8 +123,8 @@ defmodule CadetWeb.Router do
get("/team/:assessmentid", TeamController, :index)
end

# Admin pages
scope "/v2/courses/:course_id/admin", CadetWeb do
# Staff pages
scope "/v2/courses/:course_id/staff", CadetWeb do
pipe_through([:api, :auth, :ensure_auth, :course, :ensure_staff])

resources("/sourcecast", AdminSourcecastController, only: [:create, :delete])
Expand All @@ -129,10 +133,6 @@ defmodule CadetWeb.Router do
post("/assets/:foldername/*filename", AdminAssetsController, :upload)
delete("/assets/:foldername/*filename", AdminAssetsController, :delete)

post("/assessments", AdminAssessmentsController, :create)
post("/assessments/:assessmentid", AdminAssessmentsController, :update)
delete("/assessments/:assessmentid", AdminAssessmentsController, :delete)

get(
"/assessments/:assessmentid/popularVoteLeaderboard",
AdminAssessmentsController,
Expand Down Expand Up @@ -220,6 +220,23 @@ defmodule CadetWeb.Router do
post("/teams/upload", AdminTeamsController, :bulk_upload)
end

# Staff pages
scope "/v2/courses/:course_id/admin", CadetWeb do
pipe_through([:api, :auth, :ensure_auth, :course, :ensure_admin])

post("/assessments", AdminAssessmentsController, :create)
post("/assessments/:assessmentid", AdminAssessmentsController, :update)
delete("/assessments/:assessmentid", AdminAssessmentsController, :delete)

post("/grading/:assessmentid/publish_all_grades", AdminGradingController, :publish_all_grades)

post(
"/grading/:assessmentid/unpublish_all_grades",
AdminGradingController,
:unpublish_all_grades
)
end

# Other scopes may use custom stacks.
# scope "/api", CadetWeb do
# pipe_through :api
Expand Down

0 comments on commit 6b7e54e

Please sign in to comment.