[%- for column in columns %]
{% if "[[ column.name ]]" not in skip_columns %}
- {{ instance.[[ column.name ]] }} |
+
+ [%- if column.type in ['relationship'] %]
+ [%- if column.multiple %]
+ {{ instance.[[ column.name|pluralize ]] }}
+ [%- else %]
+ {{ instance.[[ column.name ]] }}
+ [%- endif %]
+ [%- else %]
+ {{ instance.[[ column.name ]] }}
+ [%- endif %]
+ |
{% endif %}
[%- endfor %]
diff --git a/vm_gen/templates/html/_update.html b/vm_gen/templates/html/_update.html
index baa5be4..b2d9794 100644
--- a/vm_gen/templates/html/_update.html
+++ b/vm_gen/templates/html/_update.html
@@ -4,12 +4,23 @@
:
[%- if column.type in ['relationship'] %]
+ [%- elif column.type in ['choice', ] %]
+
[%- elif column.type in ['number', 'int', 'integer', ] %]
[%- endif %]
+
[%- endfor %]
\ No newline at end of file
diff --git a/vm_gen/vm_gen.py b/vm_gen/vm_gen.py
index 5ddb822..082ca4a 100644
--- a/vm_gen/vm_gen.py
+++ b/vm_gen/vm_gen.py
@@ -24,14 +24,15 @@ def _process_choice(column):
}
-def process_secondary(secondary):
- col1, col2 = secondary.split('_')
+def process_secondary(view_model, column_name):
+ model_name = camel_case_to_snake_case(view_model.get('name'))
+ secondary = "{}__{}".format(model_name, column_name)
return {
'name': secondary,
'columns': [{
- 'name': col1
+ 'name': model_name
}, {
- 'name': col2
+ 'name': column_name
}]
}
@@ -49,11 +50,12 @@ def enrich_view_model(view_model):
_column_type = 'db.Boolean'
elif column_type in ['relationship', ]:
_column_type = 'relationship'
- secondary = column.get('secondary')
- if secondary:
+ multiple = column.get('multiple')
+ if multiple:
if '_secondaries' not in view_model:
view_model['_secondaries'] = []
- secondary_model = process_secondary(secondary)
+ secondary_model = process_secondary(view_model, column_name)
+ column.update({'secondary': secondary_model})
view_model['_secondaries'].append(secondary_model)
elif column_type in ['choice', ]:
if '_choice_types' not in view_model:
|