Exemplo n.º 1
0
def get_order_table(usr_id, gam_id):
    piece_table_info = (
        ("pce_type", "type"), ("name", "territory"), ("abbrev","abbrev"), ("order_type","order"),
        ("destination", "destination"), ('op', 'operands')
    )
    piece_table = db.callproc('pieces_for_user', gam_id, usr_id)
    order_table = db.callproc('orders_for_user', gam_id, usr_id)
    
    link_str = '<a href="change_orders.py?pce_id=%s">%s</a>'
    for piece in piece_table:
        piece['order_type'] = link_str % (piece['pce_id'], 'hold')
        for order in order_table:
            if piece['pce_id'] == order['pce_id']:
                piece['order_type'] = link_str % (piece['pce_id'], order['order_text'])
                if order['has_dst'] == 1:
                    if order['destination']: piece['destination'] = order['dst_name']
                    else: piece['destination'] = ''
                else: piece['destination'] = ''
        if resolution_engine.has_op(piece['pce_id']):
            s = ', '.join([op['name'] for op in db.callproc('operands_for_piece', piece['pce_id'])])
            piece['op'] = s
        else: piece['op'] = ''
    return piece_table, piece_table_info
Exemplo n.º 2
0
     db.callproc('clear_piece_operands', pce_id)
     piece_info, map_data, existing_orders = get_db_data(gam_id, pce_id)
     if resolution_engine.has_dst(pce_id):
         print_choose_dst(user_dict, piece_info, map_data, existing_orders, ter_id)
     else:
         write_orders.print_order_screen(user_dict, ses_dict, False)
         
     #print_choose_dst(user_dict, piece_info, map_data, existing_orders)
 elif form.has_key('ter_id'):
     try: ter_id = templater.validators.Int.to_python(form['ter_id'].value)
     except templater.formencode.Invalid, e: 
         templater.print_error("ter_id invalid")
         sys.exit(0)
     update_orders(pce_id, odt_id, ter_id)
     piece_info, map_data, existing_orders = get_db_data(gam_id, pce_id)
     if resolution_engine.has_op(pce_id):
         print_choose_op(user_dict, piece_info, map_data, existing_orders, ter_id)
     else:
         write_orders.print_order_screen(user_dict, ses_dict, False)
 elif form.has_key('op_id'):
     try: op_id = templater.validators.Int.to_python(form['op_id'].value)
     except templater.formencode.Invalid, e: 
         templater.print_error("op_id invalid")
         sys.exit(0)
     db.callproc('insert_operand', pce_id, op_id)
     piece_info, map_data, existing_orders = get_db_data(gam_id, pce_id)
     write_orders.print_order_screen(user_dict, ses_dict, False)
 else:
     update_orders(pce_id, odt_id, ter_id)
     piece_info, map_data, existing_orders = get_db_data(gam_id, pce_id)
     print_choose_orders(user_dict, gam_id, piece_info, map_data, existing_orders)