'Method for Discount Code delete
:param discount:
:param view_kwargs:
:return:'

def before_delete_object(self, discount, view_kwargs):

    if ((discount.used_for == 'ticket') and has_access('is_coorganizer', event_id=view_kwargs['event_id'])):
        self.schema = DiscountCodeSchemaTicket
    elif ((discount.used_for == 'event') and has_access('is_admin')):
        self.schema = DiscountCodeSchemaEvent
    else:
        raise UnprocessableEntity({'source': ''}, 'Please    check    used_for    and    endpoint    and    verify    your    permission')
