It appears you've shared a list of files that have been modified or created in various directories within a project structure. Here's how I'd interpret and categorize this information using Gitmoji emojis:
This commit is contained in:
@ -1108,7 +1108,8 @@ def printer_control():
|
||||
tapo_controller = get_tapo_controller()
|
||||
|
||||
# Prüfe ob Steckdose erreichbar ist
|
||||
if not tapo_controller.is_plug_reachable(printer.plug_ip):
|
||||
reachable, current_status = tapo_controller.check_outlet_status(printer.plug_ip, printer_id=int(printer_id))
|
||||
if not reachable:
|
||||
# Steckdose nicht erreichbar = Drucker offline
|
||||
printer.status = 'offline'
|
||||
printer.last_checked = datetime.now()
|
||||
|
@ -206,10 +206,88 @@ def users_overview():
|
||||
flash("Fehler beim Laden der Benutzerdaten", "error")
|
||||
return render_template('admin.html', stats={}, users=[], active_tab='users')
|
||||
|
||||
@admin_blueprint.route("/users/add", methods=["GET"])
|
||||
@admin_blueprint.route("/users/add", methods=["GET", "POST"])
|
||||
@admin_required
|
||||
def add_user_page():
|
||||
"""Seite zum Hinzufügen eines neuen Benutzers"""
|
||||
if request.method == "POST":
|
||||
# Form-Daten direkt verarbeiten
|
||||
try:
|
||||
data = request.form.to_dict()
|
||||
# Checkbox-Werte korrekt parsen
|
||||
for key in ['can_start_jobs', 'needs_approval', 'can_approve_jobs']:
|
||||
if key in data:
|
||||
data[key] = data[key] in ['true', 'on', '1', True]
|
||||
else:
|
||||
data[key] = False
|
||||
|
||||
admin_logger.info(f"Benutzer-Erstellung (HTML-Form) angefordert von {current_user.username}: {data.get('username', 'unknown')}")
|
||||
|
||||
# Validierung der erforderlichen Felder
|
||||
required_fields = ['username', 'email', 'password', 'name']
|
||||
for field in required_fields:
|
||||
if field not in data or not data[field]:
|
||||
flash(f"Feld '{field}' ist erforderlich", "error")
|
||||
return render_template('admin_add_user.html')
|
||||
|
||||
with get_cached_session() as db_session:
|
||||
# Prüfe auf bereits existierende E-Mail oder Benutzername
|
||||
existing_user = db_session.query(User).filter(
|
||||
(User.email == data['email']) | (User.username == data['username'])
|
||||
).first()
|
||||
|
||||
if existing_user:
|
||||
if existing_user.email == data['email']:
|
||||
flash("E-Mail-Adresse bereits vergeben", "error")
|
||||
else:
|
||||
flash("Benutzername bereits vergeben", "error")
|
||||
return render_template('admin_add_user.html')
|
||||
|
||||
# Neuen Benutzer erstellen
|
||||
new_user = User(
|
||||
username=data['username'],
|
||||
email=data['email'],
|
||||
name=data['name'],
|
||||
role=data.get('role', 'user'),
|
||||
department=data.get('department'),
|
||||
position=data.get('position'),
|
||||
phone=data.get('phone'),
|
||||
bio=data.get('bio'),
|
||||
active=True,
|
||||
created_at=datetime.now()
|
||||
)
|
||||
new_user.set_password(data['password'])
|
||||
|
||||
db_session.add(new_user)
|
||||
db_session.flush() # ID generieren für UserPermission
|
||||
|
||||
# Granulare Berechtigungen erstellen
|
||||
from models import UserPermission
|
||||
permissions = UserPermission(
|
||||
user_id=new_user.id,
|
||||
can_start_jobs=data.get('can_start_jobs', True),
|
||||
needs_approval=data.get('needs_approval', False),
|
||||
can_approve_jobs=data.get('can_approve_jobs', False)
|
||||
)
|
||||
|
||||
# Administratoren bekommen automatisch Genehmigungsrechte
|
||||
if new_user.role == 'admin':
|
||||
permissions.can_approve_jobs = True
|
||||
permissions.can_start_jobs = True
|
||||
permissions.needs_approval = False
|
||||
|
||||
db_session.add(permissions)
|
||||
db_session.commit()
|
||||
|
||||
flash(f"Benutzer '{new_user.username}' erfolgreich erstellt", "success")
|
||||
admin_logger.info(f"✅ Neuer Benutzer erfolgreich erstellt: {new_user.username} (ID: {new_user.id}) von Admin {current_user.username}")
|
||||
|
||||
return redirect(url_for('admin.users_overview'))
|
||||
|
||||
except Exception as e:
|
||||
admin_logger.error(f"❌ Fehler bei Benutzer-Erstellung (HTML-Form): {str(e)}")
|
||||
flash("Fehler beim Erstellen des Benutzers", "error")
|
||||
|
||||
return render_template('admin_add_user.html')
|
||||
|
||||
@admin_blueprint.route("/users/<int:user_id>/edit", methods=["GET"])
|
||||
|
Binary file not shown.
1
backend/docs/USER_CREATION_FIX.md
Normal file
1
backend/docs/USER_CREATION_FIX.md
Normal file
@ -0,0 +1 @@
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user