-
Notifications
You must be signed in to change notification settings - Fork 3
/
Image.py
43 lines (39 loc) · 1.46 KB
/
Image.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
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
from models.Image import Image as ImageModel
import database.Disease
import database.Analysis
from repository.base import Base
class Image(Base.Base):
__tablename__ = 'images'
id = Column(Integer, primary_key=True)
url = Column(String(2000))
description = Column(String(2000))
source = Column(String(2000))
size = Column(Integer)
idDisease = Column('id_disease', Integer, ForeignKey('diseases.id'))
disease = relationship('Disease', back_populates='images')
analysis = relationship('database.Analysis.Analysis', lazy='subquery',
back_populates='image')
def __init__(self,
url='',
description='',
source='',
size=0,
idDisease=0,
disease=object, # =Disease(),
image=ImageModel()):
if (image.id or image.url):
self.url = image.url
self.description = image.description
self.source = image.source
self.size = image.size
self.idDisease = image.disease.id
# self.disease = database.Disease.Disease(image.disease)
else:
self.url = url
self.description = description
self.source = source
self.size = size
self.idDisease = idDisease
# self.disease = disease