@must_be_logged_in
def user_choose_mailing_lists(auth, **kwargs):
 user = auth.user
 json_data = escape_html(request.get_json())
 if json_data:
  for (list_name, subscribe) in json_data.items():
   if (list_name == settings.OSF_HELP_LIST):
    update_osf_help_mails_subscription(user=user, subscribe=subscribe)
   else:
    update_mailchimp_subscription(user, list_name, subscribe)
 else:
  raise HTTPError(http.BAD_REQUEST, data=dict(message_long="Must provide a dictionary of the format {'mailing list name': Boolean}"))
 user.save()
 all_mailing_lists = {}
 all_mailing_lists.update(user.mailchimp_mailing_lists)
 all_mailing_lists.update(user.osf_mailing_lists)
 return ({'message': 'Successfully updated mailing lists', 'result': all_mailing_lists}, 200)

@ must_be_logged_in def user_choose_mailing_lists ( auth , ** kwargs ) : user = auth . user json_data = escape_html ( request . get_json ( ) ) if json_data : for ( list_name , subscribe ) in json_data . items ( ) : if ( list_name == settings . OSF_HELP_LIST ) : update_osf_help_mails_subscription ( user = user , subscribe = subscribe ) else : update_mailchimp_subscription ( user , list_name , subscribe ) else : raise HTTPError ( http . BAD_REQUEST , data = dict ( message_long = "Must provide a dictionary of the format {'mailing list name': Boolean}" ) ) user . save ( ) all_mailing_lists = { } all_mailing_lists . update ( user . mailchimp_mailing_lists ) all_mailing_lists . update ( user . osf_mailing_lists ) return ( { 'message' : 'Successfully updated mailing lists' , 'result' : all_mailing_lists } , 200 )
update mailing list subscription on user model and in mailchimp example input: "open science framework general": true .