Add dark mode support and replace group assignment with playlist assignment
- Added comprehensive dark mode styling to all pages: * Dashboard (workflow guide, secondary text, log items) * Admin panel with user management system * Content/playlist management page * Upload media page * Add player page - Implemented user management system: * Create/edit/delete users * Two role types (user/admin) * Reset password functionality * Role-based permissions - Replaced group assignment with playlist assignment: * Players now directly assigned to playlists * Updated add player form and backend * Removed group selection from player creation - Fixed bugs: * Updated instance_path configuration for SQLite * Fixed import path in app factory * Updated dependencies (Pillow 11.0.0, removed gevent) - Added start.sh script for easy development server launch
This commit is contained in:
@@ -267,6 +267,55 @@ def clear_logs():
|
||||
return redirect(url_for('admin.admin_panel'))
|
||||
|
||||
|
||||
@admin_bp.route('/users')
|
||||
@login_required
|
||||
@admin_required
|
||||
def user_management():
|
||||
"""Display user management page."""
|
||||
try:
|
||||
users = User.query.order_by(User.created_at.desc()).all()
|
||||
return render_template('admin/user_management.html', users=users)
|
||||
except Exception as e:
|
||||
log_action('error', f'Error loading user management: {str(e)}')
|
||||
flash('Error loading user management page.', 'danger')
|
||||
return redirect(url_for('admin.admin_panel'))
|
||||
|
||||
|
||||
@admin_bp.route('/user/<int:user_id>/password', methods=['POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def reset_user_password(user_id: int):
|
||||
"""Reset user password."""
|
||||
try:
|
||||
user = User.query.get_or_404(user_id)
|
||||
new_password = request.form.get('password', '').strip()
|
||||
|
||||
# Validation
|
||||
if not new_password or len(new_password) < 6:
|
||||
flash('Password must be at least 6 characters long.', 'warning')
|
||||
return redirect(url_for('admin.user_management'))
|
||||
|
||||
# Prevent changing own password through this route
|
||||
if user.id == current_user.id:
|
||||
flash('Use the change password option to update your own password.', 'warning')
|
||||
return redirect(url_for('admin.user_management'))
|
||||
|
||||
# Update password
|
||||
hashed_password = bcrypt.generate_password_hash(new_password).decode('utf-8')
|
||||
user.password = hashed_password
|
||||
db.session.commit()
|
||||
|
||||
log_action('info', f'Password reset for user {user.username} by admin {current_user.username}')
|
||||
flash(f'Password reset successfully for user "{user.username}".', 'success')
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
log_action('error', f'Error resetting password: {str(e)}')
|
||||
flash('Error resetting password. Please try again.', 'danger')
|
||||
|
||||
return redirect(url_for('admin.user_management'))
|
||||
|
||||
|
||||
@admin_bp.route('/system/info')
|
||||
@login_required
|
||||
@admin_required
|
||||
|
||||
@@ -43,7 +43,8 @@ def list():
|
||||
def add_player():
|
||||
"""Add a new player."""
|
||||
if request.method == 'GET':
|
||||
return render_template('players/add_player.html')
|
||||
playlists = Playlist.query.filter_by(is_active=True).order_by(Playlist.name).all()
|
||||
return render_template('players/add_player.html', playlists=playlists)
|
||||
|
||||
try:
|
||||
name = request.form.get('name', '').strip()
|
||||
@@ -52,6 +53,7 @@ def add_player():
|
||||
password = request.form.get('password', '').strip()
|
||||
quickconnect_code = request.form.get('quickconnect_code', '').strip()
|
||||
orientation = request.form.get('orientation', 'Landscape')
|
||||
playlist_id = request.form.get('playlist_id', '').strip()
|
||||
|
||||
# Validation
|
||||
if not name or len(name) < 3:
|
||||
@@ -81,7 +83,8 @@ def add_player():
|
||||
hostname=hostname,
|
||||
location=location or None,
|
||||
auth_code=auth_code,
|
||||
orientation=orientation
|
||||
orientation=orientation,
|
||||
playlist_id=int(playlist_id) if playlist_id else None
|
||||
)
|
||||
|
||||
# Set password if provided
|
||||
|
||||
Reference in New Issue
Block a user