aboutsummaryrefslogtreecommitdiffstats
path: root/client/models.py
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-06-20 00:28:16 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-06-20 00:28:16 +0200
commitffb9b4111a891fda9e9e1ddf19de936bdbd664f8 (patch)
treecbd563acbfb97d2cad4f7da425de412aad00e5dd /client/models.py
parentMore data for users (diff)
downloadscout-subs-ffb9b4111a891fda9e9e1ddf19de936bdbd664f8.tar.gz
scout-subs-ffb9b4111a891fda9e9e1ddf19de936bdbd664f8.zip
Document support
Diffstat (limited to '')
-rw-r--r--client/models.py57
1 files changed, 41 insertions, 16 deletions
diff --git a/client/models.py b/client/models.py
index d6e8578..01d5f4c 100644
--- a/client/models.py
+++ b/client/models.py
@@ -1,25 +1,21 @@
from django.db import models
-from django.contrib.auth.models import User
+from django.contrib.auth.models import User, Group
from datetime import datetime
# Create your models here.
-class Document(models.Model):
- code = models.IntegerField(default=0)
-
- class Meta:
- permissions = [
- ("approved", "The user is approved")
- ]
+class DocumentType(models.Model):
+ enabled = models.BooleanField(default=False)
+ group_private = models.BooleanField(default=False)
+ group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
+ personal_data = models.BooleanField(default=False)
+ medical_data = models.BooleanField(default=False)
+ custom_data = models.BooleanField(default=False)
+ name = models.CharField(default="", max_length=250)
-class YearSubscription(models.Model):
- user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
- group = models.CharField(default="", max_length=50)
- compilation_date = models.DateTimeField(auto_now_add=True)
- status = models.CharField(default="", max_length=50)
- code = models.IntegerField(default=0)
+class PersonalData(models.Model):
parent_name = models.CharField(default="", max_length=250)
via = models.CharField(default="", max_length=250)
cap = models.CharField(default="", max_length=250)
@@ -28,8 +24,37 @@ class YearSubscription(models.Model):
born_date = models.DateField(null=True, default=datetime.fromtimestamp(0))
home_phone = models.CharField(default="", max_length=250)
phone = models.CharField(default="", max_length=250)
- school = models.CharField(default="", max_length=250)
- year = models.IntegerField(default=0)
+
+
+class Document(models.Model):
+ user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
+ group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
+ code = models.IntegerField(default=0)
+ compilation_date = models.DateTimeField(auto_now_add=True)
+ status = models.CharField(default="", max_length=50)
+ document_type = models.ForeignKey(
+ DocumentType, default=None, on_delete=models.PROTECT)
+
+ personal_data = models.ForeignKey(
+ PersonalData, default=None, on_delete=models.PROTECT)
+
+ class Meta:
+ permissions = [
+ ("approved", "The user is approved")
+ ]
+
+
+class KeyVal(models.Model):
+ container = models.ForeignKey(
+ Document, db_index=True, on_delete=models.CASCADE)
+ key = models.CharField(max_length=240, db_index=True)
+ value = models.CharField(max_length=240, db_index=True)
+
+
+class Keys(models.Model):
+ container = models.ForeignKey(
+ DocumentType, db_index=True, on_delete=models.CASCADE)
+ key = models.CharField(max_length=240, db_index=True)
class UserCode(models.Model):