def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) project_comment = models.ProjectComment.objects.create(project_id=kwargs['project'], comment_id=comment.id) return {'id': project_comment.id, 'comment': comment}
def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) task_comment = models.TaskComment.objects.create(task_id=kwargs['task'], comment_id=comment.id) return {'id': task_comment.id, 'comment': comment}
def create(self, **kwargs): comment_data = self.validated_data.pop("comment") comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs["sender"]) task_comment = models.TaskComment.objects.create(task_id=kwargs["task"], comment_id=comment.id) return {"id": task_comment.id, "comment": comment}
def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) module_comment = models.ModuleComment.objects.create(module_id=kwargs['module'], comment_id=comment.id) return {'id': module_comment.id, 'comment': comment}
def create(self, **kwargs): comment_data = self.validated_data.pop("comment") comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs["sender"]) project_comment = models.ProjectComment.objects.create(project_id=kwargs["project"], comment_id=comment.id) return {"id": project_comment.id, "comment": comment}
def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) module_comment = models.ModuleComment.objects.create( module_id=kwargs['module'], comment_id=comment.id) return {'id': module_comment.id, 'comment': comment}
class TaskCommentSerializer(DynamicFieldsModelSerializer): comment = CommentSerializer() class Meta: model = models.TaskComment fields = ('id', 'task', 'comment') read_only_fields = ('task',) def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) task_comment = models.TaskComment.objects.create(task_id=kwargs['task'], comment_id=comment.id) return {'id': task_comment.id, 'comment': comment}
class ProjectCommentSerializer(DynamicFieldsModelSerializer): comment = CommentSerializer(fields=('id', 'body', 'sender_alias')) class Meta: model = models.ProjectComment fields = ('id', 'project', 'comment', 'ready_for_launch') read_only_fields = ('project', ) def create(self, **kwargs): comment_data = self.validated_data.pop('comment') comment_serializer = CommentSerializer(data=comment_data) if comment_serializer.is_valid(): comment = comment_serializer.create(sender=kwargs['sender']) project_comment = models.ProjectComment.objects.create( project_id=kwargs['project'], comment_id=comment.id, ready_for_launch=kwargs['ready_for_launch']) return {'id': project_comment.id, 'comment': comment}