parameters: (self, parameters, request)
return_statement: return jsonify({'result': result})
docstring: Save changes to a user's settings.
docstring_summary: Save changes to a user's settings.
docstring_tokens: Save changes to a user s settings .
function: def saveChanges(self, parameters, request):
          """Save changes to a user's settings."""
          result = {}
          parameters = parameters['parameters']
          if ('user' not in parameters
                  or 'records' not in parameters):
              app.logger.debug('saveChanges parameters: %s', parameters)
              raise InvalidUsage(
                  'Mal-formed message format.',
                  status_code=400)
  
          user_data = parameters['user']
          record_data = parameters['records']
  
          user = User().query.filter_by(username=session['C']).one()
          app.logger.debug('user_data: %s', user_data)
          user.update(user_data)
          db.session.add(user)
  
          if 'updated' in record_data:
              for entry in record_data['updated']:
                  reference = entry['record']['reference']
                  try:
                      record = Record().query.filter_by(reference=reference).one()
                  except NoResultFound:
                      record = Record(user=user)
                      record_version = RecordVersion(record=record)
                      record_version.update(entry)
                      db.session.add(record)
                      db.session.add(record_version)
  
          if 'deleted' in record_data:
              for reference in record_data['deleted']:
                  try:
                      record = Record().query.filter_by(reference=reference).one()
                      db.session.delete(record)
                  except NoResultFound:
                      pass
  
          db.session.commit()
          result['lock'] = user.lock
          result['result'] = 'done'
  
          return jsonify({'result': result})
function_tokens: def saveChanges ( self , parameters , request ) : result = { } parameters = parameters [ 'parameters' ] if ( 'user' not in parameters or 'records' not in parameters ) : app . logger . debug ( 'saveChanges parameters: %s' , parameters ) raise InvalidUsage ( 'Mal-formed message format.' , status_code = 400 ) user_data = parameters [ 'user' ] record_data = parameters [ 'records' ] user = User ( ) . query . filter_by ( username = session [ 'C' ] ) . one ( ) app . logger . debug ( 'user_data: %s' , user_data ) user . update ( user_data ) db . session . add ( user ) if 'updated' in record_data : for entry in record_data [ 'updated' ] : reference = entry [ 'record' ] [ 'reference' ] try : record = Record ( ) . query . filter_by ( reference = reference ) . one ( ) except NoResultFound : record = Record ( user = user ) record_version = RecordVersion ( record = record ) record_version . update ( entry ) db . session . add ( record ) db . session . add ( record_version ) if 'deleted' in record_data : for reference in record_data [ 'deleted' ] : try : record = Record ( ) . query . filter_by ( reference = reference ) . one ( ) db . session . delete ( record ) except NoResultFound : pass db . session . commit ( ) result [ 'lock' ] = user . lock result [ 'result' ] = 'done' return jsonify ( { 'result' : result } )