-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from SELab-2/development
Deploy first version of the frontend
- Loading branch information
Showing
226 changed files
with
20,941 additions
and
1,314 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
Binary file not shown.
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 |
---|---|---|
|
@@ -17,4 +17,7 @@ | |
fields: | ||
project: 1 | ||
score: 8 | ||
students: [] | ||
students: | ||
- '1' | ||
- '2' | ||
- '3' |
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
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,15 @@ | ||
from rest_framework.permissions import IsAuthenticated, SAFE_METHODS | ||
from api.permissions.role_permissions import is_teacher | ||
from authentication.models import User | ||
|
||
|
||
class StudentPermission(IsAuthenticated): | ||
|
||
def has_permission(self, request, view): | ||
"""Check if user has permission to view a general student endpoint.""" | ||
return view.action == 'retrieve' | ||
|
||
def has_object_permission(self, request, view, obj): | ||
"""Check if user has permission to view a detailed group endpoint""" | ||
user: User = request.user | ||
return request.method in SAFE_METHODS and (user.id == request.user.id or is_teacher(user)) |
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,15 @@ | ||
from rest_framework.permissions import IsAuthenticated, SAFE_METHODS | ||
from authentication.models import User | ||
|
||
|
||
# (Almost) same as StudentPermission | ||
class TeacherPermission(IsAuthenticated): | ||
|
||
def has_permission(self, request, view): | ||
"""Check if user has permission to view a general Teacher endpoint.""" | ||
return view.action == 'retrieve' | ||
|
||
def has_object_permission(self, request, view, obj): | ||
"""Check if user has permission to view a detailed group endpoint""" | ||
user: User = request.user | ||
return request.method in SAFE_METHODS and user.id == request.user.id |
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
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from django.urls import reverse | ||
from rest_framework.test import APITestCase | ||
from api.models.assistant import Assistant | ||
from api.models.teacher import Teacher | ||
from api.models.course import Course | ||
from authentication.models import Faculty, User | ||
|
||
|
@@ -287,3 +288,44 @@ def test_assistant_courses(self): | |
self.assertEqual(content["name"], course2.name) | ||
self.assertEqual(int(content["academic_startyear"]), course2.academic_startyear) | ||
self.assertEqual(content["description"], course2.description) | ||
|
||
|
||
class AssitantModelAsTeacherTests(APITestCase): | ||
def setUp(self) -> None: | ||
self.user = Teacher.objects.create( | ||
id=1, | ||
first_name="John", | ||
last_name="Doe", | ||
username="john_doe", | ||
email="[email protected]" | ||
) | ||
|
||
self.client.force_authenticate(self.user) | ||
|
||
def test_retrieve_assistant_list(self): | ||
""" | ||
Able to retrieve assistant list as a teacher. | ||
""" | ||
# Create an assistant for testing with the name "Bob Peeters" | ||
create_assistant( | ||
id=5, first_name="Bob", last_name="Peeters", email="[email protected]" | ||
) | ||
|
||
create_assistant( | ||
id=6, first_name="Jane", last_name="Doe", email="[email protected]" | ||
) | ||
|
||
# Make a GET request to retrieve the assistant details | ||
response = self.client.get(reverse("assistant-list"), follow=True) | ||
|
||
# Check if the response was successful | ||
self.assertEqual(response.status_code, 200) | ||
|
||
# Assert that the response is JSON | ||
self.assertEqual(response.accepted_media_type, "application/json") | ||
|
||
# Parse the JSON content from the response | ||
content_json = json.loads(response.content.decode("utf-8")) | ||
|
||
# Assert that the parsed JSON is a list with multiple assistant | ||
self.assertEqual(len(content_json), 2) |
Oops, something went wrong.