Merge website-branding feature and adjust for compatibility

- Resolved conflicts in models.py, app.py, and template files
- Added branding checks to prevent errors when g.branding is None
- Updated all template references to use conditional branding
- Added BrandingSettings to migrations
- Created branding uploads directory
- Integrated branding with existing comment and task management features
This commit is contained in:
2025-07-06 16:58:29 +02:00
14 changed files with 466 additions and 35 deletions

View File

@@ -16,7 +16,8 @@ try:
from models import (User, TimeEntry, WorkConfig, SystemSettings, Team, Role, Project,
Company, CompanyWorkConfig, CompanySettings, UserPreferences, WorkRegion, AccountType,
ProjectCategory, Task, SubTask, TaskStatus, TaskPriority, Announcement, SystemEvent,
WidgetType, UserDashboard, DashboardWidget, WidgetTemplate, Comment, CommentVisibility)
WidgetType, UserDashboard, DashboardWidget, WidgetTemplate, Comment, CommentVisibility,
BrandingSettings)
from werkzeug.security import generate_password_hash
FLASK_AVAILABLE = True
except ImportError:
@@ -327,6 +328,25 @@ def create_missing_tables(cursor):
)
""")
# Branding Settings table
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='branding_settings'")
if not cursor.fetchone():
print("Creating branding_settings table...")
cursor.execute("""
CREATE TABLE branding_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
app_name VARCHAR(100) NOT NULL DEFAULT 'Time Tracker',
logo_filename VARCHAR(255),
logo_alt_text VARCHAR(255) DEFAULT 'Logo',
favicon_filename VARCHAR(255),
primary_color VARCHAR(7) DEFAULT '#007bff',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_by_id INTEGER,
FOREIGN KEY (updated_by_id) REFERENCES user (id)
)
""")
def migrate_to_company_model(db_path):
"""Migrate to company-based multi-tenancy model."""
@@ -1199,6 +1219,31 @@ def migrate_postgresql_schema():
db.session.execute(text("CREATE INDEX idx_comment_created_at ON comment(created_at DESC)"))
db.session.commit()
# Check if branding_settings table exists
result = db.session.execute(text("""
SELECT table_name
FROM information_schema.tables
WHERE table_name = 'branding_settings'
"""))
if not result.fetchone():
print("Creating branding_settings table...")
db.session.execute(text("""
CREATE TABLE branding_settings (
id SERIAL PRIMARY KEY,
app_name VARCHAR(100) NOT NULL DEFAULT 'Time Tracker',
logo_filename VARCHAR(255),
logo_alt_text VARCHAR(255) DEFAULT 'Logo',
favicon_filename VARCHAR(255),
primary_color VARCHAR(7) DEFAULT '#007bff',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_by_id INTEGER,
FOREIGN KEY (updated_by_id) REFERENCES "user" (id)
)
"""))
db.session.commit()
# Check if company_settings table exists
result = db.session.execute(text("""
SELECT table_name