04/28 Updated sprint 4 & 5
This commit is contained in:
+22
-8
@@ -6,7 +6,7 @@ QR code management and destination handler routes.
|
||||
Routes: /qr-codes/create, /qr-codes/bulk-import, /qr-codes/<id>/*,
|
||||
/qr/<string:qr_url>
|
||||
"""
|
||||
from flask import Blueprint, render_template, request, redirect, flash, session, jsonify, send_file, current_app, url_for
|
||||
from flask import abort, Blueprint, render_template, request, redirect, flash, session, jsonify, send_file, current_app, url_for
|
||||
from datetime import datetime, date, timedelta, time
|
||||
import io, os, base64, re, uuid, json, traceback
|
||||
|
||||
@@ -435,7 +435,9 @@ def download_qr_import_template():
|
||||
def edit_qr_code(qr_id):
|
||||
"""Enhanced edit QR code with customization support"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
|
||||
if request.method == 'POST':
|
||||
# Track changes for logging
|
||||
@@ -578,7 +580,9 @@ def edit_qr_code(qr_id):
|
||||
def delete_qr_code(qr_id):
|
||||
"""Permanently delete QR code (Admin only) - Hard delete - PRESERVING EXACT ROUTE"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
logger_handler.logger.debug(f"Found QR Code for delete: {qr_code.name} (ID: {qr_id})")
|
||||
|
||||
if request.method == 'POST':
|
||||
@@ -1092,7 +1096,9 @@ def qr_get_locations(qr_url):
|
||||
def toggle_qr_status(qr_id):
|
||||
"""Toggle QR code active/inactive status"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
|
||||
# Toggle the status
|
||||
qr_code.active_status = not qr_code.active_status
|
||||
@@ -1121,7 +1127,9 @@ def toggle_qr_status(qr_id):
|
||||
def copy_qr_url(qr_id):
|
||||
"""Log QR code URL copy action"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
|
||||
# Log URL copy action
|
||||
logger_handler.logger.info(f"User {session.get('username', 'unknown')} copied URL for QR code {qr_code.name} (ID: {qr_id})")
|
||||
@@ -1144,7 +1152,9 @@ def copy_qr_url(qr_id):
|
||||
def open_qr_link(qr_id):
|
||||
"""Log QR code link open action"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
|
||||
# Log link open action
|
||||
logger_handler.logger.info(f"User {session.get('username', 'unknown')} opened link for QR code {qr_code.name} (ID: {qr_id})")
|
||||
@@ -1167,7 +1177,9 @@ def open_qr_link(qr_id):
|
||||
def activate_qr_code(qr_id):
|
||||
"""Activate a QR code"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
qr_code.active_status = True
|
||||
db.session.commit()
|
||||
|
||||
@@ -1192,7 +1204,9 @@ def activate_qr_code(qr_id):
|
||||
def deactivate_qr_code(qr_id):
|
||||
"""Deactivate a QR code"""
|
||||
try:
|
||||
qr_code = QRCode.query.get_or_404(qr_id)
|
||||
qr_code = db.session.get(QRCode, qr_id)
|
||||
if qr_code is None:
|
||||
abort(404)
|
||||
qr_code.active_status = False
|
||||
db.session.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user