bunch of changes
This commit is contained in:
@ -5,13 +5,8 @@ from datetime import datetime, timedelta
|
||||
from app import db
|
||||
from plugins.auth.models import User
|
||||
from plugins.plant.models import (
|
||||
Plant, PlantCommonName, PlantScientificName, PlantOwnershipLog,
|
||||
PlantLineage
|
||||
Plant, PlantCommonName, PlantScientificName
|
||||
)
|
||||
from plugins.growlog.models import PlantUpdate
|
||||
from plugins.media.models import Media, ImageHeart, FeaturedImage
|
||||
from plugins.submission.models import Submission, SubmissionImage
|
||||
|
||||
|
||||
@click.command(name='preload-data') # 🔧 changed from preload_data
|
||||
@with_appcontext
|
||||
@ -38,12 +33,6 @@ def preload_data(auto=False):
|
||||
db.session.commit()
|
||||
|
||||
# COMMON & SCIENTIFIC NAMES
|
||||
#monstera_common = PlantCommonName(name='Monstera')
|
||||
#deliciosa_sci = PlantScientificName(name='Monstera deliciosa')
|
||||
#aurea_sci = PlantScientificName(name='Monstera aurea')
|
||||
#db.session.add_all([monstera_common, deliciosa_sci, aurea_sci])
|
||||
#db.session.commit()
|
||||
|
||||
joepii_common = PlantCommonName(name='Philodendron Joepii')
|
||||
queen_common = PlantCommonName(name='Anthurium Warocqueanum Queen')
|
||||
thai_common = PlantCommonName(name='Thai Constellation Monstera')
|
||||
@ -60,78 +49,5 @@ def preload_data(auto=False):
|
||||
db.session.add_all([joepii_sci, queen_sci, thai_sci, generic_sci])
|
||||
db.session.commit()
|
||||
|
||||
# PLANTS
|
||||
""" parent_plant = Plant(
|
||||
common_name_id=monstera_common.id,
|
||||
scientific_name_id=deliciosa_sci.id,
|
||||
created_by_user_id=admin.id
|
||||
)
|
||||
child_plant = Plant(
|
||||
common_name_id=monstera_common.id,
|
||||
scientific_name_id=aurea_sci.id,
|
||||
created_by_user_id=user.id,
|
||||
parent_id=1
|
||||
)
|
||||
db.session.add_all([parent_plant, child_plant])
|
||||
db.session.flush()
|
||||
|
||||
# LINEAGE & OWNERSHIP
|
||||
db.session.add(PlantLineage(parent_plant_id=parent_plant.id, child_plant_id=child_plant.id))
|
||||
db.session.add(PlantOwnershipLog(
|
||||
plant_id=child_plant.id,
|
||||
user_id=user.id,
|
||||
date_acquired=datetime.utcnow() - timedelta(days=20)
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
# UPDATE & MEDIA
|
||||
update = PlantUpdate(
|
||||
plant_id=child_plant.id,
|
||||
update_type='Repotted',
|
||||
description='Moved to a 6" pot with a new moss pole.',
|
||||
)
|
||||
db.session.add(update)
|
||||
db.session.flush()
|
||||
|
||||
db.session.add(Media(
|
||||
file_url='uploads/demo_plant_update.jpg',
|
||||
update_id=update.id,
|
||||
caption='Freshly repotted.'
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
# SUBMISSION & IMAGE
|
||||
submission = Submission(
|
||||
user_id=user.id,
|
||||
plant_id=child_plant.id,
|
||||
common_name='Monstera',
|
||||
scientific_name='Monstera aurea',
|
||||
price=120.00,
|
||||
source='Etsy',
|
||||
height=45,
|
||||
width=30,
|
||||
leaf_count=5,
|
||||
potting_mix='2:1:1 bark:pumice:coco',
|
||||
container_size='6"',
|
||||
health_status='Healthy',
|
||||
notes='Some minor yellowing on one leaf.'
|
||||
)
|
||||
db.session.add(submission)
|
||||
db.session.flush()
|
||||
|
||||
image = SubmissionImage(
|
||||
submission_id=submission.id,
|
||||
file_path='uploads/demo_submission.jpg',
|
||||
is_visible=True
|
||||
)
|
||||
db.session.add(image)
|
||||
db.session.flush()
|
||||
|
||||
db.session.add_all([
|
||||
ImageHeart(user_id=admin.id, submission_image_id=image.id),
|
||||
FeaturedImage(submission_image_id=image.id, override_text='Gorgeous coloration', is_featured=True)
|
||||
])
|
||||
db.session.commit() """
|
||||
|
||||
if not auto:
|
||||
click.echo("🎉 Demo data seeded successfully.")
|
||||
|
Reference in New Issue
Block a user