lots of things

This commit is contained in:
2025-06-06 22:02:44 -05:00
parent 9daee50a3a
commit 96c634897b
30 changed files with 1120 additions and 182 deletions

View File

@ -1,40 +1,42 @@
# plugins/media/models.py
from app import db
from datetime import datetime
from plugins.plant.models import Plant
class Media(db.Model):
__tablename__ = 'media'
__table_args__ = {'extend_existing': True}
__tablename__ = "media"
__table_args__ = {"extend_existing": True}
id = db.Column(db.Integer, primary_key=True)
file_url = db.Column(db.String(256), nullable=False)
uploaded_at = db.Column(db.DateTime, default=datetime.utcnow)
plant_id = db.Column(db.Integer, db.ForeignKey('plant.id'), nullable=True)
growlog_id = db.Column(db.Integer, db.ForeignKey('grow_logs.id'), nullable=True)
update_id = db.Column(db.Integer, db.ForeignKey('plant_updates.id'), nullable=True)
uploader_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False)
caption = db.Column(db.String(255), nullable=True)
# Relationship to PlantUpdate
update = db.relationship('PlantUpdate', back_populates='media_items', lazy=True)
plant_id = db.Column(db.Integer, db.ForeignKey("plant.id"), nullable=True)
growlog_id = db.Column(db.Integer, db.ForeignKey("grow_logs.id"), nullable=True)
update_id = db.Column(db.Integer, db.ForeignKey("plant_updates.id"), nullable=True)
update = db.relationship("PlantUpdate", back_populates="media_items")
class ImageHeart(db.Model):
__tablename__ = 'image_hearts'
__table_args__ = {'extend_existing': True}
__tablename__ = "image_hearts"
__table_args__ = {"extend_existing": True}
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
submission_image_id = db.Column(db.Integer, db.ForeignKey('submission_images.id'), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False)
media_id = db.Column(db.Integer, db.ForeignKey("media.id"), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
media = db.relationship("Media", backref="hearts")
class FeaturedImage(db.Model):
__tablename__ = 'featured_images'
__table_args__ = {'extend_existing': True}
__tablename__ = "featured_images"
__table_args__ = {"extend_existing": True}
id = db.Column(db.Integer, primary_key=True)
submission_image_id = db.Column(db.Integer, db.ForeignKey('submission_images.id'), nullable=False)
media_id = db.Column(db.Integer, db.ForeignKey("media.id"), nullable=False)
override_text = db.Column(db.String(255), nullable=True)
is_featured = db.Column(db.Boolean, default=True)
media = db.relationship("Media", backref="featured_entries")