'query method for Discount Code List
:param view_kwargs:
:return:'

def query(self, view_kwargs):

    query_ = self.session.query(DiscountCode)
    if view_kwargs.get('user_id'):
        user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
        query_ = query_.join(User).filter((User.id == user.id))
    if view_kwargs.get('event_identifier'):
        event = safe_query(self, Event, 'identifier', view_kwargs['event_identifier'], 'event_identifier')
        view_kwargs['event_id'] = event.id
    if (view_kwargs.get('event_id') and has_access('is_coorganizer', event_id=view_kwargs['event_id'])):
        self.schema = DiscountCodeSchemaTicket
        query_ = query_.filter_by(event_id=view_kwargs['event_id'])
    elif ((not view_kwargs.get('event_id')) and has_access('is_admin')):
        self.schema = DiscountCodeSchemaEvent
    else:
        raise UnprocessableEntity({'source': ''}, 'Please    check    used_for    and    endpoint    and    verify    your    permission')
    return query_
