-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[COST-4514] Upgrade to django 4.0 (#4839)
* update django to 4.0 and update relevant method names * update pipfile.lock and remove gettext alias * mock get_response * more mocks for get_response required by middlewaremixin * use method_decorator to apply neevr_cache on class method * method set_context deprecated in DRF 3.12 in favor of requires_context * user django RedisCache and remove django_redis pkg
- Loading branch information
1 parent
29146bc
commit 2aead84
Showing
24 changed files
with
663 additions
and
717 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,53 @@ | ||
# | ||
# Copyright 2021 Red Hat Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
"""View for Settings.""" | ||
from django.utils.decorators import method_decorator | ||
from django.utils.translation import gettext | ||
from django.views.decorators.cache import never_cache | ||
from rest_framework.response import Response | ||
from rest_framework.serializers import ValidationError | ||
from rest_framework.views import APIView | ||
|
||
from api.common.permissions.settings_access import SettingsAccessPermission | ||
from api.deprecated_settings.settings import Settings | ||
from api.utils import DateHelper | ||
|
||
SETTINGS_GENERATORS = {"settings": Settings} | ||
|
||
|
||
class SettingsView(APIView): | ||
""" | ||
View to interact with settings for a customer. | ||
""" | ||
|
||
permission_classes = [SettingsAccessPermission] | ||
deprecation_datetime = DateHelper().create_end_of_life_date(2023, 9, 29) | ||
sunset_datetime = DateHelper().create_end_of_life_date(2024, 1, 31) | ||
link = "https://github.com/project-koku/koku/pull/4670" | ||
|
||
@method_decorator(never_cache) | ||
def get(self, request): | ||
""" | ||
Return a list of all settings. | ||
""" | ||
settings = self._build_settings(request) | ||
return Response(settings) | ||
|
||
def post(self, request): | ||
"""Handle all changed settings.""" | ||
if not isinstance(request.data, dict): | ||
msg = "Invalid input format." | ||
raise ValidationError({"details": gettext(msg)}) | ||
for settings_clazz in SETTINGS_GENERATORS.values(): | ||
instance = settings_clazz(request) | ||
instance.handle_settings(request.data) | ||
return Response() | ||
|
||
def _build_settings(self, request): | ||
settings = [] | ||
for settings_clazz in SETTINGS_GENERATORS.values(): | ||
instance = settings_clazz(request) | ||
settings += instance.build_settings() | ||
return settings |
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
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
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
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.