feat: dropdown filtra marcas y modelos por ano seleccionado

Al seleccionar ano, solo muestra marcas/modelos disponibles para ese ano.
Toyota 2020: 92 modelos vs 625 sin filtro.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-02 08:06:34 +00:00
parent 67e214db15
commit 10e318bfd7
4 changed files with 69 additions and 29 deletions

View File

@@ -62,8 +62,9 @@ def _master_only(fn):
@catalog_bp.route('/brands', methods=['GET'])
@require_auth('catalog.view')
def brands():
year_id = request.args.get('year_id', type=int)
def _do(master):
data = catalog_service.get_brands(master)
data = catalog_service.get_brands(master, year_id=year_id)
return jsonify({'data': data})
return _master_only(_do)
@@ -72,10 +73,11 @@ def brands():
@require_auth('catalog.view')
def models():
brand_id = request.args.get('brand_id', type=int)
year_id = request.args.get('year_id', type=int)
if not brand_id:
return jsonify({'error': 'brand_id required'}), 400
def _do(master):
data = catalog_service.get_models(master, brand_id)
data = catalog_service.get_models(master, brand_id, year_id=year_id)
return jsonify({'data': data})
return _master_only(_do)