예제 #1
0
def handle_poll_submit(request):
    if not request.method == 'POST':
        log.sec_req(request, "Tried to hit poll submit URL by GET.")
        raise Http404
    
    poll_id = request.POST['poll_id']
    vote_id = request.POST['vote_id']
    current_poll = FlowgramPoll.objects.get(id=poll_id)
    
    # increment votes and save
    if vote_id == current_poll.candidate_id_1:
        current_poll.votes_1 += 1
    elif vote_id == current_poll.candidate_id_2:
        current_poll.votes_2 += 1
    elif vote_id == current_poll.candidate_id_3:
        current_poll.votes_3 += 1
    current_poll.save()
    
    current_poll_fg1 = Flowgram.objects.get(id=current_poll.candidate_id_1)
    current_poll_fg2 = Flowgram.objects.get(id=current_poll.candidate_id_2)
    current_poll_fg3 = Flowgram.objects.get(id=current_poll.candidate_id_3)
    
    return req_render_to_response(request, 'includes/modules/other_content/poll_module_results.incl', {
        'current_poll': current_poll,
        'current_poll_fg1': current_poll_fg1,
        'current_poll_fg2': current_poll_fg2,
        'current_poll_fg3': current_poll_fg3,
    })
예제 #2
0
def delete_comment(request, enc, comment_id):
    comment = get_object_or_404(models.Comment, id=comment_id)

    if not permissions.can_edit(request.user, comment.flowgram):
        log.sec_req(request, "User tried to delete comment on flowgram %s." % (comment.flowgram.id))
        raise Http404

    comment.delete()

    controller.record_stat(request, 'del_comment_website', '0', comment_id)
    return helpers.go_back(request)