Beispiel #1
0
def cancel_proposal(proposal):
    results = {}
    if proposal.type == ProposalType.CREATION.name:
        learning_unit_year = proposal.learning_unit_year

        errors = list(business_deletion.check_can_delete_ignoring_proposal_validation(learning_unit_year).values())

        if errors:
            results = {ERROR: errors}
        else:
            results = {SUCCESS: business_deletion.delete_from_given_learning_unit_year(learning_unit_year)}
            delete_learning_unit_proposal(proposal, True)
    else:
        reinitialize_data_before_proposal(proposal)
        delete_learning_unit_proposal(proposal, False)

    return results
Beispiel #2
0
def cancel_proposal(learning_unit_proposal, author=None, send_mail=False):
    acronym = learning_unit_proposal.learning_unit_year.acronym
    academic_year = learning_unit_proposal.learning_unit_year.academic_year
    error_messages = []
    success_messages = []
    if learning_unit_proposal.type == ProposalType.CREATION.name:
        learning_unit_year = learning_unit_proposal.learning_unit_year
        error_messages.extend(
            business_deletion.check_can_delete_ignoring_proposal_validation(
                learning_unit_year))
        if not error_messages:
            success_messages.extend(
                business_deletion.delete_from_given_learning_unit_year(
                    learning_unit_year))
    else:
        reinitialize_data_before_proposal(learning_unit_proposal)
    delete_learning_unit_proposal(learning_unit_proposal)
    success_messages.append(
        _("success_cancel_proposal").format(acronym=acronym,
                                            academic_year=academic_year))
    if send_mail and author is not None:
        send_mail_util.send_mail_after_the_learning_unit_proposal_cancellation(
            [author], [learning_unit_proposal])
    return {SUCCESS: success_messages, ERROR: error_messages}