From c5b4ca015af8c1e4d35f0a38dd6b82ade6ca6c31 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Mon, 3 Jun 2024 18:04:54 +0200 Subject: [PATCH] Add user and site to options provider (#430) --- rdmo/options/providers.py | 4 ++-- rdmo/projects/viewsets.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rdmo/options/providers.py b/rdmo/options/providers.py index 9a36d2af48..cc1c6bebe3 100644 --- a/rdmo/options/providers.py +++ b/rdmo/options/providers.py @@ -9,13 +9,13 @@ class Provider(Plugin): # determines if the page needs to be refreshed after a value is stored refresh = False - def get_options(self, project, search=None): + def get_options(self, project, search=None, user=None, site=None): raise NotImplementedError class SimpleProvider(Provider): - def get_options(self, project, search=None): + def get_options(self, project, search=None, user=None, site=None): return [ { 'id': 'simple_1', diff --git a/rdmo/projects/viewsets.py b/rdmo/projects/viewsets.py index 9a974895a5..40ac357ffa 100644 --- a/rdmo/projects/viewsets.py +++ b/rdmo/projects/viewsets.py @@ -187,7 +187,8 @@ def options(self, request, pk=None): if Question.objects.filter_by_catalog(project.catalog).filter(optionsets=optionset) and \ optionset.provider is not None: options = [] - for option in optionset.provider.get_options(project, search=request.GET.get('search')): + for option in optionset.provider.get_options(project, search=request.GET.get('search'), + user=request.user, site=request.site): if 'id' not in option: raise RuntimeError(f"'id' is missing in options of '{optionset.provider.class_name}'") elif 'text' not in option: