test fix
Browse files- app/__init__.py +45 -35
- app/models/__init__.py +37 -1
- app/models/google_ad.py +0 -0
- app/routes/auth.py +1 -0
app/__init__.py
CHANGED
|
@@ -67,46 +67,56 @@ def create_app(config_class=None):
|
|
| 67 |
|
| 68 |
# Register test blueprint first (this should always work)
|
| 69 |
logger.info("Registering test blueprint...")
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
# Register other blueprints
|
| 74 |
logger.info("Registering other blueprints...")
|
|
|
|
|
|
|
| 75 |
try:
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
logger.info("Importing dashboard blueprint...")
|
| 81 |
-
from .routes.dashboard import dashboard_bp
|
| 82 |
-
|
| 83 |
-
logger.info("Importing API blueprint...")
|
| 84 |
-
from .routes.api import api_bp
|
| 85 |
-
|
| 86 |
-
logger.info("Importing compliance blueprint...")
|
| 87 |
-
from .routes.compliance import compliance_bp
|
| 88 |
-
|
| 89 |
-
logger.info("Importing Google Ads blueprint...")
|
| 90 |
-
from .routes.google_ads import google_ads_bp
|
| 91 |
-
|
| 92 |
-
logger.info("Registering auth blueprint...")
|
| 93 |
-
app.register_blueprint(auth_bp)
|
| 94 |
-
|
| 95 |
-
logger.info("Registering dashboard blueprint...")
|
| 96 |
-
app.register_blueprint(dashboard_bp)
|
| 97 |
-
|
| 98 |
-
logger.info("Registering API blueprint...")
|
| 99 |
-
app.register_blueprint(api_bp)
|
| 100 |
-
|
| 101 |
-
logger.info("Registering compliance blueprint...")
|
| 102 |
-
app.register_blueprint(compliance_bp)
|
| 103 |
-
|
| 104 |
-
logger.info("Registering Google Ads blueprint...")
|
| 105 |
-
app.register_blueprint(google_ads_bp)
|
| 106 |
except Exception as e:
|
| 107 |
-
logger.error(f"Error registering
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# Add a simple route directly to the app
|
| 112 |
@app.route('/')
|
|
|
|
| 67 |
|
| 68 |
# Register test blueprint first (this should always work)
|
| 69 |
logger.info("Registering test blueprint...")
|
| 70 |
+
try:
|
| 71 |
+
from .routes.test import test_bp
|
| 72 |
+
app.register_blueprint(test_bp)
|
| 73 |
+
logger.info("Test blueprint registered successfully")
|
| 74 |
+
except Exception as e:
|
| 75 |
+
logger.error(f"Error registering test blueprint: {e}")
|
| 76 |
|
| 77 |
# Register other blueprints
|
| 78 |
logger.info("Registering other blueprints...")
|
| 79 |
+
|
| 80 |
+
# Try to register each blueprint individually
|
| 81 |
try:
|
| 82 |
+
logger.info("Importing and registering dashboard blueprint...")
|
| 83 |
+
from .routes.dashboard import dashboard_bp
|
| 84 |
+
app.register_blueprint(dashboard_bp)
|
| 85 |
+
logger.info("Dashboard blueprint registered successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
except Exception as e:
|
| 87 |
+
logger.error(f"Error registering dashboard blueprint: {e}")
|
| 88 |
+
|
| 89 |
+
try:
|
| 90 |
+
logger.info("Importing and registering API blueprint...")
|
| 91 |
+
from .routes.api import api_bp
|
| 92 |
+
app.register_blueprint(api_bp)
|
| 93 |
+
logger.info("API blueprint registered successfully")
|
| 94 |
+
except Exception as e:
|
| 95 |
+
logger.error(f"Error registering API blueprint: {e}")
|
| 96 |
+
|
| 97 |
+
try:
|
| 98 |
+
logger.info("Importing and registering compliance blueprint...")
|
| 99 |
+
from .routes.compliance import compliance_bp
|
| 100 |
+
app.register_blueprint(compliance_bp)
|
| 101 |
+
logger.info("Compliance blueprint registered successfully")
|
| 102 |
+
except Exception as e:
|
| 103 |
+
logger.error(f"Error registering compliance blueprint: {e}")
|
| 104 |
+
|
| 105 |
+
try:
|
| 106 |
+
logger.info("Importing and registering Google Ads blueprint...")
|
| 107 |
+
from .routes.google_ads import google_ads_bp
|
| 108 |
+
app.register_blueprint(google_ads_bp)
|
| 109 |
+
logger.info("Google Ads blueprint registered successfully")
|
| 110 |
+
except Exception as e:
|
| 111 |
+
logger.error(f"Error registering Google Ads blueprint: {e}")
|
| 112 |
+
|
| 113 |
+
try:
|
| 114 |
+
logger.info("Importing and registering auth blueprint...")
|
| 115 |
+
from .routes.auth import auth_bp
|
| 116 |
+
app.register_blueprint(auth_bp)
|
| 117 |
+
logger.info("Auth blueprint registered successfully")
|
| 118 |
+
except Exception as e:
|
| 119 |
+
logger.error(f"Error registering auth blueprint: {e}")
|
| 120 |
|
| 121 |
# Add a simple route directly to the app
|
| 122 |
@app.route('/')
|
app/models/__init__.py
CHANGED
|
@@ -1,2 +1,38 @@
|
|
| 1 |
# app/models/__init__.py
|
| 2 |
-
# This file makes the models directory a Python package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# app/models/__init__.py
|
| 2 |
+
# This file makes the models directory a Python package
|
| 3 |
+
|
| 4 |
+
from app import db
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
from flask_login import UserMixin
|
| 7 |
+
from werkzeug.security import generate_password_hash, check_password_hash
|
| 8 |
+
|
| 9 |
+
class User(UserMixin, db.Model):
|
| 10 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 11 |
+
email = db.Column(db.String(120), unique=True, nullable=False)
|
| 12 |
+
password = db.Column(db.String(128), nullable=False)
|
| 13 |
+
role = db.Column(db.String(20), default="viewer")
|
| 14 |
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
| 15 |
+
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
| 16 |
+
|
| 17 |
+
def __repr__(self):
|
| 18 |
+
return f'<User {self.email}>'
|
| 19 |
+
|
| 20 |
+
def set_password(self, password):
|
| 21 |
+
self.password = generate_password_hash(password)
|
| 22 |
+
|
| 23 |
+
def check_password(self, password):
|
| 24 |
+
return check_password_hash(self.password, password)
|
| 25 |
+
|
| 26 |
+
class Ad(db.Model):
|
| 27 |
+
id = db.Column(db.String(36), primary_key=True)
|
| 28 |
+
content = db.Column(db.Text)
|
| 29 |
+
sentiment = db.Column(db.JSON)
|
| 30 |
+
ad_metadata = db.Column(db.JSON)
|
| 31 |
+
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
| 32 |
+
versions = db.relationship('AdVersion', backref='ad')
|
| 33 |
+
|
| 34 |
+
class AdVersion(db.Model):
|
| 35 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 36 |
+
ad_id = db.Column(db.String(36), db.ForeignKey('ad.id'))
|
| 37 |
+
content = db.Column(db.Text)
|
| 38 |
+
timestamp = db.Column(db.DateTime, default=datetime.utcnow)
|
app/models/google_ad.py
CHANGED
|
Binary files a/app/models/google_ad.py and b/app/models/google_ad.py differ
|
|
|
app/routes/auth.py
CHANGED
|
@@ -2,6 +2,7 @@ from flask import Blueprint, render_template, redirect, url_for, flash
|
|
| 2 |
from flask_login import login_user, logout_user, login_required
|
| 3 |
from ..models import User
|
| 4 |
from ..forms import LoginForm, RegistrationForm
|
|
|
|
| 5 |
|
| 6 |
auth_bp = Blueprint('auth', __name__)
|
| 7 |
|
|
|
|
| 2 |
from flask_login import login_user, logout_user, login_required
|
| 3 |
from ..models import User
|
| 4 |
from ..forms import LoginForm, RegistrationForm
|
| 5 |
+
from app import db
|
| 6 |
|
| 7 |
auth_bp = Blueprint('auth', __name__)
|
| 8 |
|