Bloqueo catalogo OEM hasta completarse

This commit is contained in:
Nexus Dev
2026-04-27 05:41:35 +00:00
parent 9ff3dc4c8b
commit 142abbc217
5 changed files with 90 additions and 2 deletions

View File

@@ -19,10 +19,22 @@ from tenant_db import get_master_conn, get_tenant_conn
from services import catalog_service
from services.vin_decoder import decode_vin
from services.plate_lookup import search_plate, register_plate, is_valid_mexican_plate, normalize_plate
from config import CATALOG_OEM_ENABLED
catalog_bp = Blueprint('catalog', __name__, url_prefix='/pos/api/catalog')
def _oem_blocked():
"""Return a 403 response if OEM catalog is disabled."""
if not CATALOG_OEM_ENABLED:
return jsonify({
'error': 'Catálogo OEM no disponible',
'message': 'El catálogo OEM está en construcción. Por favor usa el modo Local o Shop Supplies.',
'oem_disabled': True,
}), 403
return None
def _with_conns(fn):
"""Helper: open master + tenant connections, call fn, close both.
fn receives (master_conn, tenant_conn, branch_id).
@@ -298,6 +310,12 @@ def parts():
if not use_nexpart_nav and not group_id:
return jsonify({'error': 'group_id (or nexpart_group + subgroup + part_type) required'}), 400
# Block OEM catalog if not enabled
if mode != 'local' and not use_nexpart_nav:
blocked = _oem_blocked()
if blocked:
return blocked
def _do(master, tenant, branch_id):
if use_nexpart_nav:
result = catalog_service.get_parts_for_nexpart_triple(
@@ -319,6 +337,9 @@ def parts():
@catalog_bp.route('/part/<int:part_id>', methods=['GET'])
@require_auth('catalog.view')
def part_detail(part_id):
blocked = _oem_blocked()
if blocked:
return blocked
def _do(master, tenant, branch_id):
result = catalog_service.get_part_detail(master, part_id, tenant, branch_id)
if not result:
@@ -330,6 +351,9 @@ def part_detail(part_id):
@catalog_bp.route('/search', methods=['GET'])
@require_auth('catalog.view')
def search():
blocked = _oem_blocked()
if blocked:
return blocked
q = request.args.get('q', '').strip()
if not q or len(q) < 2:
return jsonify({'data': []})