new radius server

This commit is contained in:
2025-04-01 17:43:52 -04:00
parent 9d4b21b5ae
commit 1482643261
13 changed files with 174 additions and 10 deletions

Binary file not shown.

View File

@@ -5,7 +5,7 @@ from views.group_views import group
from config import app_config as config_class
from database import init_app
import logging, os
import logging, os, pytz
from logging.handlers import RotatingFileHandler
# Instantiate config class
@@ -13,8 +13,11 @@ app_config = config_class()
app = Flask(__name__)
app.config.from_object(app_config)
app.config['TZ'] = pytz.timezone(app.config['APP_TIMEZONE'])
init_app(app)
app.config['TZ'] = pytz.timezone(app.config['APP_TIMEZONE'])
# Logging
if app.config.get('LOG_TO_FILE'):
log_file = app.config.get('LOG_FILE_PATH', '/app/logs/app.log')

View File

@@ -17,8 +17,8 @@ class Config:
OUI_API_DAILY_LIMIT = int(os.getenv('OUI_API_DAILY_LIMIT', '10000'))
# These get set in __init__
APP_TIMEZONE = 'UTC'
TZ = pytz.utc
APP_TIMEZONE = os.getenv('APP_TIMEZONE', 'UTC')
TZ = pytz.timezone(APP_TIMEZONE)
def __init__(self):
tz_name = os.getenv('APP_TIMEZONE', 'UTC')

View File

@@ -1,4 +1,4 @@
from flask import Blueprint, render_template, request, jsonify
from flask import Blueprint, render_template, request, jsonify, current_app
from database import get_db
from datetime import datetime
import requests, pytz
@@ -13,14 +13,14 @@ def time_ago(dt):
if not dt:
return "n/a"
tz_name = current_app.config.get('APP_TIMEZONE', 'UTC')
local_tz = current_app.config.get('TZ', pytz.utc)
# Only assign UTC tzinfo if naive
# If the DB datetime is naive, assume it's already in local server time
if dt.tzinfo is None:
dt = dt.replace(tzinfo=pytz.utc)
server_tz = pytz.timezone('America/Toronto') # Or your DB server's real timezone
dt = server_tz.localize(dt)
# Convert to app timezone
# Convert to the app's configured timezone (from .env)
dt = dt.astimezone(local_tz)
now = datetime.now(local_tz)
diff = now - dt