Skip to content

Commit

Permalink
Add user and site to options provider (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar authored and MyPyDavid committed Jun 19, 2024
1 parent 904da1b commit d49034a
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 @@ -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:
Expand Down

0 comments on commit d49034a

Please sign in to comment.