@authenticated_json_view
@has_request_variables
def json_subscription_property(request, user_profile, subscription_data=REQ(validator=check_list(check_dict([('stream', check_string), ('property', check_string), ('value', check_variable_type([check_string, check_bool]))])))):
 if (request.method != 'POST'):
  return json_error(_('Invalid verb'))
 property_converters = {'color': check_string, 'in_home_view': check_bool, 'desktop_notifications': check_bool, 'audible_notifications': check_bool, 'pin_to_top': check_bool}
 response_data = []
 for change in subscription_data:
  stream_name = change['stream']
  property = change['property']
  value = change['value']
  if (property not in property_converters):
   return json_error((_('Unknown subscription property: %s') % (property,)))
  sub = get_subscription_or_die(stream_name, user_profile)[0]
  property_conversion = property_converters[property](property, value)
  if property_conversion:
   return json_error(property_conversion)
  do_change_subscription_property(user_profile, sub, stream_name, property, value)
  response_data.append({'stream': stream_name, 'property': property, 'value': value})
 return json_success({'subscription_data': response_data})

@ authenticated_json_view @ has_request_variables def json_subscription_property ( request , user_profile , subscription_data = REQ ( validator = check_list ( check_dict ( [ ( 'stream' , check_string ) , ( 'property' , check_string ) , ( 'value' , check_variable_type ( [ check_string , check_bool ] ) ) ] ) ) ) ) : if ( request . method != 'POST' ) : return json_error ( _ ( 'Invalid verb' ) ) property_converters = { 'color' : check_string , 'in_home_view' : check_bool , 'desktop_notifications' : check_bool , 'audible_notifications' : check_bool , 'pin_to_top' : check_bool } response_data = [ ] for change in subscription_data : stream_name = change [ 'stream' ] property = change [ 'property' ] value = change [ 'value' ] if ( property not in property_converters ) : return json_error ( ( _ ( 'Unknown subscription property: %s' ) % ( property , ) ) ) sub = get_subscription_or_die ( stream_name , user_profile ) [ 0 ] property_conversion = property_converters [ property ] ( property , value ) if property_conversion : return json_error ( property_conversion ) do_change_subscription_property ( user_profile , sub , stream_name , property , value ) response_data . append ( { 'stream' : stream_name , 'property' : property , 'value' : value } ) return json_success ( { 'subscription_data' : response_data } )
this is the entry point to changing subscription properties .