-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1b3661
commit 7941e73
Showing
10 changed files
with
138 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Third Party | ||
from django_filters import ( | ||
UnknownFieldBehavior, | ||
rest_framework as filters, | ||
) | ||
|
||
# wger | ||
from wger.manager.api.consts import BASE_CONFIG_FILTER_FIELDS | ||
|
||
|
||
class BaseConfigFilterSet(filters.FilterSet): | ||
class Meta: | ||
fields = BASE_CONFIG_FILTER_FIELDS | ||
unknown_field_behavior = UnknownFieldBehavior.IGNORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Third Party | ||
from rest_framework import serializers | ||
|
||
|
||
def validate_requirements(value: dict | None): | ||
"""Validates the requirements field.""" | ||
|
||
if value is None: | ||
return | ||
|
||
if not isinstance(value, dict): | ||
raise serializers.ValidationError('Requirements must be a JSON object.') | ||
|
||
required_keys = {'rules'} # Set of required keys | ||
if not all(key in value for key in required_keys): | ||
raise serializers.ValidationError("Missing required keys: 'rules'") # More specific | ||
|
||
if 'rules' in value and not isinstance(value['rules'], list): | ||
raise serializers.ValidationError("'rules' must be a list.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.