예제 #1
0
def update(request):
    logger = LogManager(__name__, 'CHANGE_SETTINGS')

    parameters = request.POST

    if 'model' in parameters:
        model = str(parameters['model'])
        request.session['model'] = model
        logger.clean_context()
        logger.set_context('user_name', request.user.username)
        logger.set_context('new_model', model)
        logger.info('dataset_updated')

    if 'dataset' in parameters:
        # TODO: check if is a valid mapping_id before change session[dataset]
        new_dataset = parameters['dataset']

        if request.user.has_perm('permission_admin.can_access_dataset_' +
                                 str(new_dataset)):
            request.session['dataset'] = new_dataset

            logger.clean_context()
            logger.set_context('user_name', request.user.username)
            logger.set_context('new_dataset', new_dataset)
            logger.info('dataset_updated')

        ds = Datasets().activate_dataset(request.session)
        es_m = ds.build_manager(ES_Manager)

    return HttpResponseRedirect(URL_PREFIX + '/')
예제 #2
0
파일: views.py 프로젝트: ekt68/texta
def update(request):
	logger = LogManager(__name__, 'CHANGE_SETTINGS')

	parameters = request.POST	
	if 'model_pk' in parameters:
		model = {"pk": parameters["model_pk"], "description": parameters["model_description"], "unique_id": parameters["model_uuid"]}
		request.session['model'] = model
		logger.clean_context()
		logger.set_context('user_name', request.user.username)
		logger.set_context('new_model', model)
		logger.info('model_updated')

	if 'dataset[]' in parameters:
		# TODO: check if is a valid mapping_id before change session[dataset]
		new_datasets = parameters.getlist('dataset[]')
		
		new_datasets = [new_dataset for new_dataset in new_datasets if request.user.has_perm('permission_admin.can_access_dataset_' + str(new_dataset))]

		request.session['dataset'] = new_datasets

		logger.clean_context()
		logger.set_context('user_name', request.user.username)
		logger.set_context('new_datasets', new_datasets)
		logger.info('datasets_updated')

		ds = Datasets().activate_datasets(request.session)
		#es_m = ds.build_manager(ES_Manager)

	return HttpResponseRedirect(URL_PREFIX + '/')
예제 #3
0
def update_model(request):
    logger = LogManager(__name__, 'CHANGE_SETTINGS')
    parameters = request.POST
    try:
        model = {
            "pk": parameters["model_pk"],
            "description": parameters["model_description"],
            "unique_id": parameters["model_uuid"]
        }
        request.session['model'] = model
        logger.clean_context()
        logger.set_context('user_name', request.user.username)
        logger.set_context('new_model', model)
        logger.info('model_updated')
        return HttpResponse(json.dumps({'status': 'success'}))
    except:
        return HttpResponse(json.dumps({'status': 'error'}))
예제 #4
0
def update_dataset(request):
    logger = LogManager(__name__, 'CHANGE_SETTINGS')
    parameters = request.POST

    try:
        # TODO: check if is a valid mapping_id before change session[dataset]
        new_datasets = parameters.getlist('dataset[]')
        new_datasets = [
            new_dataset for new_dataset in new_datasets
            if request.user.has_perm('permission_admin.can_access_dataset_' +
                                     str(new_dataset))
        ]
        request.session['dataset'] = new_datasets

        logger.clean_context()
        logger.set_context('user_name', request.user.username)
        logger.set_context('new_datasets', new_datasets)
        logger.info('datasets_updated')

        ds = Datasets().activate_datasets(request.session)
        return HttpResponse(json.dumps({'status': 'success'}))
    except:
        return HttpResponse(json.dumps({'status': 'error'}))