コード例 #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
ファイル: views.py プロジェクト: sfpiano/rbclone
def comment(request):
  if request.method == 'POST':
    form = CommentForm(request.POST)
    if form.is_valid():
      cd = form.cleaned_data
      return HttpResponseRedirect('/contact/thanks/')
  else:
    form = CommentForm()

  context = {}
  return render_to_response('diff/comment_form.html', {'form': form}, RequestContext(request, context))