Changed 'type' references to 'field_type' in backend and a couple places in front end.
This commit is contained in:
parent
69b57ff45a
commit
70df4ec486
6 changed files with 51 additions and 32 deletions
18
back/backend/migrations/0006_auto_20190213_1719.py
Normal file
18
back/backend/migrations/0006_auto_20190213_1719.py
Normal file
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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
|
||||
|
|
|
@ -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="<p>Enter flight details here.</p>",
|
||||
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="<p>Enter hotel info here.\nPer diem rates can be found at "
|
||||
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
||||
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="<p>How much did you spend on local transportation, in total?</p>",
|
||||
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="<p>Enter info about meals and incidentals here.\nPer diem rates can be found at "
|
||||
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
||||
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"}
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue