Spaces:
Running
Running
| from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, JSON | |
| from sqlalchemy.orm import relationship | |
| from datetime import datetime | |
| from app.database import Base | |
| class User(Base): | |
| __tablename__ = "users" | |
| id = Column(Integer, primary_key=True, index=True) | |
| username = Column(String, unique=True, index=True) | |
| email = Column(String, unique=True, index=True) | |
| hashed_password = Column(String) | |
| credits = Column(Integer, default=10) | |
| is_premium = Column(Boolean, default=False) | |
| avatar_url = Column(String, nullable=True) | |
| reset_token = Column(String, nullable=True) | |
| reset_token_expires = Column(DateTime, nullable=True) | |
| devices = relationship("Device", back_populates="user") | |
| tasks = relationship("Task", back_populates="user") | |
| groups = relationship("UserGroup", back_populates="user") | |
| credit_transactions = relationship("CreditTransaction", back_populates="user", cascade="all, delete-orphan") | |
| class Device(Base): | |
| __tablename__ = "devices" | |
| id = Column(Integer, primary_key=True, index=True) | |
| user_id = Column(Integer, ForeignKey("users.id")) | |
| device_id = Column(String, index=True) | |
| name = Column(String) | |
| registered_at = Column(DateTime, default=datetime.utcnow) | |
| last_active = Column(DateTime, default=datetime.utcnow) | |
| user = relationship("User", back_populates="devices") | |
| class CreditTransaction(Base): | |
| __tablename__ = "credit_transactions" | |
| id = Column(Integer, primary_key=True, index=True) | |
| user_id = Column(Integer, ForeignKey("users.id")) | |
| amount = Column(Integer) | |
| concept = Column(String) | |
| reference_id = Column(String, nullable=True) | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| user = relationship("User", back_populates="credit_transactions") | |
| class SystemNotification(Base): | |
| __tablename__ = "system_notifications" | |
| id = Column(Integer, primary_key=True, index=True) | |
| title = Column(String, index=True) | |
| message = Column(String) | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| class AdminUser(Base): | |
| __tablename__ = "admin_users" | |
| id = Column(Integer, primary_key=True, index=True) | |
| username = Column(String, unique=True, index=True) | |
| hashed_password = Column(String) | |
| avatar_url = Column(String, nullable=True) | |
| perm_users = Column(Boolean, default=True) | |
| perm_workers = Column(Boolean, default=True) | |
| perm_churches = Column(Boolean, default=True) | |
| perm_groups = Column(Boolean, default=True) | |
| perm_notifications = Column(Boolean, default=True) | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| class AdminNotification(Base): | |
| __tablename__ = "admin_notifications" | |
| id = Column(Integer, primary_key=True, index=True) | |
| title = Column(String, index=True) | |
| message = Column(String) | |
| created_at = Column(DateTime, default=datetime.utcnow) | |
| read = Column(Boolean, default=False) | |
| class LandingFeature(Base): | |
| __tablename__ = "landing_features" | |
| id = Column(Integer, primary_key=True, index=True) | |
| icon_svg = Column(String, nullable=True) | |
| icon_color = Column(String, default="cyan") # cyan | purple | green | blue | yellow | red | |
| title = Column(String) | |
| description = Column(String) | |
| order = Column(Integer, default=0) | |
| class LandingPlatform(Base): | |
| __tablename__ = "landing_platforms" | |
| id = Column(Integer, primary_key=True, index=True) | |
| name = Column(String, nullable=False) | |
| version = Column(String, nullable=True) | |
| os_details = Column(String, nullable=True) | |
| description = Column(String, nullable=True) | |
| download_url = Column(String, nullable=True) | |
| button_text = Column(String, nullable=True) | |
| os_type = Column(String, default="windows") # windows | android | apple | |
| is_visible = Column(Boolean, default=True) | |
| order = Column(Integer, default=0) | |
| class LandingTutorial(Base): | |
| __tablename__ = "landing_tutorials" | |
| id = Column(Integer, primary_key=True, index=True) | |
| title = Column(String, nullable=False) | |
| desc = Column(String, nullable=True) | |
| steps = Column(JSON, default=[]) # list of strings | |
| order = Column(Integer, default=0) | |
| class LandingGalleryItem(Base): | |
| __tablename__ = "landing_gallery" | |
| id = Column(Integer, primary_key=True, index=True) | |
| image_url = Column(String, nullable=False) | |
| caption = Column(String, nullable=True) | |
| order = Column(Integer, default=0) | |