Adding settings page.

This commit is contained in:
Yaro Kasear 2025-10-10 16:26:22 -05:00
parent 69a6e7fb2e
commit 775600e140
3 changed files with 58 additions and 0 deletions

View file

@ -20,6 +20,7 @@ from .routes.entry import init_entry_routes
from .routes.index import init_index_routes
from .routes.listing import init_listing_routes
from .routes.search import init_search_routes
from .routes.settings import init_settings_routes
def create_app(config_cls=crudkit.DevConfig) -> Flask:
app = Flask(__name__)
@ -79,6 +80,7 @@ def create_app(config_cls=crudkit.DevConfig) -> Flask:
init_index_routes(app)
init_listing_routes(app)
init_search_routes(app)
init_settings_routes(app)
@app.teardown_appcontext
def _remove_session(_exc):

View file

@ -0,0 +1,22 @@
from flask import Blueprint, render_template
import crudkit
from crudkit.ui.fragments import render_form
bp_settings = Blueprint("settings", __name__)
def init_settings_routes(app):
@bp_settings.get('/settings')
def settings():
brand_model = crudkit.crud.get_model('brand')
brand_service = crudkit.crud.get_service(brand_model)
device_type_model = crudkit.crud.get_model('devicetype')
device_type_service = crudkit.crud.get_service(device_type_model)
brands = brand_service.list({"sort": "name", "limit": 0})
device_types = device_type_service.list({"sort": "description", "limit": 0})
return render_template("settings.html", brands=brands, device_types=device_types)
app.register_blueprint(bp_settings)

View file

@ -0,0 +1,34 @@
{% extends 'base.html' %}
{% block main %}
<form id="settings_form" action="POST">
<div class="container">
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active">Devices</a>
</li>
<li class="nav-item">
<a class="nav-link">Locations</a>
</li>
</ul>
<div class="row">
<div class="col">
<input type="text" class="form-control border-bottom-0 rounded-bottom-0" placeholder="Enter the name of a brand.">
<select name="brands" id="brands" size="10" class="form-control rounded-top-0">
{% for brand in brands %}
<option value="{{ brand.id }}">{{ brand.name }}</option>
{% endfor %}
</select>
</div>
<div class="col">
<input type="text" class="form-control border-bottom-0 rounded-bottom-0" placeholder="Enter the description of a device type.">
<select name="device_types" id="device_types" size="10" class="form-control rounded-top-0">
{% for device_type in device_types %}
<option value="{{ device_type.id }}">{{ device_type.description }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</form>
{% endblock %}