updated first commit
This commit is contained in:
38
app/models/content.py
Normal file
38
app/models/content.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
Content model for media files
|
||||
"""
|
||||
|
||||
from app.extensions import db
|
||||
|
||||
class Content(db.Model):
|
||||
"""Content model representing media files for players"""
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
file_name = db.Column(db.String(255), nullable=False, index=True)
|
||||
original_name = db.Column(db.String(255), nullable=True)
|
||||
duration = db.Column(db.Integer, nullable=False, default=10) # Duration in seconds
|
||||
position = db.Column(db.Integer, default=0) # Position in playlist
|
||||
player_id = db.Column(db.Integer, db.ForeignKey('player.id'), nullable=False, index=True)
|
||||
content_type = db.Column(db.String(50), nullable=False, default='image') # image, video, document
|
||||
file_size = db.Column(db.Integer, nullable=True) # File size in bytes
|
||||
uploaded_at = db.Column(db.DateTime, default=db.func.current_timestamp())
|
||||
is_active = db.Column(db.Boolean, default=True)
|
||||
|
||||
# Metadata for different content types
|
||||
width = db.Column(db.Integer, nullable=True)
|
||||
height = db.Column(db.Integer, nullable=True)
|
||||
format = db.Column(db.String(10), nullable=True)
|
||||
|
||||
@property
|
||||
def file_path(self):
|
||||
"""Get the full file path for this content"""
|
||||
return f"uploads/{self.file_name}"
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""Get the URL for this content"""
|
||||
from flask import url_for
|
||||
return url_for('static', filename=self.file_path)
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Content {self.file_name} (Player: {self.player_id})>'
|
||||
Reference in New Issue
Block a user