Gave all models string representations and set up file storage.

This commit is contained in:
kououken 2019-01-25 14:37:03 -08:00
parent 71c1208bfa
commit 1a68176f80
6 changed files with 67 additions and 1 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-01-25 22:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0002_auto_20190123_0038'),
]
operations = [
migrations.AlterField(
model_name='datafile',
name='data',
field=models.FileField(blank=True, null=True, upload_to='uploads/%Y/%m/%d/'),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-01-25 22:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0003_auto_20190125_1425'),
]
operations = [
migrations.AlterField(
model_name='datafile',
name='data',
field=models.FileField(blank=True, max_length=512, null=True, upload_to='uploads/%Y/%m/%d/'),
),
]

View file

@ -8,6 +8,9 @@ class Report(models.Model):
date_submitted = models.DateTimeField('date submitted', null=True, blank=True)
submitted = models.BooleanField(default=False)
def __str__(self):
return self.title
class Section(models.Model):
report_id = models.ForeignKey(Report, on_delete=models.CASCADE)
completed = models.BooleanField()
@ -15,6 +18,9 @@ class Section(models.Model):
html_description = models.TextField()
number = models.IntegerField()
def __str__(self):
return "{0}(#{1})".format(self.title, self.number)
class Field(models.Model):
section_id = models.ForeignKey(Section, on_delete=models.CASCADE)
label = models.CharField(max_length=256)
@ -22,26 +28,50 @@ class Field(models.Model):
type = models.CharField(max_length=128)
completed = models.BooleanField(default=False)
def __str__(self):
return "{0}(#{1})".format(self.label, self.number)
class DataBool(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.BooleanField(default=False)
def __str__(self):
if self.data:
return "True"
else:
return "False"
class DataDecimal(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.DecimalField(max_digits=9,decimal_places=2, null=True, blank=True)
def __str__(self):
return "{0}".format(self.data)
class DataDate(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.DateField(null=True, blank=True)
def __str__(self):
return "{0}".format(self.data)
class DataFile(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.FileField(null=True, blank=True)
data = models.FileField(upload_to='uploads/%Y/%m/%d/', max_length=512, null=True, blank=True)
def __str__(self):
return "{0}".format(self.data)
class DataString(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.TextField(default='')
def __str__(self):
return "{0}".format(self.data)
class DataInteger(models.Model):
field_id = models.ForeignKey(Field, on_delete=models.CASCADE)
data = models.IntegerField(null=True, blank=True)
def __str__(self):
return "{0}".format(self.data)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB