Merged data fields into Field table, added 'required' and 'auto_submit' fields to Section.
This commit is contained in:
parent
bd9ba06bba
commit
6ae79194d0
14 changed files with 126 additions and 196 deletions
|
@ -4,9 +4,3 @@ from .models import *
|
|||
admin.site.register(Report)
|
||||
admin.site.register(Section)
|
||||
admin.site.register(Field)
|
||||
admin.site.register(DataBool)
|
||||
admin.site.register(DataDecimal)
|
||||
admin.site.register(DataDate)
|
||||
admin.site.register(DataFile)
|
||||
admin.site.register(DataString)
|
||||
admin.site.register(DataInteger)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.5 on 2019-01-23 00:38
|
||||
# Generated by Django 2.1.5 on 2019-02-01 00:21
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
@ -12,56 +12,20 @@ class Migration(migrations.Migration):
|
|||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DataBool',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.BooleanField(default=False)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DataDate',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.DateField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DataDecimal',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.DecimalField(blank=True, decimal_places=2, max_digits=9, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DataFile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.FileField(blank=True, null=True, upload_to='')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DataInteger',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.IntegerField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DataString',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('data', models.TextField(default='')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Field',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('label', models.CharField(max_length=256)),
|
||||
('label', models.CharField(max_length=512)),
|
||||
('number', models.IntegerField()),
|
||||
('type', models.CharField(max_length=128)),
|
||||
('completed', models.BooleanField(default=False)),
|
||||
('data_bool', models.BooleanField(default=False)),
|
||||
('data_decimal', models.DecimalField(blank=True, decimal_places=2, max_digits=9, null=True)),
|
||||
('data_date', models.DateField(blank=True, null=True)),
|
||||
('data_file', models.FileField(blank=True, max_length=512, null=True, upload_to='uploads/%Y/%m/%d/')),
|
||||
('data_string', models.TextField(default='')),
|
||||
('data_integer', models.IntegerField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
@ -78,6 +42,8 @@ class Migration(migrations.Migration):
|
|||
name='Section',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('auto_submit', models.BooleanField()),
|
||||
('required', models.BooleanField()),
|
||||
('completed', models.BooleanField()),
|
||||
('title', models.CharField(max_length=256)),
|
||||
('html_description', models.TextField()),
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
# Generated by Django 2.1.5 on 2019-01-23 00:38
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('backend', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='report',
|
||||
name='user_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='field',
|
||||
name='section_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Section'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='datastring',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='datainteger',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='datafile',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='datadecimal',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='datadate',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='databool',
|
||||
name='field_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Field'),
|
||||
),
|
||||
]
|
28
back/backend/migrations/0002_auto_20190131_1621.py
Normal file
28
back/backend/migrations/0002_auto_20190131_1621.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 2.1.5 on 2019-02-01 00:21
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('backend', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='report',
|
||||
name='user_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='field',
|
||||
name='section_id',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backend.Section'),
|
||||
),
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
# 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/'),
|
||||
),
|
||||
]
|
39
back/backend/migrations/0003_auto_20190131_1637.py
Normal file
39
back/backend/migrations/0003_auto_20190131_1637.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Generated by Django 2.1.5 on 2019-02-01 00:37
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('backend', '0002_auto_20190131_1621'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='field',
|
||||
name='data_date',
|
||||
field=models.DateField(default=datetime.date.today, verbose_name='date'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='field',
|
||||
name='data_integer',
|
||||
field=models.IntegerField(blank=True, default=0),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='field',
|
||||
name='data_string',
|
||||
field=models.TextField(blank=True, default=''),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='report',
|
||||
name='date_created',
|
||||
field=models.DateTimeField(default=datetime.date.today, verbose_name='date created'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='report',
|
||||
name='date_submitted',
|
||||
field=models.DateTimeField(default=datetime.date.today, verbose_name='date submitted'),
|
||||
),
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
# 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/'),
|
||||
),
|
||||
]
|
19
back/backend/migrations/0004_auto_20190131_1645.py
Normal file
19
back/backend/migrations/0004_auto_20190131_1645.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.1.5 on 2019-02-01 00:45
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('backend', '0003_auto_20190131_1637'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='field',
|
||||
name='data_date',
|
||||
field=models.DateField(default=datetime.date.today),
|
||||
),
|
||||
]
|
|
@ -1,11 +1,12 @@
|
|||
from django.db import models
|
||||
from django.conf import settings
|
||||
import datetime
|
||||
|
||||
class Report(models.Model):
|
||||
user_id = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
title = models.CharField(max_length=128)
|
||||
date_created = models.DateTimeField('date created')
|
||||
date_submitted = models.DateTimeField('date submitted', null=True, blank=True)
|
||||
date_created = models.DateTimeField('date created', default=datetime.date.today)
|
||||
date_submitted = models.DateTimeField('date submitted', default=datetime.date.today)
|
||||
submitted = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -13,6 +14,8 @@ class Report(models.Model):
|
|||
|
||||
class Section(models.Model):
|
||||
report_id = models.ForeignKey(Report, on_delete=models.CASCADE)
|
||||
auto_submit = models.BooleanField()
|
||||
required = models.BooleanField()
|
||||
completed = models.BooleanField()
|
||||
title = models.CharField(max_length=256)
|
||||
html_description = models.TextField()
|
||||
|
@ -23,55 +26,30 @@ class Section(models.Model):
|
|||
|
||||
class Field(models.Model):
|
||||
section_id = models.ForeignKey(Section, on_delete=models.CASCADE)
|
||||
label = models.CharField(max_length=256)
|
||||
label = models.CharField(max_length=512)
|
||||
number = models.IntegerField()
|
||||
type = models.CharField(max_length=128)
|
||||
completed = models.BooleanField(default=False)
|
||||
data_bool = models.BooleanField(default=False)
|
||||
data_decimal = models.DecimalField(max_digits=9,decimal_places=2, null=True, blank=True)
|
||||
data_date = models.DateField(default=datetime.date.today)
|
||||
data_file = models.FileField(upload_to='uploads/%Y/%m/%d/', max_length=512, null=True, blank=True)
|
||||
data_string = models.TextField(default='', blank=True)
|
||||
data_integer = models.IntegerField(default=0, blank=True)
|
||||
|
||||
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(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)
|
||||
if self.type == "boolean":
|
||||
if self.data_bool:
|
||||
return "True"
|
||||
else:
|
||||
return "False"
|
||||
elif self.type == "decimal":
|
||||
return "{}".format(self.data_decimal)
|
||||
elif self.type == "date":
|
||||
return "{}".format(self.data_date)
|
||||
elif self.type == "file":
|
||||
return "{}".format(self.data_file)
|
||||
elif self.type == "string":
|
||||
return "{}".format(self.data_string)
|
||||
elif self.type == "integer":
|
||||
return "{}".format(self.data_integer)
|
||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
|
@ -126,7 +126,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'America/Los_Angeles'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.5 on 2019-01-23 00:38
|
||||
# Generated by Django 2.1.5 on 2019-02-01 00:21
|
||||
|
||||
import django.contrib.auth.models
|
||||
import django.contrib.auth.validators
|
||||
|
@ -35,8 +35,8 @@ class Migration(migrations.Migration):
|
|||
],
|
||||
options={
|
||||
'verbose_name': 'user',
|
||||
'verbose_name_plural': 'users',
|
||||
'abstract': False,
|
||||
'verbose_name_plural': 'users',
|
||||
},
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
|
|
Loading…
Reference in a new issue