def delete_model(model, item_id, 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 hasattr(item, 'in_trash'):
  item.in_trash = True
  save_to_db(item, '{} moved to trash'.format(model.__name__))
 else:
  delete_from_db(item, '{} deleted'.format(model.__name__))
 return item

def delete_model ( model , item_id , 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 hasattr ( item , 'in_trash' ) : item . in_trash = True save_to_db ( item , '{} moved to trash' . format ( model . __name__ ) ) else : delete_from_db ( item , '{} deleted' . format ( model . __name__ ) ) return item
deletes a model if event_id is set .