<s> from tastypie . authorization import DjangoAuthorization <EOL> from panda . api . utils import PandaAuthentication , PandaSerializer , PandaModelResource <EOL> from panda . models import Notification , UserProxy <EOL> class NotificationResource ( PandaModelResource ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> queryset = Notification . objects . all ( ) <EOL> resource_name = '<STR_LIT>' <EOL> authentication = PandaAuthentication ( ) <EOL> authorization = DjangoAuthorization ( ) <EOL> serializer = PandaSerializer ( ) <EOL> filtering = { <EOL> "<STR_LIT>" : ( '<STR_LIT>' ) <EOL> } <EOL> def obj_create ( self , bundle , request = None , ** kwargs ) : <EOL> user = UserProxy . objects . get ( id = request . user . id ) <EOL> return super ( NotificationResource , self ) . obj_create ( bundle , request , recipient = user ) <EOL> def apply_authorization_limits ( self , request , object_list ) : <EOL> user = UserProxy . objects . get ( id = request . user . id ) <EOL> return object_list . filter ( recipient = user ) <EOL> def save_related ( self , bundle ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def put_list ( self , request , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if request . GET . get ( '<STR_LIT>' , '<STR_LIT:false>' ) . lower ( ) == '<STR_LIT:true>' : <EOL> return super ( NotificationResource , self ) . patch_list ( request , ** kwargs ) <EOL> else : <EOL> return super ( NotificationResource , self ) . put_list ( request , ** kwargs ) </s>
