def update_configuration(configuration_id): """Update a configuration""" config = Configuration.objects(id=ObjectId(configuration_id)).first() if config is not None: config = deserialize_that(read_request(), config) config.save() return JsonResponse(config)
def find_configuration_by_reference(ref): """Find a configuration object by the information provided in the reference Find a configuration either by id, filename, or name (found in reference) :param ref: A slickqaweb.model.configurationReference.ConfigurationReference instance :return: An instance of Configuration from mongo if found, None otherwise """ assert isinstance(ref, ConfigurationReference) config = None if hasattr(ref, 'id') and ref.id is not None: config = Configuration.objects(id=ref.id).first() if config is None and hasattr(ref, 'filename') and ref.filename is not None and ref.filename != '': config = Configuration.objects(filename=ref.filename).first() if config is None and hasattr(ref, 'name') and ref.name is not None and ref.name != '': config = Configuration.objects(name=ref.name).first() return config
def delete_configuration(configuration_id): """Remove a configuration""" config = Configuration.objects(id=ObjectId(configuration_id)).first() if config is not None: config.delete()
def get_configuration(configuration_id): """Get a specific configuration by id.""" config = Configuration.objects(id=ObjectId(configuration_id)).first() return JsonResponse(config)