Skip to content

Commit

Permalink
fix _validate_value_in_options()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Feb 13, 2025
1 parent 3b0745d commit 602757e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions projectroles/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _validate_value_in_options(
Ensure setting_value is present in setting_options.
:param setting_value: String
:param setting_options: List of options (String or Integers)
:param setting_options: List of options
:param project: Project object
:param user: User object
:raise: ValueError if type is not recognized
Expand All @@ -218,15 +218,11 @@ def _validate_value_in_options(
', '.join(map(str, valid_options)),
)
)
else:
elif setting_options:
opts = [
o[0] if isinstance(o, tuple) else o for o in setting_options
]
if (
setting_options
and not callable(setting_options)
and setting_value not in opts
):
if setting_value not in opts:
raise ValueError(
'Choice "{}" not found in options ({})'.format(
setting_value, ', '.join(map(str, setting_options))
Expand Down

0 comments on commit 602757e

Please sign in to comment.