<s> from flask import Markup , url_for <EOL> from sqlalchemy import Column , Integer , Float , String , ForeignKey , Text <EOL> from sqlalchemy . orm import relationship <EOL> from flask . ext . appbuilder . models . mixins import ImageColumn <EOL> from flask . ext . appbuilder . filemanager import ImageManager <EOL> from flask . ext . appbuilder import Model <EOL> from flask_appbuilder . security . sqla . models import User <EOL> class ProductType ( Model ) : <EOL> id = Column ( Integer , primary_key = True ) <EOL> name = Column ( String ( <NUM_LIT:50> ) , unique = True , nullable = False ) <EOL> def __repr__ ( self ) : <EOL> return self . name <EOL> class Product ( Model ) : <EOL> id = Column ( Integer , primary_key = True ) <EOL> name = Column ( String ( <NUM_LIT:50> ) , unique = True , nullable = False ) <EOL> price = Column ( Float , nullable = False ) <EOL> photo = Column ( ImageColumn ) <EOL> description = Column ( Text ( ) ) <EOL> product_type_id = Column ( Integer , ForeignKey ( '<STR_LIT>' ) , nullable = False ) <EOL> product_type = relationship ( "<STR_LIT>" ) <EOL> def photo_img ( self ) : <EOL> im = ImageManager ( ) <EOL> if self . photo : <EOL> return Markup ( '<STR_LIT>' + url_for ( '<STR_LIT>' , <EOL> pk = str ( self . id ) ) + '<STR_LIT>' + <EOL> im . get_url ( self . photo ) + '<STR_LIT>' ) <EOL> else : <EOL> return Markup ( '<STR_LIT>' + url_for ( '<STR_LIT>' , <EOL> pk = str ( self . id ) ) + '<STR_LIT>' ) <EOL> def price_label ( self ) : <EOL> return Markup ( '<STR_LIT>' . format ( self . price ) ) <EOL> def __repr__ ( self ) : <EOL> return self . name <EOL> class Client ( User ) : <EOL> extra = Column ( String ( <NUM_LIT:50> ) , unique = True , nullable = False ) </s>
