lots of changes
This commit is contained in:
@ -2,18 +2,11 @@
|
||||
|
||||
from datetime import datetime
|
||||
import uuid as uuid_lib
|
||||
|
||||
# Import the central SQLAlchemy instance, not a new one
|
||||
from app import db
|
||||
# from plugins.auth.models import User
|
||||
|
||||
# If your User model lives in plugins/auth/models.py, import it here:
|
||||
from plugins.auth.models import User
|
||||
|
||||
# -----------------------------
|
||||
# (We no longer need PlantLineage)
|
||||
# -----------------------------
|
||||
|
||||
# Association table for tags (unchanged)
|
||||
# Association table for Plant ↔ Tag (unchanged)
|
||||
plant_tags = db.Table(
|
||||
'plant_tags',
|
||||
db.metadata,
|
||||
@ -30,7 +23,6 @@ class Tag(db.Model):
|
||||
name = db.Column(db.String(128), unique=True, nullable=False)
|
||||
# … any other columns you had …
|
||||
|
||||
|
||||
class PlantCommonName(db.Model):
|
||||
__tablename__ = 'plant_common_name'
|
||||
__table_args__ = {'extend_existing': True}
|
||||
@ -46,7 +38,6 @@ class PlantCommonName(db.Model):
|
||||
cascade='all, delete-orphan'
|
||||
)
|
||||
|
||||
|
||||
class PlantScientificName(db.Model):
|
||||
__tablename__ = 'plant_scientific_name'
|
||||
__table_args__ = {'extend_existing': True}
|
||||
@ -56,12 +47,8 @@ class PlantScientificName(db.Model):
|
||||
common_id = db.Column(db.Integer, db.ForeignKey('plant_common_name.id'), nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
plants = db.relationship(
|
||||
'plugins.plant.models.Plant',
|
||||
backref='scientific',
|
||||
lazy='dynamic'
|
||||
)
|
||||
|
||||
# We removed the “plants” relationship from here to avoid backref conflicts.
|
||||
# If you need it, you can still do Plant.query.filter_by(scientific_id=<this id>).
|
||||
|
||||
class PlantOwnershipLog(db.Model):
|
||||
__tablename__ = 'plant_ownership_log'
|
||||
@ -72,11 +59,16 @@ class PlantOwnershipLog(db.Model):
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
|
||||
date_acquired = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
transferred = db.Column(db.Boolean, default=False, nullable=False)
|
||||
graph_node_id = db.Column(db.String(255), nullable=True) # optional
|
||||
is_verified = db.Column(db.Boolean, default=False, nullable=False)
|
||||
|
||||
user = db.relationship('plugins.auth.models.User', backref='ownership_logs', lazy=True)
|
||||
# Optional: if you ever want to store a pointer to the Neo4j node, you can re-add:
|
||||
# graph_node_id = db.Column(db.String(255), nullable=True)
|
||||
|
||||
user = db.relationship(
|
||||
'plugins.auth.models.User',
|
||||
backref='ownership_logs',
|
||||
lazy=True
|
||||
)
|
||||
|
||||
class Plant(db.Model):
|
||||
__tablename__ = 'plant'
|
||||
@ -94,6 +86,10 @@ class Plant(db.Model):
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
updated_at = db.Column(db.DateTime, onupdate=datetime.utcnow)
|
||||
|
||||
# ─── NEW: Flag that indicates whether the common/scientific name pair was human-verified ─────────────────
|
||||
data_verified = db.Column(db.Boolean, default=False, nullable=False)
|
||||
|
||||
# Relationships
|
||||
updates = db.relationship(
|
||||
'plugins.growlog.models.PlantUpdate',
|
||||
backref='plant',
|
||||
|
Reference in New Issue
Block a user