-
Notifications
You must be signed in to change notification settings - Fork 3
/
Disease.py
46 lines (43 loc) · 1.79 KB
/
Disease.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
import database.Image
import database.Plant
import database.AnalysisResult
from models.Disease import Disease as DiseaseModel
from repository.base import Base
class Disease(Base.Base):
__tablename__ = 'diseases'
id = Column(Integer, primary_key=True)
scientificName = Column('scientific_name', String(2000))
commonName = Column('common_name', String(2000))
idPlant = Column('id_plant', Integer, ForeignKey('plants.id'))
plant = relationship('Plant', back_populates='diseases')
images = relationship('Image', lazy='subquery',
back_populates='disease')
analysis_result = relationship('database.AnalysisResult.AnalysisResult',
lazy='subquery',
back_populates='disease')
def __init__(self,
id=0,
scientificName="",
commonName="",
idPlant=0,
plant=object(), # database.Plant.Plant(),
images=[],
disease=DiseaseModel()):
if (disease.id or disease.scientificName):
self.id = disease.id
self.scientificName = disease.scientificName
self.commonName = disease.commonName
self.idPlant = disease.plant.id
#self.plant = database.Plant.Plant(disease.plant)
self.images = []
for image in disease.images:
self.images.append(database.Image.Image(image))
else:
self.id = id
self.scientificName = scientificName
self.commonName = commonName
self.idPlant = idPlant
#self.plant = plant
self.images = images