示例#1
0
    def delete(self, request, image_id):
        filters = { '_id': ObjectId(image_id) }

        old_image = Image.objects.get(**filters)

        image_archive = Image(**old_image.to_mongo().to_dict())
        image_archive.status = 'archived'
        image_archive.archived_at = datetime.datetime.utcnow()
        image_archive.switch_collection('images_archive')
        image_archive.save()

        old_image.delete()

        return HttpResponse(image_archive.to_json())