-
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 #55 from SELab-2/model_update
Model update
- Loading branch information
Showing
23 changed files
with
680 additions
and
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
- model: api.checks | ||
- model: api.structurecheck | ||
pk: 1 | ||
fields: | ||
dockerfile: 'path/to/Dockerfile' | ||
allowed_file_extensions: | ||
- 1 | ||
- 2 | ||
forbidden_file_extensions: | ||
- 3 | ||
- 4 | ||
name: '.' | ||
project: 123456 | ||
obligated_extensions: | ||
- 3 | ||
- 4 | ||
blocked_extensions: | ||
- 1 | ||
- 2 | ||
|
||
- model: api.extracheck | ||
pk: 1 | ||
fields: | ||
project: 123456 | ||
run_script: 'scripts/run.sh' | ||
|
||
- model: api.fileextension | ||
pk: 1 | ||
fields: | ||
extension: 'py' | ||
extension: 'class' | ||
- model: api.fileextension | ||
pk: 2 | ||
fields: | ||
extension: 'js' | ||
extension: 'png' | ||
- model: api.fileextension | ||
pk: 3 | ||
fields: | ||
extension: 'html' | ||
extension: 'java' | ||
- model: api.fileextension | ||
pk: 4 | ||
fields: | ||
extension: 'php' | ||
extension: 'py' |
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
23 changes: 23 additions & 0 deletions
23
backend/api/migrations/0002_project_group_size_project_max_score.py
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,23 @@ | ||
# Generated by Django 5.0.2 on 2024-03-05 10:22 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='project', | ||
name='group_size', | ||
field=models.PositiveSmallIntegerField(default=1), | ||
), | ||
migrations.AddField( | ||
model_name='project', | ||
name='max_score', | ||
field=models.PositiveSmallIntegerField(default=100), | ||
), | ||
] |
39 changes: 39 additions & 0 deletions
39
backend/api/migrations/0003_remove_project_checks_extracheck_structurecheck_and_more.py
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,39 @@ | ||
# Generated by Django 5.0.2 on 2024-03-06 09:08 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0002_project_group_size_project_max_score'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='project', | ||
name='checks', | ||
), | ||
migrations.CreateModel( | ||
name='ExtraCheck', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('run_script', models.FileField(upload_to='')), | ||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extra_checks', to='api.project')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='StructureCheck', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('blocked_extensions', models.ManyToManyField(blank=True, related_name='blocked_extensions', to='api.fileextension')), | ||
('obligated_extensions', models.ManyToManyField(blank=True, related_name='obligated_extensions', to='api.fileextension')), | ||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='structure_checks', to='api.project')), | ||
], | ||
), | ||
migrations.DeleteModel( | ||
name='Checks', | ||
), | ||
] |
28 changes: 28 additions & 0 deletions
28
backend/api/migrations/0004_submission_structure_checks_passed_extrachecksresult.py
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,28 @@ | ||
# Generated by Django 5.0.2 on 2024-03-06 11:53 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0003_remove_project_checks_extracheck_structurecheck_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='submission', | ||
name='structure_checks_passed', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.CreateModel( | ||
name='ExtraChecksResult', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('passed', models.BooleanField(default=False)), | ||
('extra_check', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='api.extracheck')), | ||
('submission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='extra_checks_results', 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,18 @@ | ||
# Generated by Django 5.0.2 on 2024-03-06 14:20 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0004_submission_structure_checks_passed_extrachecksresult'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='project', | ||
name='max_score', | ||
field=models.PositiveSmallIntegerField(default=20), | ||
), | ||
] |
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 |
---|---|---|
@@ -1,30 +1,60 @@ | ||
from django.db import models | ||
from api.models.project import Project | ||
from api.models.extension import FileExtension | ||
|
||
|
||
class FileExtension(models.Model): | ||
"""Model that represents a file extension.""" | ||
class StructureCheck(models.Model): | ||
"""Model that represents a structure check for a project. | ||
This means that the structure of a submission is checked. | ||
These checks are obligated to pass.""" | ||
|
||
# ID check should be generated automatically | ||
# ID should be generated automatically | ||
|
||
extension = models.CharField(max_length=10, unique=True) | ||
# Name of the structure check | ||
name = models.CharField( | ||
max_length=100, | ||
blank=False, | ||
null=False | ||
) | ||
|
||
def __str__(self) -> str: | ||
return str(self.extension) | ||
# Link to the project | ||
project = models.ForeignKey( | ||
Project, | ||
on_delete=models.CASCADE, | ||
related_name="structure_checks" | ||
) | ||
|
||
# Obligated extensions | ||
obligated_extensions = models.ManyToManyField( | ||
FileExtension, | ||
related_name="obligated_extensions", | ||
blank=True | ||
) | ||
|
||
# Blocked extensions | ||
blocked_extensions = models.ManyToManyField( | ||
FileExtension, | ||
related_name="blocked_extensions", | ||
blank=True | ||
) | ||
|
||
class Checks(models.Model): | ||
"""Model that represents checks for a project.""" | ||
|
||
# ID check should be generated automatically | ||
class ExtraCheck(models.Model): | ||
"""Model that represents an extra check for a project. | ||
These checks are not obligated to pass.""" | ||
|
||
dockerfile = models.FileField(blank=True, null=True) | ||
# ID should be generated automatically | ||
|
||
# Link to the file extensions that are allowed | ||
allowed_file_extensions = models.ManyToManyField( | ||
FileExtension, related_name="checks_allowed", blank=True | ||
# Link to the project | ||
project = models.ForeignKey( | ||
Project, | ||
on_delete=models.CASCADE, | ||
related_name="extra_checks" | ||
) | ||
|
||
# Link to the file extensions that are forbidden | ||
forbidden_file_extensions = models.ManyToManyField( | ||
FileExtension, related_name="checks_forbidden", blank=True | ||
# Run script | ||
# TODO set upload_to | ||
run_script = models.FileField( | ||
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,12 @@ | ||
from django.db import models | ||
|
||
|
||
class FileExtension(models.Model): | ||
"""Model that represents a file extension.""" | ||
|
||
# ID should be generated automatically | ||
|
||
extension = models.CharField( | ||
max_length=10, | ||
unique=True | ||
) |
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.