diff --git a/deploy/data/individuals_test.json b/deploy/data/individuals_test.json index 2e8b5ed7..26227f0a 100644 --- a/deploy/data/individuals_test.json +++ b/deploy/data/individuals_test.json @@ -4,7 +4,7 @@ "id" : "NCIT:C42331", "label" : "African" }, - "id" : "HG00096", + "id" : "AV0101", "info" : { "eid" : "fake1" }, diff --git a/permissions/controlled_datasets.yml b/permissions/controlled_datasets.yml index e84d0dec..f9f6ba3d 100644 --- a/permissions/controlled_datasets.yml +++ b/permissions/controlled_datasets.yml @@ -1,2 +1,5 @@ -controlled_datasets: +app-user3: +- CINECA_synthetic_cohort_EUROPE_UK1 +- AV_Dataset +hola: - CINECA_synthetic_cohort_EUROPE_UK1 diff --git a/permissions/permissions-ui/bash/urls.py b/permissions/permissions-ui/bash/urls.py index b50e254d..8930a8b2 100644 --- a/permissions/permissions-ui/bash/urls.py +++ b/permissions/permissions-ui/bash/urls.py @@ -6,6 +6,6 @@ urlpatterns = [ path('', views.bash_view, name='index'), path('public', views.public_view, name='public'), - path('controlled', views.controlled_view, name='controlled'), - path('registered', views.registered_view, name='registered') + path('registered', views.registered_view, name='registered'), + path('controlled', views.controlled_view, name='controlled') ] \ No newline at end of file diff --git a/permissions/permissions-ui/bash/views.py b/permissions/permissions-ui/bash/views.py index 7d2d196f..3da48c0b 100644 --- a/permissions/permissions-ui/bash/views.py +++ b/permissions/permissions-ui/bash/views.py @@ -42,27 +42,26 @@ def add_public_datasets(list_datasets): yaml.dump(public_datasets, pfile) pfile.close -def add_controlled_datasets(list_datasets): - with open("../beacon/permissions/controlled_datasets.yml", 'r') as pfile: - controlled_datasets = yaml.safe_load(pfile) +def add_registered_datasets(list_datasets): + with open("../beacon/permissions/registered_datasets.yml", 'r') as pfile: + registered_datasets = yaml.safe_load(pfile) pfile.close - controlled_datasets['controlled_datasets']=list_datasets - with open("../beacon/permissions/controlled_datasets.yml", 'w') as pfile: - yaml.dump(controlled_datasets, pfile) + registered_datasets['registered_datasets']=list_datasets + with open("../beacon/permissions/registered_datasets.yml", 'w') as pfile: + yaml.dump(registered_datasets, pfile) pfile.close -def add_registered_datasets(list_users, list_datasets): - with open("../beacon/permissions/registered_datasets.yml", 'r') as pfile: - registered_datasets = yaml.safe_load(pfile) +def add_controlled_datasets(list_users, list_datasets): + with open("../beacon/permissions/controlled_datasets.yml", 'r') as pfile: + controlled_datasets = yaml.safe_load(pfile) pfile.close for user in list_users: - print(user) - registered_datasets[user]=[] + controlled_datasets[user]=[] for dataset in list_datasets: - if dataset not in registered_datasets[user]: - registered_datasets[user].append(dataset) - with open("../beacon/permissions/registered_datasets.yml", 'w') as pfile: - yaml.dump(registered_datasets, pfile) + if dataset not in controlled_datasets[user]: + controlled_datasets[user].append(dataset) + with open("../beacon/permissions/controlled_datasets.yml", 'w') as pfile: + yaml.dump(controlled_datasets, pfile) pfile.close def load_datasets(): @@ -84,39 +83,39 @@ def load_public_datasets(): return list_of_public_datasets -def load_controlled_datasets(): - with open("../beacon/permissions/controlled_datasets.yml", 'r') as pfile: - controlled_datasets = yaml.safe_load(pfile) +def load_registered_datasets(): + with open("../beacon/permissions/registered_datasets.yml", 'r') as pfile: + registered_datasets = yaml.safe_load(pfile) pfile.close() - list_of_controlled_datasets = controlled_datasets['controlled_datasets'] + list_of_registered_datasets = registered_datasets['registered_datasets'] - return list_of_controlled_datasets + return list_of_registered_datasets def load_users(): - with open("../beacon/permissions/registered_datasets.yml", 'r') as pfile: - registered_datasets = yaml.safe_load(pfile) + with open("../beacon/permissions/controlled_datasets.yml", 'r') as pfile: + controlled_datasets = yaml.safe_load(pfile) pfile.close() list_users=[] - for k, v in registered_datasets.items(): + for k, v in controlled_datasets.items(): list_users.append(k) return list_users -def load_registered_datasets(user): - with open("../beacon/permissions/registered_datasets.yml", 'r') as pfile: - registered_datasets = yaml.safe_load(pfile) +def load_controlled_datasets(user): + with open("../beacon/permissions/controlled_datasets.yml", 'r') as pfile: + controlled_datasets = yaml.safe_load(pfile) pfile.close() - list_registered_datasets=[] + list_controlled_datasets=[] - for k, v in registered_datasets.items(): + for k, v in controlled_datasets.items(): if k == user: - list_registered_datasets = v + list_controlled_datasets = v - return list_registered_datasets + return list_controlled_datasets @@ -130,10 +129,10 @@ def bash_view(request): reference = form.cleaned_data['Datasets'] if reference == 'PUBLIC': return redirect("bash:public") - elif reference == 'CONTROLLED': - return redirect("bash:controlled") elif reference == 'REGISTERED': return redirect("bash:registered") + elif reference == 'CONTROLLED': + return redirect("bash:controlled") return render(request, template, context) def public_view(request): @@ -143,7 +142,6 @@ def public_view(request): context={'bash_out': bash_out, 'datasets': datasets} if request.method == 'POST': answer = request.POST.getlist('list', False) - print(answer) add_public_datasets(answer) context = { 'answer': answer, @@ -151,31 +149,30 @@ def public_view(request): return redirect("bash:index") return render(request, template, context) -def controlled_view(request): - template = "controlled.html" +def registered_view(request): + template = "registered.html" datasets=load_datasets() - bash_out=load_controlled_datasets() + bash_out=load_registered_datasets() context={'bash_out': bash_out, 'datasets': datasets} if request.method == 'POST': answer = request.POST.getlist('list', False) - print(answer) - add_controlled_datasets(answer) + add_registered_datasets(answer) context = { 'answer': answer, } return redirect("bash:index") return render(request, template, context) -def registered_view(request): - template = "registered.html" +def controlled_view(request): + template = "controlled.html" bash_out=load_users() datasets=load_datasets() context={} if request.method == 'GET': users = request.GET.getlist('userslist', False) if users != False: - registered_datasets = load_registered_datasets(users[0]) - context={'bash_out': bash_out, 'datasets': datasets, 'users': users, 'registered_datasets': registered_datasets} + controlled_datasets = load_controlled_datasets(users[0]) + context={'bash_out': bash_out, 'datasets': datasets, 'users': users, 'controlled_datasets': controlled_datasets} else: context={'bash_out': bash_out, 'datasets': datasets, 'users': users} @@ -185,7 +182,7 @@ def registered_view(request): if request.method == 'POST': user = request.POST.getlist('users', False) datasets_list = request.POST.getlist('list', False) - add_registered_datasets(user, datasets_list) + add_controlled_datasets(user, datasets_list) context = { 'answer': user, 'datasets_list': datasets_list } diff --git a/permissions/permissions-ui/templates/controlled.html b/permissions/permissions-ui/templates/controlled.html index c3b3d088..f5c53db9 100644 --- a/permissions/permissions-ui/templates/controlled.html +++ b/permissions/permissions-ui/templates/controlled.html @@ -48,6 +48,7 @@