예제 #1
0
파일: views.py 프로젝트: texta-tk/texta
def add_dataset(request):
    daterange = ""
    dataset = Dataset(author=request.user,
                      index=request.POST['index'],
                      mapping=request.POST['mapping'],
                      daterange=daterange,
                      access=(request.POST['access']))
    dataset.save()

    create_dataset_access_permission_and_propagate(dataset,
                                                   request.POST['access'])
    indices = ES_Manager.get_indices()
    ds_out = dataset.__dict__
    for index in indices:
        if index['index'] == ds_out['index']:
            ds_out['status'] = index['status']
            ds_out['docs_count'] = index['docs_count']
            ds_out['store_size'] = index['store_size']
            break
        elif '*' in ds_out['index']:
            ds_out['status'] = 'open'
            ds_out['docs_count'] = 'multiindex'
            ds_out['store_size'] = 'multiindex'
    ds_out['_state'] = ''
    ds_out['author'] = request.user.get_username()
    return JsonResponse(ds_out)
예제 #2
0
파일: views.py 프로젝트: texta-tk/texta
def index(request):
    indices = ES_Manager.get_indices()
    indices = sorted(indices, key=lambda x: x['index'])  # sort alphabetically
    datasets = get_datasets(indices=indices)

    users = User.objects.all()
    users = annotate_users_with_permissions(users, datasets)
    template = loader.get_template('permission_admin.html')
    allowed_datasets = Datasets().get_allowed_datasets(request.user)

    language_models = Task.objects.filter(
        task_type=TaskTypes.TRAIN_MODEL.value).filter(
            status__iexact=Task.STATUS_COMPLETED).order_by('-pk')

    return HttpResponse(
        template.render(
            {
                'users': users,
                'datasets': datasets,
                'indices': indices,
                'STATIC_URL': STATIC_URL,
                'URL_PREFIX': URL_PREFIX,
                'allowed_datasets': allowed_datasets,
                'language_models': language_models
            }, request))
예제 #3
0
파일: datasets.py 프로젝트: texta-tk/texta
 def get_allowed_datasets(self, user):
     indices = ES_Manager.get_indices()
     datasets = self.sort_datasets(indices)
     #print(datasets)
     return [
         dataset for dataset in datasets
         if user.has_perm('permission_admin.can_access_dataset_' +
                          str(dataset['id']))
     ]
예제 #4
0
파일: views.py 프로젝트: ekt68/texta
def index(request):
    indices = ES_Manager.get_indices()
    indices = sorted(indices, key=lambda x: x['index'])  # sort alphabetically
    datasets = get_datasets(indices=indices)

    users = User.objects.all()
    users = annotate_users_with_permissions(users, datasets)
    template = loader.get_template('permission_admin.html')
    allowed_datasets = Datasets().get_allowed_datasets(request.user)

    language_models =Task.objects.filter(task_type=TaskTypes.TRAIN_MODEL.value).filter(status__iexact=Task.STATUS_COMPLETED).order_by('-pk')

    return HttpResponse(template.render({'users':users,'datasets':datasets,'indices':indices,'STATIC_URL':STATIC_URL,'URL_PREFIX':URL_PREFIX, 'allowed_datasets': allowed_datasets, 'language_models': language_models},request))
예제 #5
0
파일: views.py 프로젝트: ekt68/texta
def add_dataset(request):
    daterange = ""
    dataset = Dataset(author=request.user, index=request.POST['index'],
                      mapping=request.POST['mapping'], daterange=daterange, access=(request.POST['access']))
    dataset.save()

    create_dataset_access_permission_and_propagate(dataset, request.POST['access'])
    indices = ES_Manager.get_indices()
    ds_out = dataset.__dict__
    for index in indices:
        if index['index'] == ds_out['index']:
            ds_out['status'] = index['status']
            ds_out['docs_count'] = index['docs_count']
            ds_out['store_size'] = index['store_size']
            break
        elif '*' in ds_out['index']:
            ds_out['status'] = 'open'
            ds_out['docs_count'] = 'multiindex'
            ds_out['store_size'] = 'multiindex'
    ds_out['_state'] = ''
    ds_out['author'] = request.user.get_username()
    return JsonResponse(ds_out)
예제 #6
0
파일: datasets.py 프로젝트: ekt68/texta
	def get_allowed_datasets(self, user):
		indices = ES_Manager.get_indices()
		datasets = self.sort_datasets(indices)
		#print(datasets)
		return [dataset for dataset in datasets if user.has_perm('permission_admin.can_access_dataset_' + str(dataset['id']))]