<s> import tw2 . core as twc , tw2 . forms as twf <EOL> import elixir as el <EOL> el . metadata . bind = '<STR_LIT>' <EOL> el . options_defaults [ '<STR_LIT>' ] = True <EOL> class People ( el . Entity ) : <EOL> name = el . Field ( el . String ( <NUM_LIT:100> ) ) <EOL> email = el . Field ( el . String ( <NUM_LIT:100> ) ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class Status ( el . Entity ) : <EOL> name = el . Field ( el . String ( <NUM_LIT:100> ) ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class Order ( el . Entity ) : <EOL> name = el . Field ( el . String ( <NUM_LIT:100> ) ) <EOL> status = el . ManyToOne ( Status ) <EOL> customer = el . ManyToOne ( People ) <EOL> assignee = el . ManyToOne ( People ) <EOL> delivery = el . Field ( el . Boolean ) <EOL> address = el . Field ( el . String ( <NUM_LIT:200> ) ) <EOL> items = el . OneToMany ( '<STR_LIT>' ) <EOL> class Item ( el . Entity ) : <EOL> order = el . ManyToOne ( Order ) <EOL> code = el . Field ( el . String ( <NUM_LIT:50> ) ) <EOL> description = el . Field ( el . String ( <NUM_LIT:200> ) ) <EOL> el . setup_all ( ) <EOL> class Index ( twc . Page ) : <EOL> title = '<STR_LIT>' <EOL> class child ( twf . GridLayout ) : <EOL> id = twf . LinkField ( link = '<STR_LIT>' , text = '<STR_LIT>' , label = None ) <EOL> name = twf . LabelField ( ) <EOL> status = twf . LabelField ( ) <EOL> customer = twf . LabelField ( ) <EOL> assignee = twf . LabelField ( ) <EOL> def fetch_data ( self , req ) : <EOL> self . value = Order . query . all ( ) <EOL> class OrderForm ( twf . FormPage ) : <EOL> title = '<STR_LIT>' <EOL> class child ( twf . Form ) : <EOL> class child ( twf . TableLayout ) : <EOL> id = twf . HiddenField ( ) <EOL> name = twf . TextField ( ) <EOL> status_id = twf . SingleSelectField ( options = [ str ( r ) for r in Status . query . all ( ) ] ) <EOL> customer_id = twf . SingleSelectField ( options = [ str ( r ) for r in People . query . all ( ) ] ) <EOL> assignee_id = twf . SingleSelectField ( options = [ str ( r ) for r in People . query . all ( ) ] ) <EOL> delivery = twf . CheckBox ( ) <EOL> address = twf . TextArea ( ) <EOL> def fetch_data ( self , req ) : <EOL> self . value = Order . query . get ( req . GET [ '<STR_LIT:id>' ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import wsgiref . simple_server as wrs <EOL> wrs . make_server ( '<STR_LIT>' , <NUM_LIT> , twc . make_middleware ( controller_prefix = '<STR_LIT:/>' ) ) . serve_forever ( ) </s>
