5656
5757AP_TARGET = {"cc" : "https://www.w3.org/ns/activitystreams#Public" }
5858
59+ OBJ_Map = {
60+ "Note" : "note-page" ,
61+ "Review" : "review-page" ,
62+ "Repository" : "repository-page" ,
63+ "Vulnerability" : "vulnerability-page" ,
64+ }
65+
5966
6067def check_and_r_ap_context (request ):
6168 """
@@ -270,19 +277,13 @@ def save(self):
270277
271278 def succeeded_ap_rs (self , new_obj ):
272279 """Response for successfully deleting the object"""
273- Obj_Map = {
274- "Note" : "note-page" ,
275- "Review" : "review-page" ,
276- "Repository" : "repository-page" ,
277- "Vulnerability" : "vulnerability-page" ,
278- }
279280 return JsonResponse (
280- {"Location" : full_reverse (Obj_Map [self .object .type ], new_obj .id )}, status = 201
281+ {"Location" : full_reverse (OBJ_Map [self .object .type ], new_obj .id )}, status = 201
281282 )
282283
283284 def failed_ap_rs (self ):
284285 """Response for failure deleting the object"""
285- return JsonResponse ({ self . object }, status = 405 )
286+ return HttpResponseBadRequest ( "Invalid Create Activity request" )
286287
287288 def to_ap (self ):
288289 """Request for creating object in activitypub format"""
@@ -309,19 +310,20 @@ def save(self):
309310 }
310311
311312 if (
312- (isinstance (actor , Person ) and self .object .type in ["Note" , "Review" ])
313- or (isinstance (actor , Service ) and self .object .type == "Repository" )
314- or (isinstance (actor , Purl ) and self .object .type == "Note" )
313+ (isinstance (actor , Person ) and self .object .type in ["Note" , "Review" ])
314+ or (isinstance (actor , Service ) and self .object .type == "Repository" )
315+ or (isinstance (actor , Purl ) and self .object .type == "Note" )
315316 ):
316317 for key , value in updated_param [self .object .type ].items ():
317318 if value :
318319 setattr (old_obj , key , value )
319320 old_obj .save ()
320- return "TODO"
321321
322- def succeeded_ap_rs (self ):
322+ return self .succeeded_ap_rs (old_obj .to_ap )
323+
324+ def succeeded_ap_rs (self , update_obj ):
323325 """Response for successfully deleting the object"""
324- return JsonResponse ({ self . object } , status = 410 )
326+ return JsonResponse (update_obj , status = 200 )
325327
326328 def failed_ap_rs (self ):
327329 """Response for failure deleting the object"""
@@ -344,9 +346,9 @@ def save(self):
344346 return self .failed_ap_rs ()
345347
346348 if (
347- (type (actor ) is Person and self .object .type in ["Note" , "Review" ])
348- or (type (actor ) is Purl and self .object .type in ["Note" ])
349- or (type (actor ) is Service and self .object .type == ["Repository" , "Purl" ])
349+ (type (actor ) is Person and self .object .type in ["Note" , "Review" ])
350+ or (type (actor ) is Purl and self .object .type in ["Note" ])
351+ or (type (actor ) is Service and self .object .type == ["Repository" , "Purl" ])
350352 ):
351353 instance = self .object .get_object ()
352354 instance .delete ()
@@ -360,7 +362,7 @@ def ap_rq(self):
360362
361363 def succeeded_ap_rs (self ):
362364 """Response for successfully deleting the object"""
363- return JsonResponse (asdict ( self . object ) , status = 410 )
365+ return JsonResponse ({ "message" : "The object has been deleted successfully" } , status = 200 )
364366
365367 def failed_ap_rs (self ):
366368 """Response for failure deleting the object"""
0 commit comments