def put(self, request, group, note_id):
if not request.user.is_authenticated():
raise PermissionDenied(detail="Key doesn't have permission to edit Note")
try:
note = Activity.objects.get(
group=group,
type=Activity.NOTE,
user=request.user,
id=note_id,
)
except Activity.DoesNotExist:
raise ResourceDoesNotExist
serializer = NoteSerializer(data=request.DATA)
if serializer.is_valid():
# Would be nice to have a last_modified timestamp we could bump here
note.data = dict(serializer.object)
note.save()
return Response(serialize(note, request.user), status=200)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
评论列表
文章目录