Skip to content

Commit

Permalink
feat: editor for course description and editor, better project overvi…
Browse files Browse the repository at this point in the history
…ew list
  • Loading branch information
EwoutV committed Apr 16, 2024
1 parent 86bb212 commit 89546d5
Show file tree
Hide file tree
Showing 32 changed files with 493 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 5.0.4 on 2024-04-15 19:09

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0015_checkresult_remove_extrachecksresult_error_message_and_more'),
]

operations = [
migrations.AddField(
model_name='course',
name='excerpt',
field=models.CharField(default='no excerpt provided', max_length=200),
preserve_default=False,
),
migrations.AlterField(
model_name='checkresult',
name='submission',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='api.submission'),
),
migrations.AlterField(
model_name='extracheckresult',
name='extra_check',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extra_check', to='api.extracheck'),
),
migrations.AlterField(
model_name='structurecheckresult',
name='structure_check',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='structure_check', to='api.structurecheck'),
),
]
3 changes: 3 additions & 0 deletions backend/api/models/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Course(models.Model):
# Begin year of the academic year
academic_startyear = models.IntegerField(blank=False, null=False)

# The excerpt of the course
excerpt = models.CharField(max_length=200, blank=False, null=False)

# The description of the course
description = models.TextField(blank=True, null=True)

Expand Down
6 changes: 6 additions & 0 deletions backend/api/serializers/course_serializer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from nh3 import clean
from django.utils.translation import gettext
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -37,6 +38,11 @@ class CourseSerializer(serializers.ModelSerializer):
read_only=True
)

def validate(self, attrs: dict) -> dict:
"""Extra custom validation for course serializer"""
attrs['description'] = clean(attrs['description'])
return attrs

class Meta:
model = Course
fields = "__all__"
Expand Down
3 changes: 3 additions & 0 deletions backend/api/serializers/project_serializer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from nh3 import clean
from api.logic.check_folder_structure import parse_zip_file
from api.models.checks import FileExtension
from api.models.course import Course
Expand Down Expand Up @@ -64,6 +65,8 @@ def validate(self, data):
if "deadline" in data and data["deadline"] < start_date:
raise ValidationError(gettext("project.errors.deadline_before_start_date"))

data['description'] = clean(data['description'])

return data

class Meta:
Expand Down
27 changes: 26 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ django-seed = "^0.3.1"
django-celery-results = "^2.5.1"
django-polymorphic = "^3.1.0"
django-rest-polymorphic = "^0.1.10"
nh3 = "^0.2.17"


[build-system]
Expand Down
Loading

0 comments on commit 89546d5

Please sign in to comment.