Skip to content

Commit

Permalink
Merge branch 'development' of github.com:SELab-2/UGent-7 into seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
tyboro2002 committed Apr 8, 2024
2 parents 0919332 + 89c0336 commit 4df5954
Show file tree
Hide file tree
Showing 26 changed files with 669 additions and 139 deletions.
27 changes: 26 additions & 1 deletion backend/api/fixtures/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,36 @@
students:
- '1'
- '2'
- '000200694919'
- model: api.group
pk: 3
fields:
project: 123456
project: 2
score: 8
students: []
- model: api.group
pk: 4
fields:
project: 2
score: 8
students:
- '1'
- model: api.group
pk: 5
fields:
project: 2
score: 8
students:
- '2'

- model: api.group
pk: 6
fields:
project: 2
score: 8
students:
- '3'

- model: api.group
pk: 2
fields:
Expand All @@ -21,3 +45,4 @@
- '1'
- '2'
- '3'
- '000200694919'
15 changes: 14 additions & 1 deletion backend/api/fixtures/projects.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- model: api.project
pk: 123456
fields:
name: sel2
name: sel1
description: make a project
visible: true
archived: false
Expand All @@ -22,3 +22,16 @@
group_size: 3
max_score: 20
course: 1

- model: api.project
pk: 2
fields:
name: sel2
description: make a project, but better and more fun than the previous one because it's the second one and we learned from the first one
visible: true
archived: false
start_date: 2024-02-26 00:00:00+00:00
deadline: 2024-02-27 00:00:00+00:00
group_size: 3
max_score: 20
course: 1
6 changes: 6 additions & 0 deletions backend/api/fixtures/students.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
- 1
- model: api.student
pk: '3'
fields:
student_id: null
courses:
- 1
- model: api.student
pk: '000200694919'
fields:
student_id: null
courses:
Expand Down
15 changes: 15 additions & 0 deletions backend/api/fixtures/submissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
submission_number: 2
submission_time: "2021-01-02T00:00:00Z"
structure_checks_passed: True
- model: api.submission
pk: 3
fields:
group: 4
submission_number: 1
submission_time: "2021-01-02T00:00:00Z"
structure_checks_passed: True
- model: api.submission
pk: 4
fields:
group: 4
submission_number: 2
submission_time: "2021-01-02T00:00:00Z"
structure_checks_passed: True


- model: api.submissionfile
pk: 1
Expand Down
27 changes: 23 additions & 4 deletions backend/api/permissions/group_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def has_object_permission(self, request: Request, view: ViewSet, group) -> bool:
"""Check if user has permission to view a detailed group endpoint"""
user: User = request.user
course = group.project.course
teacher_or_assitant = is_teacher(user) and user.teacher.courses.filter(id=course.id).exists() or \
is_assistant(user) and user.assistant.courses.filter(id=course.id).exists()
teacher_or_assitant = is_teacher(user) and user.teacher.courses.filter(
id=course.id).exists() or is_assistant(user) and user.assistant.courses.filter(id=course.id).exists()

if request.method in SAFE_METHODS:
# Users that are linked to the course can view the group.
Expand All @@ -39,8 +39,8 @@ class GroupStudentPermission(BasePermission):
def has_object_permission(self, request: Request, view: ViewSet, group) -> bool:
user: User = request.user
course = group.project.course
teacher_or_assitant = is_teacher(user) and user.teacher.courses.filter(id=course.id).exists() or \
is_assistant(user) and user.assistant.courses.filter(id=course.id).exists()
teacher_or_assitant = is_teacher(user) and user.teacher.courses.filter(
id=course.id).exists() or is_assistant(user) and user.assistant.courses.filter(id=course.id).exists()

if request.method in SAFE_METHODS:
# Users related to the course can view the students of the group.
Expand All @@ -53,3 +53,22 @@ def has_object_permission(self, request: Request, view: ViewSet, group) -> bool:

# Teachers and assistants can add and remove any student from a group
return teacher_or_assitant


class GroupSubmissionPermission(BasePermission):
"""Permission class for submission related group endpoints"""

def had_object_permission(self, request: Request, view: ViewSet, group) -> bool:
user: User = request.user
course = group.project.course
teacher_or_assitant = is_teacher(user) and user.teacher.courses.filter(
id=course.id).exists() or is_assistant(user) and user.assistant.courses.filter(id=course.id).exists()
if request.method in SAFE_METHODS:
# Users related to the group can view the submissions of the group
return teacher_or_assitant or (is_student(user) and user.student.groups.filter(id=group.id).exists())

# Student can only add submissions to there own group
if is_student(user) and request.data.get("student_id") == user.id and view.action == "create":
return user.student.course.filter(id=course.id).exists()

