diff --git a/back/backend/admin.py b/back/backend/admin.py index 82c2833..e3e94a0 100644 --- a/back/backend/admin.py +++ b/back/backend/admin.py @@ -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) diff --git a/back/backend/migrations/0001_initial.py b/back/backend/migrations/0001_initial.py index 1176375..2f2b805 100644 --- a/back/backend/migrations/0001_initial.py +++ b/back/backend/migrations/0001_initial.py @@ -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()), diff --git a/back/backend/migrations/0002_auto_20190123_0038.py b/back/backend/migrations/0002_auto_20190123_0038.py deleted file mode 100644 index c29c19d..0000000 --- a/back/backend/migrations/0002_auto_20190123_0038.py +++ /dev/null @@ -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'), - ), - ] diff --git a/back/backend/migrations/0002_auto_20190131_1621.py b/back/backend/migrations/0002_auto_20190131_1621.py new file mode 100644 index 0000000..1eca0d4 --- /dev/null +++ b/back/backend/migrations/0002_auto_20190131_1621.py @@ -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'), + ), + ] diff --git a/back/backend/migrations/0003_auto_20190125_1425.py b/back/backend/migrations/0003_auto_20190125_1425.py deleted file mode 100644 index 5863d20..0000000 --- a/back/backend/migrations/0003_auto_20190125_1425.py +++ /dev/null @@ -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/'), - ), - ] diff --git a/back/backend/migrations/0003_auto_20190131_1637.py b/back/backend/migrations/0003_auto_20190131_1637.py new file mode 100644 index 0000000..f01f12b --- /dev/null +++ b/back/backend/migrations/0003_auto_20190131_1637.py @@ -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'), + ), + ] diff --git a/back/backend/migrations/0004_auto_20190125_1434.py b/back/backend/migrations/0004_auto_20190125_1434.py deleted file mode 100644 index 9976389..0000000 --- a/back/backend/migrations/0004_auto_20190125_1434.py +++ /dev/null @@ -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/'), - ), - ] diff --git a/back/backend/migrations/0004_auto_20190131_1645.py b/back/backend/migrations/0004_auto_20190131_1645.py new file mode 100644 index 0000000..e04e02e --- /dev/null +++ b/back/backend/migrations/0004_auto_20190131_1645.py @@ -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), + ), + ] diff --git a/back/backend/models.py b/back/backend/models.py index 0dff4f6..bb26ed3 100644 --- a/back/backend/models.py +++ b/back/backend/models.py @@ -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) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index d7782b7..f726ff0 100644 Binary files a/back/db.sqlite3 and b/back/db.sqlite3 differ diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 323a058..7244d49 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -126,7 +126,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'America/Los_Angeles' USE_I18N = True diff --git a/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg b/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg deleted file mode 100644 index 151c5b5..0000000 Binary files a/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large_hKfT3Wx.jpg and /dev/null differ diff --git a/back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large.jpg b/back/uploads/2019/01/31/CUqADRaW4AAb1QI.jpg_large.jpg similarity index 100% rename from back/uploads/2019/01/25/CUqADRaW4AAb1QI.jpg_large.jpg rename to back/uploads/2019/01/31/CUqADRaW4AAb1QI.jpg_large.jpg diff --git a/back/users/migrations/0001_initial.py b/back/users/migrations/0001_initial.py index 89ddacf..5992e07 100644 --- a/back/users/migrations/0001_initial.py +++ b/back/users/migrations/0001_initial.py @@ -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()),