Ejemplo n.º 1
0
def publish_issue(request, issue_id):
    """
    publish or not to publish issue
    """
    if request.method != "POST":
        return HttpResponseBadRequest

    issue = get_object_or_404(Issue, id=issue_id, user=request.user)
    
    form = Publish(request.POST)
    
    if form.is_valid(): 
        issue.is_draft = True if form.cleaned_data['is_draft'] else False
        issue.save()

    next = request.REQUEST.get('next', '/' )
    return HttpResponseRedirect(next) 
Ejemplo n.º 2
0
def xhr_publish_issue(request, issue_id):
    if request.method == 'GET':
        return json_error_response(
            'XMLHttpRequest votes can only be made using POST.')
    if not request.user.is_authenticated():
        return json_error_response('Not authenticated.')

    try:
        issue = Issue.objects.get(id=issue_id, user=request.user)
    except ObjectDoesNotExist:
        return json_error_response('No Issue found ') 

    form = Publish(request.POST)
    if form.is_valid(): 
        issue.is_draft = True if form.cleaned_data['is_draft'] else False
        issue.save()

    return HttpResponse(simplejson.dumps({
        'success': True,
    }))
Ejemplo n.º 3
0
def publish_issue(request, issue_id):
    """
    publish or not to publish issue
    """
    if request.is_ajax():
        return xhr_publish_issue(request, issue_id)

    if request.method != "POST" or not request.user.is_authenticated():
        return HttpResponseBadRequest

    issue = get_object_or_404(Issue, id=issue_id, user=request.user)

    form = Publish(request.POST)

    if form.is_valid():
        issue.is_draft = True if form.cleaned_data['is_draft'] else False
        issue.save()

    next = request.REQUEST.get('next', '/')
    return HttpResponseRedirect(next)
Ejemplo n.º 4
0
def xhr_publish_issue(request, issue_id):
    if request.method == 'GET':
        return json_error_response(
            'XMLHttpRequest votes can only be made using POST.')
    if not request.user.is_authenticated():
        return json_error_response('Not authenticated.')

    try:
        issue = Issue.objects.get(id=issue_id, user=request.user)
    except ObjectDoesNotExist:
        return json_error_response('No Issue found ')

    form = Publish(request.POST)
    if form.is_valid():
        issue.is_draft = True if form.cleaned_data['is_draft'] else False
        issue.save()

    return HttpResponse(simplejson.dumps({
        'success': True,
    }))