Пример #1
0
def edit_project(request, pk):
    """
    Edit a given proposal. Only for staff that is allowed to edit the proposal. Time slot validation is handled in form.

    :param request:
    :param pk: pk of the proposal to edit.
    :return:
    """
    obj = get_object_or_404(Proposal, pk=pk)
    title = 'Edit Proposal'

    if request.method == 'POST':
        # only limited editing when status 4
        if obj.Status == 4:
            form = ProposalFormLimited(request.POST, request=request, instance=obj)
        else:
            form = ProposalFormEdit(request.POST, request.FILES, request=request, instance=obj)
        if form.is_valid():
            obj = form.save()
            if form.changed_data:
                update_cached_project(obj)
                check_content_policy.CPVCheckThread(obj).start()
                if obj.Private.all():
                    for std in obj.Private.all():
                        mail_proposal_private(obj, std, "Your private proposal was edited.")
            return render(request, "proposals/message_project.html", {"Message": "Proposal saved!", "Proposal": obj})
    else:
        if obj.Status == 4:
            form = ProposalFormLimited(request=request, instance=obj)
            title = 'Edit active Proposal'
        else:
            form = ProposalFormEdit(request=request, instance=obj)
    return render(request, 'GenericForm.html', {'form': form, 'formtitle': title, 'buttontext': 'Save'})
Пример #2
0
def create_project(request):
    """
    Create a new proposal. Only for staff. Generating a new proposal for this timeslot is only allowed in the first
    timephase. In other timephases projects can only be generated for the next timeslot.

    :param request:
    :return:
    """
    if request.method == 'POST':
        form = ProposalFormCreate(request.POST, request=request)
        if form.is_valid():
            prop = form.save()
            mail_proposal_all(request, prop)
            check_content_policy.CPVCheckThread(prop).start()
            if prop.Private.all():
                for std in prop.Private.all():
                    mail_proposal_private(prop, std, "A private proposal was created for you.")
            return render(request, "proposals/message_project.html", {"Message": "Proposal created!", "Proposal": prop})
    else:
        init = {}
        if get_grouptype("1") in request.user.groups.all():
            init["ResponsibleStaff"] = request.user.id
        elif get_grouptype("2") in request.user.groups.all() or get_grouptype('2u'):
            init["Assistants"] = [request.user.id]
        form = ProposalFormCreate(request=request, initial=init)
    if get_timephase_number() == 1:
        return render(request, 'GenericForm.html', {'form': form,
                                                    'formtitle': 'Create new Proposal',
                                                    'buttontext': 'Create and go to next step'})
    else:
        return render(request, 'GenericForm.html', {'form': form,
                                                    'formtitle': 'Create new Proposal (For next timeslot)',
                                                    'buttontext': 'Create and go to next step'})
Пример #3
0
def content_policy_calc(request):
    """
    List of proposal description/assignment texts that do not met the expected text.
    Example of a policy violation is an email address in a proposal description.

    :param request:
    """
    projects = get_all_projects(old=False)
    check_content_policy.CPVCheckThread(projects).start()
    return render(request, "proposals/cpv_progress.html")