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 %} +
+

+ + User Details: {{ user.username }} +

+ + Back to Users + +
+ + +
+
+
+ + User Information +
+
+
+
+
+
+ + #{{ user.id }} +
+
+ + {{ user.username }} +
+
+ + {{ user.email }} +
+
+ + {{ user.company if user.company else 'Not specified' }} +
+
+
+
+ + + + {{ 'Active' if user.is_active else 'Inactive' }} + +
+
+ + + + {{ 'Admin' if user.is_admin else 'User' }} + +
+
+ + + {{ user.last_login.strftime('%B %d, %Y at %H:%M') if user.last_login else 'Never' }} + +
+
+ + {{ user.created_at.strftime('%B %d, %Y at %H:%M') }} +
+
+
+
+
+ + +
+
+
+ + User Actions +
+
+
+
+ + {% if user.id != current_user.id %} + + {% endif %} +
+
+
+ + +
+
+
+ + Quotation History ({{ quotations|length }} total) +
+
+
+ {% if quotations %} +
+ + + + + + + + + + + + + + {% for quotation in quotations %} + + + + + + + + + + {% endfor %} + +
IDProject NameMold TypeCountryTotal CostCreatedActions
+ #{{ 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') }} + + + + + +
+
+ {% else %} +
+ +
No quotations found
+

This user hasn't created any quotations yet.

+
+ {% endif %} +
+
+{% endblock %} + +{% block scripts %} +{{ super() }} + +{% endblock %} + +{% block styles %} +{{ super() }} + +{% endblock %} \ No newline at end of file diff --git a/src/app/templates/admin/users.html b/src/app/templates/admin/users.html index 7977fe7..2cd0f97 100644 --- a/src/app/templates/admin/users.html +++ b/src/app/templates/admin/users.html @@ -85,21 +85,27 @@
+ title="View User Details" + data-bs-toggle="tooltip"> + View {% if user.id != current_user.id %} {% endif %}
@@ -164,6 +170,14 @@ {% block scripts %} {{ super() }}