-
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.
- Loading branch information
Showing
50 changed files
with
921 additions
and
580 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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
# Generated by Django 5.0.4 on 2024-05-02 15:15 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0018_course_invitation_link_and_more'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Feedback', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('message', models.TextField()), | ||
('creation_date', models.DateTimeField(auto_now_add=True)), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='feedback_messages', to=settings.AUTH_USER_MODEL)), | ||
('submission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='feedback', to='api.submission')), | ||
], | ||
), | ||
] |
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,14 @@ | ||
# Generated by Django 5.0.4 on 2024-05-07 12:30 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0019_feedback'), | ||
('api', '0023_submission_zip_alter_checkresult_error_message_and_more'), | ||
] | ||
|
||
operations = [ | ||
] |
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,14 @@ | ||
# Generated by Django 5.0.4 on 2024-05-18 10:58 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0024_merge_20240507_1230'), | ||
('api', '0025_extracheckresult_artifact'), | ||
] | ||
|
||
operations = [ | ||
] |
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,38 @@ | ||
from django.db import models | ||
from api.models.submission import Submission | ||
from authentication.models import User | ||
|
||
|
||
class Feedback(models.Model): | ||
"""Model that represents a feedback message.""" | ||
|
||
# ID should be generated automatically | ||
|
||
# Feedback message | ||
message = models.TextField(null=False) | ||
|
||
# Feedback message author | ||
author = models.ForeignKey( | ||
User, | ||
# If the author is deleted, the feedback message should be deleted as well | ||
on_delete=models.CASCADE, | ||
related_name="feedback_messages", | ||
blank=False, | ||
null=False, | ||
) | ||
|
||
# Feedback message creation date | ||
creation_date = models.DateTimeField( | ||
# The default value is the current date and time | ||
auto_now_add=True, | ||
blank=False, | ||
null=False | ||
) | ||
|
||
submission = models.ForeignKey( | ||
Submission, | ||
on_delete=models.CASCADE, | ||
related_name="feedback", | ||
blank=False, | ||
null=False | ||
) |
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,17 @@ | ||
from rest_framework import permissions | ||
|
||
from api.permissions.role_permissions import is_teacher | ||
|
||
|
||
class IsAdminOrTeacherForPatch(permissions.BasePermission): | ||
""" | ||
Custom permission to only allow admins to access objects in general, | ||
but teachers can only make PATCH requests. | ||
""" | ||
|
||
def has_permission(self, request, view): | ||
if request.user.is_authenticated and request.user.is_staff: | ||
return True | ||
elif request.method == 'PATCH' and is_teacher(request.user): | ||
return True | ||
return False |
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
Oops, something went wrong.