Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Queue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIP
Labrador
Queue
Merge requests
!438
Resolve "[Queue-2.0] Create Course and Create Edition buttons"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "[Queue-2.0] Create Course and Create Edition buttons"
393-queue-2-0-create-course-and-create-edition-buttons
into
development
Overview
34
Commits
14
Pipelines
0
Changes
11
Merged
Resolve "[Queue-2.0] Create Course and Create Edition buttons"
Cédric Willekens
requested to merge
393-queue-2-0-create-course-and-create-edition-buttons
into
development
May 5, 2021
Overview
31
Commits
14
Pipelines
0
Changes
11
Make sure to read our
contributing guide
Closes
#393 (closed)
Edited
Aug 13, 2021
by
Cédric Willekens
0
0
Merge request reports
Compare
development
version 12
f6c8d199
Aug 14, 2021
version 11
bef5f350
Aug 13, 2021
version 10
ebfdac6d
Aug 13, 2021
version 9
b91d71c3
Aug 13, 2021
version 8
e830809d
Aug 13, 2021
version 7
b4e206ee
Aug 13, 2021
version 6
43cb36be
Aug 5, 2021
version 5
63edd08d
Aug 4, 2021
version 4
cab1d890
Aug 4, 2021
version 3
049c94dd
Aug 4, 2021
version 2
a5fba553
Aug 4, 2021
version 1
f3b03f09
Jul 13, 2021
development (base)
and
latest version
latest version
14a74455
14 commits,
Aug 14, 2021
version 12
f6c8d199
13 commits,
Aug 14, 2021
version 11
bef5f350
12 commits,
Aug 13, 2021
version 10
ebfdac6d
11 commits,
Aug 13, 2021
version 9
b91d71c3
10 commits,
Aug 13, 2021
version 8
e830809d
9 commits,
Aug 13, 2021
version 7
b4e206ee
8 commits,
Aug 13, 2021
version 6
43cb36be
7 commits,
Aug 5, 2021
version 5
63edd08d
5 commits,
Aug 4, 2021
version 4
cab1d890
5 commits,
Aug 4, 2021
version 3
049c94dd
4 commits,
Aug 4, 2021
version 2
a5fba553
3 commits,
Aug 4, 2021
version 1
f3b03f09
2 commits,
Jul 13, 2021
11 files
+
659
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
11
src/main/java/nl/tudelft/queue/controller/AdminController.java
0 → 100644
+
120
−
0
View file @ 14a74455
Edit in single-file editor
Open in Web IDE
/*
* Queue - A Queueing system that can be used to handle labs in higher education
* Copyright (C) 2016-2021 Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
nl.tudelft.queue.controller
;
import
javax.validation.Valid
;
import
nl.tudelft.labracore.api.*
;
import
nl.tudelft.labracore.api.dto.*
;
import
nl.tudelft.labracore.lib.security.user.AuthenticatedPerson
;
import
nl.tudelft.labracore.lib.security.user.Person
;
import
nl.tudelft.queue.dto.create.QueueCourseCreateDTO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
@Controller
@PreAuthorize
(
"@permissionService.isAdmin()"
)
@RequestMapping
(
"/admin"
)
public
class
AdminController
{
@Autowired
private
CourseControllerApi
cApi
;
@Autowired
private
ProgramControllerApi
programApi
;
/**
* Adds a model attribute to every template resolution for recognizing the type of page we are in. For
* this controller all pages will be in the "admin"-area.
*
* @return The generic page name: "admin".
*/
@ModelAttribute
(
"page"
)
public
static
String
page
()
{
return
"admin"
;
}
/**
* Return the main admin page.
*
* @return The Thymeleaf view to resolve.
*/
@GetMapping
public
String
getAdminPage
()
{
return
"admin/view"
;
}
/**
* Get the list of courses in Queue.
*
* @param model The model to fill out for Thymeleaf template resolution.
* @return The thymeleaf template to resolve.
*/
@GetMapping
(
"/courses"
)
public
String
getAllCourses
(
Model
model
)
{
var
courses
=
cApi
.
getAllCourses
().
collectList
().
block
();
model
.
addAttribute
(
"courses"
,
courses
);
return
"admin/view/courseList"
;
}
/**
* Get the admin overview for a specific course.
*
* @param courseId The id of the course to retrieve.
* @param model The model to fill out for Thymeleaf template resolution.
* @return The thymeleaf template to resolve.
*/
@GetMapping
(
"/course/{courseId}"
)
public
String
viewCourse
(
@PathVariable
Long
courseId
,
Model
model
)
{
var
course
=
cApi
.
getCourseById
(
courseId
).
block
();
model
.
addAttribute
(
"course"
,
course
);
return
"admin/view/course"
;
}
/**
*
* @param model The model to fill out for Thymeleaf template resolution.
* @return The thymeleaf template to resolve.
*/
@GetMapping
(
"/course/add"
)
public
String
getCreateCoursePage
(
@AuthenticatedPerson
Person
person
,
Model
model
)
{
QueueCourseCreateDTO
create
=
QueueCourseCreateDTO
.
builder
().
build
();
model
.
addAttribute
(
"course"
,
create
);
model
.
addAttribute
(
"programs"
,
programApi
.
getAllRelevantPrograms
(
person
.
getId
()).
collectList
().
block
());
return
"admin/create/course"
;
}
/**
* Creates a new course based on the infromation filled in in the {@link QueueCourseCreateDTO} object.
*
* @param create The DTO used to create the course
* @return A redirect to the admin page
*/
@PostMapping
(
"/course/add"
)
public
String
createCourse
(
@Valid
@ModelAttribute
(
"course"
)
QueueCourseCreateDTO
create
)
{
CourseCreateDTO
course
=
create
.
apply
();
cApi
.
addCourse
(
course
).
block
();
return
"redirect:/admin"
;
}
}
Loading