<s> from django import http <EOL> from rest_framework . exceptions import NotFound <EOL> from rest_framework import permissions as drf_permissions <EOL> from framework . guid . model import Guid <EOL> from framework . auth . oauth_scopes import CoreScopes , ComposedScopes <EOL> from api . base . exceptions import EndpointNotImplementedError <EOL> from api . base import permissions as base_permissions <EOL> from api . base . views import JSONAPIBaseView <EOL> class GuidRedirect ( JSONAPIBaseView ) : <EOL> """<STR_LIT>""" <EOL> permission_classes = ( <EOL> drf_permissions . IsAuthenticatedOrReadOnly , <EOL> base_permissions . TokenHasScope , <EOL> ) <EOL> required_read_scopes = [ ComposedScopes . FULL_READ ] <EOL> required_write_scopes = [ CoreScopes . NULL ] <EOL> view_category = '<STR_LIT>' <EOL> view_name = '<STR_LIT>' <EOL> def get_serializer_class ( self ) : <EOL> return None <EOL> def get ( self , request , ** kwargs ) : <EOL> url = self . get_redirect_url ( ** kwargs ) <EOL> if url : <EOL> return http . HttpResponseRedirect ( url ) <EOL> raise NotFound <EOL> def get_redirect_url ( self , ** kwargs ) : <EOL> guid = Guid . load ( kwargs [ '<STR_LIT>' ] ) <EOL> if guid : <EOL> referent = guid . referent <EOL> if getattr ( referent , '<STR_LIT>' , None ) : <EOL> return referent . absolute_api_v2_url <EOL> else : <EOL> raise EndpointNotImplementedError ( ) <EOL> return None </s>
