conditionally show columns

This commit is contained in:
Daniel Tsvetkov 2020-08-12 13:28:04 +02:00
parent 0dbb20fdab
commit 0d02b47df5
4 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@ PaaS - creates easily deployable declarative web applications with (moslty) file
## TODO
* [ ] [list] pagination of many items
* [ ] [prod_install] Download sensitive prompt
* [ ] [vm_gen] Auto generate dependency graph for `view_models/_process_order`
* [ ] [auto_dns] Start and test `auto_dns.service`

View File

@ -325,7 +325,10 @@ def populate_static(app):
if row_updates:
row.update(row_updates)
if model_name == "User":
if 'role_names' in row:
role_names = row.pop('role_names')
else:
role_names = ""
row['password'] = hash_password(row['password'])
user = user_datastore.create_user(**row)
for role_name in role_names.split(';'):

View File

@ -2,7 +2,8 @@
<input type="hidden" name="_next" value="{{ _next or request.args.get('_next') or url_for('list_[[ name|camel_to_snake ]]') }}"/>
<table>
[%- for column in columns %]
<tr><td>
{% if "[[ column.name ]]" not in disabled_columns %}
<tr {% if "[[ column.name ]]" in hidden_columns %}style="display: none;"{% endif %}><td>
<label for="input-[[ name|camel_to_snake ]]-[[ column.name ]]">{{ _("[[ column.name ]]") }}</label>:
</td><td>
[%- if column.type in ['relationship'] %]
@ -14,7 +15,7 @@
[%- if not column.secondary %]
<option selected="selected" value="">{{ _("Choose...") }}</option>
[%- endif %]
{% if instance and instance.[[ column.name|pluralize ]] is defined %}
{% if [[ column.name|pluralize ]] is not defined and instance and instance.[[ column.name|pluralize ]] is defined %}
{% set [[ column.name|pluralize ]] = instance.[[ column.name|pluralize ]] %}
{% else %}
{% set [[ column.name|pluralize ]] = model_views.[[ column.name ]].model.query.all() %}
@ -49,6 +50,7 @@
/>
[%- endif %]
</td></tr>
{% endif %}
[%- endfor %]
</table>
<input type="submit">

View File

@ -2,7 +2,8 @@
<input type="hidden" name="_next" value="{{ _next or request.args.get('_next') or url_for('get_[[ name|camel_to_snake ]]', uuid=instance.id) }}"/>
<table>
[%- for column in columns %]
<tr><td>
{% if "[[ column.name ]]" not in disabled_columns %}
<tr {% if "[[ column.name ]]" in hidden_columns %}style="display: none;"{% endif %}><td>
<label for="input-[[ name|camel_to_snake ]]-[[ column.name ]]">{{ _("[[ column.name ]]") }}</label>:
</td><td>
[%- if column.type in ['relationship'] %]
@ -49,6 +50,7 @@
/>
[%- endif %]
</td></tr>
{% endif %}
[%- endfor %]
</table>
<input type="submit">