Fixed create.py and update.html

This commit is contained in:
Candifloss 2025-02-07 23:50:26 +05:30
parent 1a271f465a
commit 200810d793
2 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ def create():
try: try:
primary_attr = next((attrib_name for attrib_name, attrib in item_attributes.items() if attrib.primary), None) primary_attr = next((attrib_name for attrib_name, attrib in item_attributes.items() if attrib.primary), None)
except ValueError: 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) item = Asset(**form_data)
@ -25,8 +25,8 @@ def create():
db.session.add(item) db.session.add(item)
db.session.commit() db.session.commit()
except exc.IntegrityError: except exc.IntegrityError:
return render_template('create.html', exc='integrity') return render_template('create.html', item_attributes=item_attributes, exc='integrity')
except exc.StatementError: except exc.StatementError:
return render_template('create.html', exc='status') return render_template('create.html', item_attributes=item_attributes, exc='status')
return redirect('/viewall') return redirect('/viewall')

View File

@ -18,7 +18,7 @@
{%- if properties.required %} required {% endif -%} {%- if properties.required %} required {% endif -%}
> >
{% for option in properties.options -%} {% for option in properties.options -%}
<option value="{{ option }}">{{ option }}</option> <option value="{{ option }}" {% if item[attrib] == option %}selected{% endif %}>{{ option }}</option>
{% endfor -%} {% endfor -%}
</select> </select>
{% else %} {% else %}
@ -29,7 +29,7 @@
{%- if properties.required %} required {% endif -%} {%- if properties.required %} required {% endif -%}
{%- if properties.min is not none %} min="{{ properties.min }}" {% endif -%} {%- if properties.min is not none %} min="{{ properties.min }}" {% endif -%}
{%- if properties.max is not none %} max="{{ properties.max }}" {% 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 -%} {% endif -%}
</p> </p>