Skip to content

Commit

Permalink
clean-up waffling code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed May 22, 2024
1 parent 41c0e85 commit 7a55c02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions api/nodes/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import waffle
from distutils.version import StrictVersion
from django.apps import apps
from django.db.models import Q, OuterRef, Exists, Subquery, CharField, Value, BooleanField
Expand All @@ -14,7 +13,6 @@
from osf.models import AbstractNode, Preprint, Guid, NodeRelation, Contributor
from osf.models.node import NodeGroupObjectPermission
from osf.utils import permissions
from osf import features

from api.base.exceptions import ServiceUnavailableError
from api.base.utils import get_object_or_error, waterbutler_api_url_for, get_user_auth, has_admin_scope
Expand All @@ -40,10 +38,7 @@ def get_file_object(target, path, provider, request):
obj = get_object_or_error(model, Q(target_object_id=target.pk, target_content_type=content_type, _id=path.strip('/')), request)
return obj

if waffle.flag_is_active(request, features.ENABLE_GV):
addon = target.get_addon(provider, request=request)
else:
addon = super(target.__class__, target).get_addon(provider, request=request)
addon = target.get_addon(provider, request=request)

if isinstance(target, AbstractNode) and not addon or not addon.configured:
raise NotFound(f'The {provider} provider is not configured for this project.')
Expand Down
4 changes: 2 additions & 2 deletions osf/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2435,11 +2435,11 @@ def _remove_from_associated_collections(self, auth=None, force=False):
def get_addon(self, name, is_deleted=False):
request, user_id = get_request_and_user_id()

if hasattr(request, 'user') and not isinstance(request.user, AnonymousUser) and waffle.flag_is_active(request, features.ENABLE_GV) and name not in ['osfstorage', 'wiki']:
if waffle.flag_is_active(request, features.ENABLE_GV):
return GravyValetAddonAppConfig(
self,
name,
auth=(request.user.username, request.user.password)
auth=Auth(request.user)
).node_settings
else:
return super().get_addon(name, is_deleted)
Expand Down
4 changes: 2 additions & 2 deletions osf/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,11 @@ def create_unregistered(cls, fullname, email=None):
def get_addon(self, name, is_deleted=False):
request, user_id = get_request_and_user_id()

if hasattr(request, 'user') and waffle.flag_is_active(request, features.ENABLE_GV) and name not in ['osfstorage', 'wiki']:
if waffle.flag_is_active(request, features.ENABLE_GV):
return GravyValetAddonAppConfig(
self,
name,
auth=(request.user.username, request.user.password)
auth=Auth(request.user)
).user_settings
else:
return super().get_addon(name, is_deleted)
Expand Down

0 comments on commit 7a55c02

Please sign in to comment.