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 894a6e7..52e2ecd 100644 Binary files a/back/db.sqlite3 and b/back/db.sqlite3 differ diff --git a/front/static/js/viewHistory.js b/front/static/js/viewHistory.js index 7f04143..99bcca7 100644 --- a/front/static/js/viewHistory.js +++ b/front/static/js/viewHistory.js @@ -72,7 +72,7 @@ function createFormGroup(field) { input.name = field.field_name; input.id = field.field_name; - switch(field.type) { + switch(field.field_type) { case "boolean": input.type = "checkbox"; if (field.value === true) @@ -242,7 +242,7 @@ function createReportForm(parsedData, type) { let field = fields[key]; console.log("Field label: " + field.label); - console.log("Field type: " + field.type); + console.log("Field type: " + field.field_type); console.log("Field value: " + field.value); // Create a form group for each field and add it to the form