def create(self, validated_data): print "In create" print validated_data annotation = Annotation() annotation.author = validated_data.get('author') annotation.body = validated_data.get('body') annotation.content_type = validated_data.get('content_type') annotation.object_id = validated_data.get('object_id') annotation.paragraph = validated_data.get('paragraph') annotation.privacy = validated_data.get('privacy') annotation.privacy_override = validated_data.get('privacy_override', False) #Get row from contentType which has content_type content_object = ContentType.objects.get_for_id(annotation.content_type.id) annotation.content_object = content_object.model_class().objects.get(id=annotation.object_id) print annotation.content_object annotation.save() print validated_data.get('shared_with') for user in validated_data.get('shared_with'): sharing = AnnotationShareMap(annotation=annotation, user=user) sharing.save() return annotation
def create_annotation(self, body='', paragraph=None): annotation = Annotation() annotation.content_type=ContentType.objects.get(model='blogcontent', app_label="blogging") annotation.object_id= str(1) annotation.body=body annotation.paragraph=paragraph annotation.author= User.objects.get(id=1) annotation.save()
def create_annotation(self, body='', paragraph=None): annotation = Annotation() annotation.content_type = ContentType.objects.get(model='blogcontent', app_label="blogging") annotation.object_id = str(1) annotation.body = body annotation.paragraph = paragraph annotation.author = User.objects.get(id=1) annotation.save()
def test_create_serializer_class(self): annotation = Annotation() annotation.content_type=ContentType.objects.get(model='blogcontent', app_label="blogging") annotation.object_id= str(1) annotation.body="This is a test annotation" annotation.paragraph="1" annotation.author= User.objects.get(id=1) annotation.save() obj = AnnotationSerializer(annotation) #print(obj.data) json = JSONRenderer().render(obj.data)
def test_create_serializer_class(self): annotation = Annotation() annotation.content_type = ContentType.objects.get(model='blogcontent', app_label="blogging") annotation.object_id = str(1) annotation.body = "This is a test annotations" annotation.paragraph = "1" annotation.author = User.objects.get(id=1) annotation.save() obj = AnnotationSerializer(annotation) #print(obj.data) json = JSONRenderer().render(obj.data)