'Method to edit object
:param discount:
:param data:
:param view_kwargs:
:return:'

def before_update_object(self, discount, data, view_kwargs):

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