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
Commits
16f4a485
Commit
16f4a485
authored
Apr 9, 2024
by
Ruben Backx
Browse files
Options
Downloads
Plain Diff
Merge branch '698-leave-edition-as-a-teacher' into 'development'
Resolve "Leave edition as a teacher" Closes
#698
See merge request
!772
parents
1fb74353
e72164a6
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!774
Deploy
,
!772
Resolve "Leave edition as a teacher"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
src/main/java/nl/tudelft/queue/service/PermissionService.java
+10
-7
10 additions, 7 deletions
...main/java/nl/tudelft/queue/service/PermissionService.java
with
11 additions
and
7 deletions
CHANGELOG.md
+
1
−
0
View file @
16f4a485
...
...
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
-
Feedbacks are now soft deleted correctly.
[
@hpage
](
https://gitlab.ewi.tudelft.nl/hpage
)
-
Teachers that are the only teacher for an edition now can't leave the edition.
[
@aturgut
](
https://gitlab.ewi.tudelft.nl/aturgut
)
## [2.3.1]
...
...
This diff is collapsed.
Click to expand it.
src/main/java/nl/tudelft/queue/service/PermissionService.java
+
10
−
7
View file @
16f4a485
...
...
@@ -101,6 +101,9 @@ public class PermissionService {
@Lazy
private
RequestService
rs
;
@Autowired
private
RoleDTOService
rds
;
/**
* Gets the Person associated to the currently authenticated entity and passes it to the given callback.
* If no API Key with user could be found, this function just outputs {@code false}.
...
...
@@ -451,10 +454,15 @@ public class PermissionService {
* @return Whether the authenticated user can remove themselves from an edition. A user may not
* leave the course they are in if their role in the course is already linked to a
* student group, as this means they might have requests, submissions, or even grades in
* the course that cannot be disassociated with the user.
* the course that cannot be disassociated with the user. A user that is the only
* teacher of the edition can't leave the edition.
*/
public
boolean
canLeaveEdition
(
Long
editionId
)
{
return
withRole
(
editionId
,
(
person
,
role
)
->
STAFF_ROLES
.
contains
(
role
)
||
return
withRole
(
editionId
,
(
person
,
role
)
->
(
STAFF_ROLES
.
contains
(
role
)
&&
withEdition
(
editionId
,
edition
->
{
return
!
rds
.
isTheOnlyTeacherInEdition
(
person
.
getId
(),
edition
);
}))
||
(
role
==
STUDENT
&&
withEdition
(
editionId
,
edition
->
{
var
groups
=
sgCache
.
getByPerson
(
person
.
getId
());
var
modules
=
edition
.
getModules
().
stream
()
...
...
@@ -566,11 +574,6 @@ public class PermissionService {
* @param editionId The id of an edition
* @return Whether the authenticated user can manage the questions of an edition
*/
/**
* @param editionId The id of the edition the user wants to manage.
* @return Whether the authenticated user can change some values within the settings of the
* edition.
*/
public
boolean
canManageQuestions
(
Long
editionId
)
{
return
isAdmin
()
||
withRole
(
editionId
,
(
person
,
role
)
->
TEACHER
==
role
||
HEAD_TA
==
role
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment