diff --git a/back/backend/migrations/0003_auto_20190125_1425.py b/back/backend/migrations/0003_auto_20190125_1425.py new file mode 100644 index 0000000..5863d20 --- /dev/null +++ b/back/backend/migrations/0003_auto_20190125_1425.py @@ -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/'), + ), + ] diff --git a/back/backend/migrations/0004_auto_20190125_1434.py b/back/backend/migrations/0004_auto_20190125_1434.py new file mode 100644 index 0000000..9976389 --- /dev/null +++ b/back/backend/migrations/0004_auto_20190125_1434.py @@ -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/'), + ), + ] diff --git a/back/backend/models.py b/back/backend/models.py index afff981..0dff4f6 100644 --- a/back/backend/models.py +++ b/back/backend/models.py @@ -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) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 40ac467..d7782b7 100644 Binary files a/back/db.sqlite3 and b/back/db.sqlite3 differ diff --git a/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large.jpg b/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large.jpg new file mode 100644 index 0000000..151c5b5 Binary files /dev/null and b/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large.jpg differ diff --git a/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg b/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg new file mode 100644 index 0000000..151c5b5 Binary files /dev/null and b/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg differ