From 70df4ec486bf9bb799ee84b9ccbc4e0e3ddece21 Mon Sep 17 00:00:00 2001 From: kououken Date: Wed, 13 Feb 2019 17:38:27 -0800 Subject: [PATCH] Changed 'type' references to 'field_type' in backend and a couple places in front end. --- .../migrations/0006_auto_20190213_1719.py | 18 ++++++++++ back/backend/models.py | 26 +++++++-------- back/backend/policy.py | 31 +++++++++--------- back/backend/views.py | 4 +-- back/db.sqlite3 | Bin 105472 -> 105472 bytes front/static/js/viewHistory.js | 4 +-- 6 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 back/backend/migrations/0006_auto_20190213_1719.py diff --git a/back/backend/migrations/0006_auto_20190213_1719.py b/back/backend/migrations/0006_auto_20190213_1719.py new file mode 100644 index 0000000..a7780de --- /dev/null +++ b/back/backend/migrations/0006_auto_20190213_1719.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-02-14 01:19 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('backend', '0005_field_field_name'), + ] + + operations = [ + migrations.RenameField( + model_name='field', + old_name='type', + new_name='field_type', + ), + ] diff --git a/back/backend/models.py b/back/backend/models.py index 557020f..33caa60 100644 --- a/back/backend/models.py +++ b/back/backend/models.py @@ -30,7 +30,7 @@ class Field(models.Model): field_name = models.CharField(max_length=512, default="field") label = models.CharField(max_length=512) number = models.IntegerField() - type = models.CharField(max_length=128) + field_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) @@ -42,41 +42,41 @@ class Field(models.Model): # function that prints the string representation # on the api? def __str__(self): - if self.type == "boolean": + if self.field_type == "boolean": if self.data_bool: return "True" else: return "False" - elif self.type == "decimal": + elif self.field_type == "decimal": return "{}".format(self.data_decimal) - elif self.type == "date": + elif self.field_type == "date": return "{}".format(self.data_date) - elif self.type == "file": + elif self.field_type == "file": return "{}".format(self.data_file) - elif self.type == "string": + elif self.field_type == "string": return "{}".format(self.data_string) - elif self.type == "integer": + elif self.field_type == "integer": return "{}".format(self.data_integer) # function that gets corresponding # data type def get_datatype(self): - if self.type == "boolean": + if self.field_type == "boolean": if self.data_bool: return True else: return False - elif self.type == "decimal": + elif self.field_type == "decimal": return self.data_decimal - elif self.type == "date": + elif self.field_type == "date": return "{}".format(self.data_date) - elif self.type == "file": + elif self.field_type == "file": file_name = self.path_leaf(str(self.data_file)) return "{}".format(file_name) - elif self.type == "string": + elif self.field_type == "string": return "{}".format(self.data_string) - elif self.type == "integer": + elif self.field_type == "integer": return self.data_integer # function that accommodates if diff --git a/back/backend/policy.py b/back/backend/policy.py index c648149..381405e 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -39,7 +39,7 @@ general_section = Section( title="General Info", html_description="", fields={ - "destination": {"label": "Destination City", "type": "string"}, + "destination": {"label": "Destination City", "field_type": "string"}, } ) @@ -57,11 +57,12 @@ flight_section = Section( title="Flight Info", html_description="

Enter flight details here.

", fields={ - "international": {"label": "Is this an international flight?", "type": "boolean"}, - "departure_date": {"label": "Departure date", "type": "date"}, - "return_date": {"label": "Return date", "type": "date"}, - "fare": {"label": "Fare", "type": "decimal"}, - "layovers": {"label": "Transit wait", "type": "integer"}, + "international": {"label": "Is this an international flight?", "field_type": "boolean"}, + "departure_date": {"label": "Departure date", "field_type": "date"}, + "return_date": {"label": "Return date", "field_type": "date"}, + "fare": {"label": "Fare", "field_type": "decimal"}, + "layovers": {"label": "Transit wait", "field_type": "integer"}, + "fare_search_screenshot": {"label": "Screenshot of fare search", "field_type": "file"}, } ) @@ -80,10 +81,10 @@ lodging_section = Section( html_description="

Enter hotel info here.\nPer diem rates can be found at " "this link

", fields={ - "check-in_date": {"label": "Check-in date", "type": "date"}, - "check-out_date": {"label": "Check-out date", "type": "date"}, - "rate": {"label": "Per diem nightly rate", "type": "decimal"}, - "cost": {"label": "Total Cost", "type": "decimal"} + "check-in_date": {"label": "Check-in date", "field_type": "date"}, + "check-out_date": {"label": "Check-out date", "field_type": "date"}, + "rate": {"label": "Per diem nightly rate", "field_type": "decimal"}, + "cost": {"label": "Total Cost", "field_type": "decimal"} } ) @@ -107,8 +108,8 @@ transport_section = Section( title="Local Transportation", html_description="

How much did you spend on local transportation, in total?

", fields={ - "duration": {"label": "How many days was your trip?", "type": "decimal"}, - "cost": {"label": "Total cost", "type": "decimal"} + "duration": {"label": "How many days was your trip?", "field_type": "decimal"}, + "cost": {"label": "Total cost", "field_type": "decimal"} } ) @@ -127,9 +128,9 @@ per_diem_section = Section( html_description="

Enter info about meals and incidentals here.\nPer diem rates can be found at " "this link

", fields={ - "duration": {"label": "How many days was your trip?", "type": "decimal"}, - "rate": {"label": "What is the per diem rate for your destination?", "type": "decimal"}, - "cost": {"label": "Total Cost for meals and incidentals", "type": "decimal"} + "duration": {"label": "How many days was your trip?", "field_type": "decimal"}, + "rate": {"label": "What is the per diem rate for your destination?", "field_type": "decimal"}, + "cost": {"label": "Total Cost for meals and incidentals", "field_type": "decimal"} } ) diff --git a/back/backend/views.py b/back/backend/views.py index e59d5c6..9d9f9f0 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -55,7 +55,7 @@ def get_fields(s_id): data = { "field_name": i.field_name, "label": i.label, - "type": i.type, + "field_type": i.field_type, "number": i.number, "value": value } @@ -92,7 +92,7 @@ def report(request): for key in section.fields: field = section.fields[key] f = Field.objects.create(section_id=s, field_name=key, label=field['label'], - number=j, type=field['type'], completed=False) + number=j, field_type=field['field_type'], completed=False) f.save() j = j+1 diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 894a6e76b6ba52528ec81376750c7f6dad32f04f..52e2ecd33b88e7002ab103f534d060a875cfa6ab 100644 GIT binary patch delta 3403 zcmeHJUrbwN6#vfsfL`n51Irv&>Hl7=-uESQC76V}^8uZVEq)2cP-$BUqG;S#m&Wq96m_HGcB@)dJ z;*vb)UzFktp+q7Si#ls+vA}Hc_4{L~KaI|$!mT#oxA1bRXVr_9_mmOCWGMz{n@Iht zwEbwP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