-
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 #47 from SELab-2/databank_fixes
Databank fixes
- Loading branch information
Showing
22 changed files
with
144 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +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) | ||
project = models.ForeignKey('Project', on_delete=models.CASCADE, default='0') | ||
groep = models.ForeignKey('Groep', on_delete=models.CASCADE) | ||
tijdstip = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
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 self.tijdstip | ||
|
||
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,18 +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): | ||
# indiener is een groep, dus zeker student(en) | ||
indiening = Indiening.objects.create(**validated_data) | ||
return indiening | ||
|
||
def update(self, instance, validated_data): | ||
instance = Indiening.objects.create(**validated_data) | ||
instance.save() | ||
return instance | ||
|
||
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
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
Oops, something went wrong.