Files
digiserver-v2/app/models/group.py
ske087 498c03ef00 Replace emoji icons with local SVG files for consistent rendering
- Created 10 SVG icon files in app/static/icons/ (Feather Icons style)
- Updated base.html with SVG icons in navigation and dark mode toggle
- Updated dashboard.html with icons in stats cards and quick actions
- Updated content_list_new.html (playlist management) with SVG icons
- Updated upload_media.html with upload-related icons
- Updated manage_player.html with player management icons
- Icons use currentColor for automatic theme adaptation
- Removed emoji dependency for better Raspberry Pi compatibility
- Added ICON_INTEGRATION.md documentation
2025-11-13 21:00:07 +02:00

67 lines
2.1 KiB
Python

"""Group model for organizing players and content."""
from datetime import datetime
from typing import List, Optional
from app.extensions import db
# Association table for many-to-many relationship between groups and content
group_content = db.Table('group_content',
db.Column('group_id', db.Integer, db.ForeignKey('group.id'), primary_key=True),
db.Column('content_id', db.Integer, db.ForeignKey('content.id'), primary_key=True)
)
class Group(db.Model):
"""Group model for organizing players with shared content.
Attributes:
id: Primary key
name: Unique group name
description: Optional group description
created_at: Group creation timestamp
updated_at: Last modification timestamp
"""
__tablename__ = 'group'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False, unique=True, index=True)
description = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
updated_at = db.Column(db.DateTime, default=datetime.utcnow,
onupdate=datetime.utcnow, nullable=False)
# Relationships
contents = db.relationship('Content', secondary=group_content,
back_populates='groups', lazy='dynamic')
def __repr__(self) -> str:
"""String representation of Group."""
return f'<Group {self.name} (ID={self.id})>'
@property
def content_count(self) -> int:
"""Get number of content items in this group."""
return self.contents.count()
def add_player(self, player) -> None:
"""Add a player to this group.
Args:
player: Player instance to add
"""
player.group_id = self.id
self.updated_at = datetime.utcnow()
def remove_player(self, player) -> None:
"""Remove a player from this group.
Args:
player: Player instance to remove
"""
if player.group_id == self.id:
player.group_id = None
self.updated_at = datetime.utcnow()