def create_comment(request, comment_data):
 thread_id = comment_data.get('thread_id')
 if (not thread_id):
  raise ValidationError({'thread_id': ['This field is required.']})
 (cc_thread, context) = _get_thread_and_context(request, thread_id)
 if cc_thread['closed']:
  raise PermissionDenied
 _check_initializable_comment_fields(comment_data, context)
 serializer = CommentSerializer(data=comment_data, context=context)
 actions_form = CommentActionsForm(comment_data)
 if (not (serializer.is_valid() and actions_form.is_valid())):
  raise ValidationError(dict((serializer.errors.items() + actions_form.errors.items())))
 serializer.save()
 cc_comment = serializer.instance
 comment_created.send(sender=None, user=request.user, post=cc_comment)
 api_comment = serializer.data
 _do_extra_actions(api_comment, cc_comment, comment_data.keys(), actions_form, context, request)
 track_comment_created_event(request, context['course'], cc_comment, cc_thread['commentable_id'], followed=False)
 return api_comment

def create_comment ( request , comment_data ) : thread_id = comment_data . get ( 'thread_id' ) if ( not thread_id ) : raise ValidationError ( { 'thread_id' : [ 'This field is required.' ] } ) ( cc_thread , context ) = _get_thread_and_context ( request , thread_id ) if cc_thread [ 'closed' ] : raise PermissionDenied _check_initializable_comment_fields ( comment_data , context ) serializer = CommentSerializer ( data = comment_data , context = context ) actions_form = CommentActionsForm ( comment_data ) if ( not ( serializer . is_valid ( ) and actions_form . is_valid ( ) ) ) : raise ValidationError ( dict ( ( serializer . errors . items ( ) + actions_form . errors . items ( ) ) ) ) serializer . save ( ) cc_comment = serializer . instance comment_created . send ( sender = None , user = request . user , post = cc_comment ) api_comment = serializer . data _do_extra_actions ( api_comment , cc_comment , comment_data . keys ( ) , actions_form , context , request ) track_comment_created_event ( request , context [ 'course' ] , cc_comment , cc_thread [ 'commentable_id' ] , followed = False ) return api_comment
create a comment .