def can_access(func):
 @wraps(func)
 def wrapper(*args, **kwargs):
  user = getattr(g, 'user', None)
  event_id = kwargs.get('event_id')
  if (not event_id):
   raise ServerError()
  get_object_or_404(EventModel, event_id)
  if (user and (user.has_role(event_id) or user.is_staff)):
   return func(*args, **kwargs)
  else:
   raise PermissionDeniedError()
 return wrapper

def can_access ( func ) : @ wraps ( func ) def wrapper ( * args , ** kwargs ) : user = getattr ( g , 'user' , None ) event_id = kwargs . get ( 'event_id' ) if ( not event_id ) : raise ServerError ( ) get_object_or_404 ( EventModel , event_id ) if ( user and ( user . has_role ( event_id ) or user . is_staff ) ) : return func ( * args , ** kwargs ) else : raise PermissionDeniedError ( ) return wrapper
check if user can read/update/delete an event .