Skip to content

Commit

Permalink
fix setting def retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Oct 24, 2023
1 parent 31357b3 commit 10f8542
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions projectroles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,14 @@ def _validate_app_settings(
"""Validate and clean app_settings form fields"""
errors = []
for plugin in app_plugins + [None]:
p_name = plugin.name if plugin else 'projectroles'
if plugin:
p_name = plugin.name
def_kwarg = {'plugin': plugin}
else:
p_name = 'projectroles'
def_kwarg = {'app_name': p_name}
p_defs = app_settings.get_definitions(
APP_SETTING_SCOPE_PROJECT, app_name=p_name, **p_kwargs
APP_SETTING_SCOPE_PROJECT, **{**p_kwargs, **def_kwarg}
)
p_settings = {}

Expand Down
8 changes: 5 additions & 3 deletions projectroles/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ def validate_form_app_settings(self, app_settings, project=None, user=None):
Validate app settings form data and return a dict of errors.
:param app_settings: Dict of app settings
:param project: Project object
:param project: Project object or None
:param user: User object
:return: dict in format of {'setting_name': 'Error string' or None}
:return: dict in format of {setting_name: 'Error string'}
"""
# TODO: Implement this in your app plugin (optional)
return None
Expand Down Expand Up @@ -626,9 +626,11 @@ def validate_form_app_settings(self, app_settings, user=None):
"""
Validate app settings form data and return a dict of errors.
Validate app settings form data and return a dict of errors.
:param app_settings: Dict of app settings
:param user: User object
:return: dict in format of {'setting_name': 'Error string' or None}
:return: dict in format of {setting_name: 'Error string'}
"""
# TODO: Implement this in your app plugin (optional)
return None
Expand Down
10 changes: 8 additions & 2 deletions userprofile/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,15 @@ def __init__(self, *args, **kwargs):
def clean(self):
"""Function for custom form validation and cleanup"""
for plugin in self.app_plugins + [None]:
p_name = plugin.name if plugin else 'projectroles'
p_kwargs = {'user_modifiable': True}
if plugin:
p_name = plugin.name
p_kwargs['plugin'] = plugin
else:
p_name = 'projectroles'
p_kwargs['app_name'] = p_name
p_defs = app_settings.get_definitions(
APP_SETTING_SCOPE_USER, plugin=plugin, user_modifiable=True
APP_SETTING_SCOPE_USER, **p_kwargs
)
p_settings = {}

Expand Down

0 comments on commit 10f8542

Please sign in to comment.