-
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
30 changed files
with
525 additions
and
377 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
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 |
---|---|---|
@@ -1,11 +1,22 @@ | ||
from django.db import models | ||
|
||
|
||
def upload_to(instance, filename): | ||
return f'data/indieningen/indiening_{instance.indiening_id}/{filename}' | ||
|
||
class Indiening(models.Model): | ||
indiening_id = models.AutoField(primary_key=True) | ||
indiener = models.ForeignKey("Groep", on_delete=models.CASCADE) | ||
indieningsbestanden = models.FileField(upload_to="uploads/") | ||
tijdstip = models.DateTimeField(null=False) | ||
groep = models.ForeignKey('Groep', on_delete=models.CASCADE) | ||
tijdstip = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.tijdstip | ||
return str(self.indiening_id) | ||
|
||
|
||
class IndieningBestand(models.Model): | ||
indiening_bestand_id = models.AutoField(primary_key=True) | ||
indiening = models.ForeignKey('Indiening', on_delete=models.CASCADE) | ||
bestand = models.FileField(upload_to=upload_to) | ||
|
||
def __str__(self): | ||
return str(self.bestand.name) |
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
from rest_framework import serializers | ||
from api.models.indiening import Indiening | ||
from api.models.indiening import Indiening, IndieningBestand | ||
|
||
|
||
class IndieningSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Indiening | ||
fields = "__all__" | ||
fields = ('__all__') | ||
|
||
def create(self, validated_data): | ||
return Indiening.objects.create(**validated_data) | ||
|
||
class IndieningBestandSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = IndieningBestand | ||
fields = ('__all__') |
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,8 +1,32 @@ | ||
from rest_framework import serializers | ||
from api.models.project import Project | ||
from django.utils import timezone | ||
|
||
|
||
class ProjectSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Project | ||
fields = "__all__" | ||
fields = '__all__' | ||
|
||
def create(self, validated_data): | ||
deadline = validated_data.pop('deadline') | ||
validate_deadline(deadline) | ||
|
||
project = Project.objects.create(**validated_data) | ||
project.deadline = deadline | ||
project.save() | ||
return project | ||
|
||
def update(self, instance, validated_data): | ||
deadline = validated_data.pop('deadline') | ||
validate_deadline(deadline) | ||
|
||
super().update(instance=instance, validated_data=validated_data) | ||
instance.deadline = deadline | ||
instance.save() | ||
return instance | ||
|
||
|
||
def validate_deadline(deadline): | ||
if deadline <= timezone.now(): | ||
raise serializers.ValidationError("Deadline moet in de toekomst liggen") |
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
Oops, something went wrong.