Fixed create.py and update.html
This commit is contained in:
parent
1a271f465a
commit
200810d793
@ -17,7 +17,7 @@ def create():
|
||||
try:
|
||||
primary_attr = next((attrib_name for attrib_name, attrib in item_attributes.items() if attrib.primary), None)
|
||||
except ValueError:
|
||||
return render_template('create.html', exc=primary_attr)
|
||||
return render_template('create.html', item_attributes=item_attributes, exc=primary_attr)
|
||||
|
||||
item = Asset(**form_data)
|
||||
|
||||
@ -25,8 +25,8 @@ def create():
|
||||
db.session.add(item)
|
||||
db.session.commit()
|
||||
except exc.IntegrityError:
|
||||
return render_template('create.html', exc='integrity')
|
||||
return render_template('create.html', item_attributes=item_attributes, exc='integrity')
|
||||
except exc.StatementError:
|
||||
return render_template('create.html', exc='status')
|
||||
return render_template('create.html', item_attributes=item_attributes, exc='status')
|
||||
|
||||
return redirect('/viewall')
|
@ -18,7 +18,7 @@
|
||||
{%- if properties.required %} required {% endif -%}
|
||||
>
|
||||
{% for option in properties.options -%}
|
||||
<option value="{{ option }}">{{ option }}</option>
|
||||
<option value="{{ option }}" {% if item[attrib] == option %}selected{% endif %}>{{ option }}</option>
|
||||
{% endfor -%}
|
||||
</select>
|
||||
{% else %}
|
||||
@ -29,7 +29,7 @@
|
||||
{%- if properties.required %} required {% endif -%}
|
||||
{%- if properties.min is not none %} min="{{ properties.min }}" {% endif -%}
|
||||
{%- if properties.max is not none %} max="{{ properties.max }}" {% endif -%}
|
||||
{%- if item.attrib %} value="{{ item.attrib }}" {% endif -%}
|
||||
{%- if item[attrib] %} value="{{ item[attrib] }}" {% endif -%}
|
||||
/>
|
||||
{% endif -%}
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user