<s> from rest_framework import permissions <EOL> from api . base . utils import get_user_auth <EOL> from website . files . models import FileNode <EOL> class CheckedOutOrAdmin ( permissions . BasePermission ) : <EOL> def has_object_permission ( self , request , view , obj ) : <EOL> assert isinstance ( obj , FileNode ) , '<STR_LIT>' . format ( obj ) <EOL> if request . method in permissions . SAFE_METHODS : <EOL> return True <EOL> auth = get_user_auth ( request ) <EOL> if obj . provider != '<STR_LIT>' : <EOL> return False <EOL> return obj . checkout is None or obj . checkout == auth . user or obj . node . has_permission ( auth . user , '<STR_LIT>' ) </s>
