示例#1
0
def save_comment(request):
    if request.POST:
        human_form = HumanityForm(request.POST)
        if human_form.is_valid():
            return post_comment(request)
    else:
        raise Http404, "All you do is GET, GET, GET. How about you POST every once in a while like you used to at the beginning of our relationship?"
示例#2
0
def section_detail(request, legislation_slug, title_num, section_num):
    
    if request.method == 'POST':
        human_form = HumanityForm(request.POST, label_suffix='')
        is_human = request.POST.get('humanity', 'robot') == 'human'
        if is_human or human_form.is_valid():
            return post_comment(request)
    else:
        human_form = HumanityForm(label_suffix='')
    
    section_num = int(section_num)
    section = Section.objects.get(number=section_num, title__number=title_num, title__legislation__slug=legislation_slug)
    try:
        next_section = Section.objects.get(number=section_num + 1, title__number=title_num, title__legislation__slug=legislation_slug)
    except Section.DoesNotExist:
        next_section = None
    try:
        previous_section = Section.objects.get(number=section_num - 1, title__number=title_num, title__legislation__slug=legislation_slug)
    except Section.DoesNotExist:
        previous_section = None
    data = {
        'legislation': section.title.legislation,
        'title': section.title,
        'section': section,
        'next_section': next_section,
        'previous_section': previous_section,
        'human_form': human_form,
    }
    return render_to_response("legislation/section_detail.html", data,
                              context_instance=RequestContext(request))
示例#3
0
def save_comment(request):
    if request.POST:
        human_form = HumanityForm(request.POST)
        if human_form.is_valid():
            return post_comment(request)
    else:
        raise Http404, "All you do is GET, GET, GET. How about you POST every once in a while like you used to at the beginning of our relationship?"
示例#4
0
def legislation_detail(request, legislation_slug):

    try:
        legislation = Legislation.objects.get(slug=legislation_slug)
    except Legislation.DoesNotExist:
        return HttpResponseRedirect('/')

    if request.method == 'POST':
        human_form = HumanityForm(request.POST, label_suffix='')
        is_human = request.POST.get('humanity', 'robot') == 'human'
        if is_human or human_form.is_valid():
            return post_comment(request)
    else:
        human_form = HumanityForm(label_suffix='')

    data = {
        'legislation': legislation,
        'human_form': human_form,
    }

    return render(request, "legislation/legislation_detail.html", data)
示例#5
0
def section_detail(request, legislation_slug, title_num, section_num):

    if request.method == 'POST':
        human_form = HumanityForm(request.POST, label_suffix='')
        is_human = request.POST.get('humanity', 'robot') == 'human'
        if is_human or human_form.is_valid():
            return post_comment(request)
    else:
        human_form = HumanityForm(label_suffix='')

    section_num = int(section_num)
    section = Section.objects.get(number=section_num,
                                  title__number=title_num,
                                  title__legislation__slug=legislation_slug)
    try:
        next_section = Section.objects.get(
            number=section_num + 1,
            title__number=title_num,
            title__legislation__slug=legislation_slug)
    except Section.DoesNotExist:
        next_section = None
    try:
        previous_section = Section.objects.get(
            number=section_num - 1,
            title__number=title_num,
            title__legislation__slug=legislation_slug)
    except Section.DoesNotExist:
        previous_section = None
    data = {
        'legislation': section.title.legislation,
        'title': section.title,
        'section': section,
        'next_section': next_section,
        'previous_section': previous_section,
        'human_form': human_form,
    }
    return render_to_response("legislation/section_detail.html",
                              data,
                              context_instance=RequestContext(request))
示例#6
0
def legislation_detail(request, legislation_slug):

    try:
        legislation = Legislation.objects.get(slug=legislation_slug)
    except Legislation.DoesNotExist:
        return HttpResponseRedirect('/')

    if request.method == 'POST':
        human_form = HumanityForm(request.POST, label_suffix='')
        is_human = request.POST.get('humanity', 'robot') == 'human'
        if is_human or human_form.is_valid():
            return post_comment(request)
    else:
        human_form = HumanityForm(label_suffix='')

    data = {
        'legislation': legislation,
        'human_form': human_form,
    }

    return render_to_response("legislation/legislation_detail.html",
                              data,
                              context_instance=RequestContext(request))