<s> from django . db import models <EOL> from lino . api import dd <EOL> from lino . utils import join_elems <EOL> from lino . utils . xmlgen . html import E <EOL> from lino . mixins . polymorphic import Polymorphic <EOL> class Place ( dd . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:200> ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class Member ( Polymorphic ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:200> ) <EOL> place = models . ForeignKey ( Place , blank = True , null = True ) <EOL> email = models . EmailField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class Customer ( Member ) : <EOL> customer_remark = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> class Supplier ( Member ) : <EOL> supplier_remark = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> class Product ( dd . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:200> ) <EOL> suppliers = models . ManyToManyField ( <EOL> '<STR_LIT>' , through = '<STR_LIT>' , <EOL> related_name = '<STR_LIT>' ) <EOL> customers = models . ManyToManyField ( <EOL> '<STR_LIT>' , through = '<STR_LIT>' , <EOL> related_name = '<STR_LIT>' ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> @ dd . displayfield ( "<STR_LIT>" ) <EOL> def offered_by ( self , ar ) : <EOL> if ar is None : <EOL> return '<STR_LIT>' <EOL> items = [ ar . obj2html ( o ) for o in self . suppliers . all ( ) ] <EOL> items = join_elems ( items , sep = '<STR_LIT:U+002CU+0020>' ) <EOL> return E . p ( * items ) <EOL> @ dd . displayfield ( "<STR_LIT>" ) <EOL> def demanded_by ( self , ar ) : <EOL> if ar is None : <EOL> return '<STR_LIT>' <EOL> items = [ ar . obj2html ( o ) for o in self . customers . all ( ) ] <EOL> items = join_elems ( items , sep = '<STR_LIT:U+002CU+0020>' ) <EOL> return E . p ( * items ) <EOL> class Offer ( dd . Model ) : <EOL> supplier = models . ForeignKey ( Supplier ) <EOL> product = models . ForeignKey ( Product ) <EOL> valid_until = models . DateField ( blank = True , null = True ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . product , self . supplier ) <EOL> class Demand ( dd . Model ) : <EOL> customer = models . ForeignKey ( Customer ) <EOL> product = models . ForeignKey ( Product ) <EOL> def __unicode__ ( self ) : <EOL> return "<STR_LIT>" % ( self . product , self . supplier ) <EOL> from . tables import * </s>
