Ejemplo n.º 1
0
def merged_proposal(request, space_url, p_set):
    """
    Create a new merged proposal. This proposal can be linked to many other proposals which are in the
    same proposal set. Only admin and moderator can create merged proposals.

    .. versionadded:: 0.1.5

    :arguments: space_url, p_set
    :context:form, get_place, form_field

    """

    get_place = get_object_or_404(Space, url=space_url)
    field = ProposalField.objects.filter(proposalset=p_set)
    form_field = [f_name.field_name for f_name in field]
    if request.method == 'POST':
        merged_form = ProposalForm(request.POST)
        if merged_form.is_valid():
            form_data = merged_form.save(commit=False)
            form_data.proposalset = get_object_or_404(ProposalSet, pk=p_set)
            form_data.space = get_object_or_404(Space, url=space_url)
            form_data.author = request.user
            form_data.merged = True
            field = ProposalField.objects.filter(proposalset=p_set)
            form_field = [f_name.field_name for f_name in field]
            form_data.save()
            merged_form.save_m2m()
            return redirect('/spaces/' + space_url + '/')
    else:
        merged_form = ProposalMergeForm(initial={'p_set': p_set})

    return render_to_response("proposals/proposal_merged.html",{'form':merged_form, 'get_place':get_place, \
                                'form_field':form_field},context_instance = RequestContext(request))
Ejemplo n.º 2
0
def merged_proposal(request, space_url, p_set):
    
    """
    Create a new merged proposal. This proposal can be linked to many other proposals which are in the
    same proposal set. Only admin and moderator can create merged proposals.

    .. versionadded:: 0.1.5

    :arguments: space_url, p_set
    :context:form, get_place, form_field

    """


    get_place = get_object_or_404(Space, url=space_url)
    field = ProposalField.objects.filter(proposalset=p_set)
    form_field = [f_name.field_name for f_name in field]
    if request.method == 'POST':
        merged_form = ProposalForm(request.POST)
        if merged_form.is_valid():
            form_data = merged_form.save(commit=False)
            form_data.proposalset = get_object_or_404(ProposalSet, pk=p_set)
            form_data.space = get_object_or_404(Space, url=space_url)
            form_data.author = request.user
            form_data.merged = True
            field = ProposalField.objects.filter(proposalset=p_set)
            form_field = [f_name.field_name for f_name in field]
            form_data.save()
            merged_form.save_m2m()
            return redirect('/spaces/'+ space_url +'/')
    else: 
        merged_form = ProposalMergeForm(initial={'p_set':p_set})

    return render_to_response("proposals/proposal_merged.html",{'form':merged_form, 'get_place':get_place, \
                                'form_field':form_field},context_instance = RequestContext(request))
Ejemplo n.º 3
0
def merge_proposal(request, space_url, set_id):
    """
    Create a new merged proposal. This proposal can be linked to many other proposals which are in the
    same proposal set. Only admin and moderator can create merged proposals.

    .. versionadded:: 0.1.5

    :arguments: space_url, p_set
    :context:form, get_place, form_field

    """
    get_place = get_object_or_404(Space, url=space_url)
    field = ProposalField.objects.filter(proposalset=set_id)
    form_field = [f_name.field_name for f_name in field]

    if (request.user.has_perm('admin_space', get_place)
            or request.user.has_perm('mod_space', get_place)):
        if request.method == 'POST':
            merged_form = ProposalForm(request.POST)
            if merged_form.is_valid():
                form_data = merged_form.save(commit=False)
                form_data.proposalset = get_object_or_404(ProposalSet,
                                                          pk=set_id)
                form_data.space = get_object_or_404(Space, url=space_url)
                form_data.author = request.user
                form_data.merged = True
                field = ProposalField.objects.filter(proposalset=set_id)
                form_field = [f_name.field_name for f_name in field]
                form_data.save()
                merged_form.save_m2m()

                return reverse(urln_space.SPACE_INDEX,
                               kwargs={'space_url': space_url})
        else:
            print "id: " + set_id
            merged_form = ProposalMergeForm(initial={'set_id': set_id})

        return render_to_response("proposals/proposal_merged.html", {
            'form': merged_form,
            'get_place': get_place,
            'form_field': form_field
        },
                                  context_instance=RequestContext(request))
    else:
        raise PermissionDenied
Ejemplo n.º 4
0
def merge_proposal(request, space_url, set_id):

    """
    Create a new merged proposal. This proposal can be linked to many other proposals which are in the
    same proposal set. Only admin and moderator can create merged proposals.

    .. versionadded:: 0.1.5

    :arguments: space_url, p_set
    :context:form, get_place, form_field

    """
    get_place = get_object_or_404(Space, url=space_url)
    field = ProposalField.objects.filter(proposalset=set_id)
    form_field = [f_name.field_name for f_name in field]

    if (request.user.has_perm('admin_space', get_place) or
        request.user.has_perm('mod_space', get_place)):
        if request.method == 'POST':
            merged_form = ProposalForm(request.POST)
            if merged_form.is_valid():
                form_data = merged_form.save(commit=False)
                form_data.proposalset = get_object_or_404(ProposalSet, pk=set_id)
                form_data.space = get_object_or_404(Space, url=space_url)
                form_data.author = request.user
                form_data.merged = True
                field = ProposalField.objects.filter(proposalset=set_id)
                form_field = [f_name.field_name for f_name in field]
                form_data.save()
                merged_form.save_m2m()

                return reverse(urln_space.SPACE_INDEX,
                    kwargs={'space_url': space_url})
        else:
            print "id: " + set_id
            merged_form = ProposalMergeForm(initial={'set_id': set_id})

        return render_to_response("proposals/proposal_merged.html",
            {'form': merged_form, 'get_place': get_place, 'form_field': form_field}, context_instance=RequestContext(request))
    else:
        raise PermissionDenied