def update_model(model, item_id, data, event_id=None):
 if (event_id is not None):
  item = get_object_in_event(model, item_id, event_id)
 else:
  item = get_object_or_404(model, item_id)
 if (len(data) == 0):
  return item
 db.session.query(model).filter_by(id=item_id).update(dict(data))
 save_to_db(item, ('%s updated' % model.__name__))
 return item

def update_model ( model , item_id , data , event_id = None ) : if ( event_id is not None ) : item = get_object_in_event ( model , item_id , event_id ) else : item = get_object_or_404 ( model , item_id ) if ( len ( data ) == 0 ) : return item db . session . query ( model ) . filter_by ( id = item_id ) . update ( dict ( data ) ) save_to_db ( item , ( '%s updated' % model . __name__ ) ) return item
updates a model .