🎉 Große Änderungen vorgenommen! Die folgenden Dateien wurden aktualisiert:
- backend/logs/admin/admin.log - backend/logs/admin_api/admin_api.log - backend/logs/api/api.log - backend/logs/app/app.log - backend/logs/auth/auth.log - backend/logs/calendar/calendar.log - backend/
This commit is contained in:
Binary file not shown.
@ -1483,6 +1483,86 @@ def generate_guest_otp_api(request_id):
|
||||
admin_logger.error(f"Fehler beim Generieren des OTP-Codes: {str(e)}")
|
||||
return jsonify({"error": "Fehler beim Generieren des OTP-Codes"}), 500
|
||||
|
||||
@admin_api_blueprint.route("/guest-requests/<int:request_id>/approve", methods=["POST"])
|
||||
@admin_required
|
||||
def approve_guest_request_api(request_id):
|
||||
"""Genehmigt eine Gastanfrage"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
approval_notes = data.get('approval_notes', '') if data else ''
|
||||
|
||||
with get_cached_session() as db_session:
|
||||
guest_request = db_session.query(GuestRequest).filter_by(id=request_id).first()
|
||||
|
||||
if not guest_request:
|
||||
return jsonify({"error": "Gastanfrage nicht gefunden"}), 404
|
||||
|
||||
if guest_request.status != 'pending':
|
||||
return jsonify({"error": "Gastanfrage ist bereits bearbeitet"}), 400
|
||||
|
||||
# Genehmigung durchführen
|
||||
guest_request.status = 'approved'
|
||||
guest_request.processed_at = datetime.now()
|
||||
guest_request.processed_by = current_user.username
|
||||
guest_request.approval_notes = approval_notes
|
||||
|
||||
# OTP-Code automatisch generieren
|
||||
otp_code = guest_request.generate_otp()
|
||||
guest_request.otp_expires_at = datetime.now() + timedelta(hours=72) # 72h gültig
|
||||
|
||||
db_session.commit()
|
||||
|
||||
admin_logger.info(f"Gastanfrage {request_id} genehmigt von Admin {current_user.name}")
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"message": "Gastanfrage erfolgreich genehmigt",
|
||||
"otp_code": otp_code,
|
||||
"expires_at": guest_request.otp_expires_at.isoformat(),
|
||||
"guest_name": guest_request.name
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
admin_logger.error(f"Fehler beim Genehmigen der Gastanfrage {request_id}: {str(e)}")
|
||||
return jsonify({"error": "Fehler beim Genehmigen der Gastanfrage"}), 500
|
||||
|
||||
@admin_api_blueprint.route("/guest-requests/<int:request_id>/reject", methods=["POST"])
|
||||
@admin_required
|
||||
def reject_guest_request_api(request_id):
|
||||
"""Lehnt eine Gastanfrage ab"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
rejection_reason = data.get('rejection_reason', 'Kein Grund angegeben') if data else 'Kein Grund angegeben'
|
||||
|
||||
with get_cached_session() as db_session:
|
||||
guest_request = db_session.query(GuestRequest).filter_by(id=request_id).first()
|
||||
|
||||
if not guest_request:
|
||||
return jsonify({"error": "Gastanfrage nicht gefunden"}), 404
|
||||
|
||||
if guest_request.status != 'pending':
|
||||
return jsonify({"error": "Gastanfrage ist bereits bearbeitet"}), 400
|
||||
|
||||
# Ablehnung durchführen
|
||||
guest_request.status = 'rejected'
|
||||
guest_request.processed_at = datetime.now()
|
||||
guest_request.processed_by = current_user.username
|
||||
guest_request.rejection_reason = rejection_reason
|
||||
|
||||
db_session.commit()
|
||||
|
||||
admin_logger.info(f"Gastanfrage {request_id} abgelehnt von Admin {current_user.name}")
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"message": "Gastanfrage erfolgreich abgelehnt",
|
||||
"guest_name": guest_request.name
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
admin_logger.error(f"Fehler beim Ablehnen der Gastanfrage {request_id}: {str(e)}")
|
||||
return jsonify({"error": "Fehler beim Ablehnen der Gastanfrage"}), 500
|
||||
|
||||
@admin_api_blueprint.route("/guest-requests/<int:request_id>/print-credentials", methods=["POST"])
|
||||
@admin_required
|
||||
def print_guest_credentials_api(request_id):
|
||||
|
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.
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