diff --git a/src/app/routes/admin.py b/src/app/routes/admin.py index 998d595..0fd72bb 100644 --- a/src/app/routes/admin.py +++ b/src/app/routes/admin.py @@ -57,9 +57,23 @@ def dashboard(): def users(): try: page = request.args.get('page', 1, type=int) + search = request.args.get('search', '').strip() per_page = 20 - users = User.query.order_by(User.created_at.desc()).paginate( + # Build query with search functionality + query = User.query + + if search: + # Search by username or email (case-insensitive) + search_filter = f"%{search.lower()}%" + query = query.filter( + db.or_( + User.username.ilike(search_filter), + User.email.ilike(search_filter) + ) + ) + + users = query.order_by(User.created_at.desc()).paginate( page=page, per_page=per_page, error_out=False ) @@ -229,7 +243,7 @@ def delete_quotation(): if not request.is_json: return jsonify({'error': 'Invalid request format'}), 400 - data = request.get_json() + data = request.get_json() quotation_id = data.get('quotation_id') if not quotation_id: diff --git a/src/app/templates/admin/user_detail.html b/src/app/templates/admin/user_detail.html index 0519ecb..88678c0 100644 --- a/src/app/templates/admin/user_detail.html +++ b/src/app/templates/admin/user_detail.html @@ -1 +1,276 @@ - \ No newline at end of file +{% extends "admin/base.html" %} + +{% block title %}User Details - {{ user.username }} - Admin Panel{% endblock %} + +{% block content %} +
| ID | +Project Name | +Mold Type | +Country | +Total Cost | +Created | +Actions | +
|---|---|---|---|---|---|---|
| + #{{ quotation.id }} + | ++ {{ quotation.project_name or 'Unnamed Project' }} + | ++ {{ quotation.mold_main_type or 'Not specified' }} + | ++ {{ quotation.mold_shop_country or 'Not specified' }} + | ++ + ${{ "{:,.2f}".format(quotation.total_cost) if quotation.total_cost else 'N/A' }} + + | ++ + {{ quotation.created_at.strftime('%m/%d/%Y %H:%M') }} + + | ++ + + + | +
This user hasn't created any quotations yet.
+