예제 #1
0
파일: views.py 프로젝트: sfpiano/rbclone
def createComment(request, set_id, file_id):
  if request.method == 'POST':
    try:
      user = User.objects.get(pk=request.user.id)
    except User.DoesNotExist:
      # TODO
      print "User not found"

    form = CommentForm(request.POST)
    if form.is_valid():
      cd = form.cleaned_data

      # This method handles comment creation and modification
      if int(request.POST['comment_id']) > 0:
        comment = DiffComment.objects.get(pk=request.POST['comment_id'])
        comment.comment = cd['message']
      else:
        comment = DiffComment(
          comment=cd['message'],
          line_number=cd['line_number'],
          user_id=user,
          file_id=FileDiff.objects.get(pk=file_id))
      comment.save()

  return HttpResponseRedirect(reverse('reviews.views.diff',
                              args=(set_id,file_id)))
예제 #2
0
파일: analyzer.py 프로젝트: sfpiano/rbclone
def analyze(fileID):
  try:
    filediff = FileDiff.objects.get(pk=fileID)
  except:
    return

  length_limit = 80

  if filediff.deleted:
    return

  stylebot = User.objects.get(username='******')

  for index, line in enumerate(filediff.get_new_file().file_data.split('\n')):
    if len(line) > length_limit:
      comment = DiffComment(
                  user_id=stylebot,
                  file_id=filediff,
                  comment="Exceeds %d characters" % length_limit,
                  line_number=index+1)
      comment.save()