Skip to content

Commit

Permalink
Merge pull request #1013 from rdmorganiser/add_user_and_site_to_optio…
Browse files Browse the repository at this point in the history
…ns_provider

Add user and site to options provider (#430)
  • Loading branch information
jochenklar authored Jul 8, 2024
2 parents 1eaeb5e + c5b4ca0 commit 6ddcee6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions rdmo/options/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion rdmo/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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:
Expand Down

0 comments on commit 6ddcee6

Please sign in to comment.