# Removing a Submissions is not possible for teachers and assistants
4 changes: 2 additions & 2 deletions backend/api/views/group_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rest_framework.response import Response
from drf_yasg.utils import swagger_auto_schema
from api.models.group import Group
from api.permissions.group_permissions import GroupPermission
from api.permissions.group_permissions import GroupPermission, GroupSubmissionPermission
from api.permissions.group_permissions import GroupStudentPermission
from api.serializers.group_serializer import GroupSerializer
from api.serializers.student_serializer import StudentSerializer
Expand Down Expand Up @@ -38,7 +38,7 @@ def students(self, request, **_):
)
return Response(serializer.data)

@action(detail=True, permission_classes=[IsAdminUser])
@action(detail=True, permission_classes=[IsAdminUser | GroupSubmissionPermission])
def submissions(self, request, **_):
"""Returns a list of submissions for the given group"""
group = self.get_object()
Expand Down
12 changes: 12 additions & 0 deletions backend/authentication/fixtures/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@
create_time: 2024-02-29 20:35:45.688545+00:00
faculties:
- Psychologie_PedagogischeWetenschappen
- model: authentication.user
pk: '000200694919'
fields:
last_login: null
username: landmaes
email: lander.maes@ugent.be
first_name: Lander
last_name: Maes
last_enrolled: 2023
create_time: 2024-02-29 20:35:45.688545+00:00
faculties:
- Wetenschappen
14 changes: 13 additions & 1 deletion frontend/src/assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dashboard": "Dashboard",
"calendar": "Calendar",
"courses": "courses",
"projects": "projects",
"settings": "preferences",
"help": "help"
},
Expand Down Expand Up @@ -41,7 +42,11 @@
"projects": {
"deadline": "Deadline",
"submissionStatus": "Indienstatus",
"group": "Group",
"groupMembers": "Group members",
"chooseGroup": "Choose a group",
"joinGroup": "Join group",
"leaveGroup": "Leave group",
"create": "Create new project",
"name": "Project name",
"description": "Description",
Expand All @@ -51,6 +56,12 @@
"visibility": "Make project visible to students",
"score_visibility": "Make score, when uploaded, automatically visible to students"
},
"submissions": {
"title": "Submissions",
"submit": "Submit",
"course": "Course",
"chooseFile": "Choose a file"
},
"courses": {
"create": "Create course",
"name": "Course name",
Expand Down Expand Up @@ -80,7 +91,8 @@
},
"card": {
"open": "details"
}
},
"submission": "Submit"
},
"types": {
"roles": {
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/assets/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dashboard": "Dashboard",
"calendar": "Kalender",
"courses": "Vakken",
"projects": "Projecten",
"settings": "Voorkeuren",
"help": "Help"
},
Expand Down Expand Up @@ -41,7 +42,11 @@
"projects": {
"deadline": "Deadline",
"submissionStatus": "Indienstatus",
"group": "Groep",
"groupMembers": "Groepsleden",
"chooseGroup": "Kies een groep",
"joinGroup": "Kies groep",
"leaveGroup": "Verlaat groep",
"create": "Creëer nieuw project",
"name": "Projectnaam",
"description": "Beschrijving",
Expand All @@ -51,6 +56,12 @@
"visibility": "Project zichtbaar maken voor studenten",
"score_visibility": "Maak score, wanneer ingevuld, automatisch zichtbaar voor studenten"
},
"submissions": {
"title": "Inzendingen",
"submit": "Indienen",
"course": "Vak",
"chooseFile": "Kies bestand(en)"
},
"courses": {
"create": "Creëer vak",
"name": "Vaknaam",
Expand Down Expand Up @@ -89,7 +100,8 @@
},
"card": {
"open": "Details"
}
},
"submission" : "Indienen"
},
"types": {
"roles": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/assets/scss/theme/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $fontWeight:normal !default;
$textColor:$shade700 !default;
$textSecondaryColor:$shade600 !default;
$borderRadius:6px !default;
$borderWidth:2px !default;
$transitionDuration:.2s !default;
$formElementTransition:background-color $transitionDuration, color $transitionDuration, border-color $transitionDuration, box-shadow $transitionDuration !default;
$actionIconTransition:background-color $transitionDuration, color $transitionDuration, box-shadow $transitionDuration !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// core
.p-fileupload-content {
position: relative;
}

.p-fileupload-content .p-progressbar {
width: 100%;
position: absolute;
top: 0;
left: 0;
}

.p-progressbar {
display: none;
}

.p-button.p-fileupload-choose {
position: relative;
overflow: hidden;
Expand Down Expand Up @@ -46,6 +46,7 @@
// theme
.p-fileupload {
.p-fileupload-buttonbar {
justify-content: space-between;
background: $panelHeaderBg;
padding: $panelHeaderPadding;
border: $panelHeaderBorder;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/layout/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const items = computed(() => [
label: t('layout.header.navigation.courses'),
route: 'courses',
},
{
icon: 'file-plus',
label: t('layout.header.navigation.projects'),
route: 'projects',
},
]);
</script>

Expand Down
Loading

0 comments on commit 4df5954

Please sign in to comment.