The Fast Loan Kiosk provides a streamlined, authentication-free interface for rapid item checkouts. Designed for high-traffic library environments, it allows librarians to process loans in seconds using only a user’s document ID.
The fast loan route handles both user search and loan creation:
app/main/routes.py
@bp.route('/fast_loan', methods=['GET', 'POST'])def fast_loan(): search_form = FastLoanSearchForm() loan_form = FastLoanForm() user_id = request.form.get('user_id') user = None if user_id: user = User.query.get(user_id) elif search_form.validate_on_submit() and search_form.submit_search.data: user = User.query.filter_by(document_id=search_form.document_id.data).first() # Filter catalog based on user role exclude_cat = 'general' if user and user.role == 'premium' else None all_items = CatalogService.get_catalog_with_counts(exclude_category=exclude_cat) # Populate loan form choices loan_form.catalog_id.choices = [ (i.id, f"{i.title_or_name} (Disponibles: {i.available_count})") for i in all_items if i.available_count > 0 ] # User search flow if search_form.validate_on_submit() and search_form.submit_search.data: if not user: flash('Usuario no encontrado. Debes estar registrado.', 'danger') return redirect(url_for('main.fast_loan')) return render_template('main/fast_loan.html', user=user, search_form=search_form, loan_form=loan_form) # Loan creation flow if loan_form.validate_on_submit() and loan_form.submit_loan.data: user_id = loan_form.user_id.data item_type = loan_form.item_type.data environment = loan_form.environment.data catalog_id = loan_form.catalog_id.data quantity = 1 if item_type == 'computo' else loan_form.quantity.data success, reserved_ids, msg = InventoryService.reserve_instances(catalog_id, quantity) if not success: flash(msg, 'warning') return redirect(url_for('main.fast_loan')) try: for inst_id in reserved_ids: LoanService.create_loan(user_id=user_id, instance_id=inst_id, environment=environment) db.session.commit() flash('Préstamo rápido registrado con éxito.', 'success') except Exception as e: db.session.rollback() flash('Error al procesar la solicitud.', 'danger') return redirect(url_for('main.index')) return render_template('main/fast_loan.html', search_form=search_form, loan_form=loan_form)
Catalog items are automatically filtered based on the user’s role:
# Premium users cannot see 'general' category (they use premium items)exclude_cat = 'general' if user and user.role == 'premium' else Noneall_items = CatalogService.get_catalog_with_counts(exclude_category=exclude_cat)
try: for inst_id in reserved_ids: LoanService.create_loan(user_id=user_id, instance_id=inst_id, environment=environment) db.session.commit() flash('Préstamo rápido registrado con éxito.', 'success')except Exception as e: db.session.rollback() flash('Error al procesar la solicitud.', 'danger')
Setup: - Touchscreen terminal in library entrance - Simplified UI with large buttons - Security camera monitoringWorkflow: - User enters document ID manually - Reviews own information - Selects item from filtered catalog - Receives confirmation to pick up at desk
Modify which categories appear for different user roles:
# Example: Exclude multiple categories for cliente usersif user.role == 'cliente': exclude_cats = ['premium', 'computo'] all_items = [item for item in all_catalog_items if item.category not in exclude_cats]