Beispiel #1
0
    def should_redirect(cls, request, submissions, actions):
        excluded = []
        for submission in submissions:
            if has_final_determination(submission):
                excluded.append(submission)

        non_determine_states = set(actions) - set(
            DETERMINATION_OUTCOMES.keys())
        if not any(non_determine_states):
            if excluded:
                messages.warning(
                    request,
                    _('A determination already exists for the following submissions and they have been excluded: {submissions}'
                      ).format(submissions=', '.join(
                          [submission.title for submission in excluded]), ))

            submissions = submissions.exclude(
                id__in=[submission.id for submission in excluded])
            action = outcome_from_actions(actions)
            return HttpResponseRedirect(
                reverse_lazy('apply:submissions:determinations:batch') +
                "?action=" + action + "&submissions=" +
                ','.join([str(submission.id) for submission in submissions]) +
                "&next=" + parse.quote_plus(request.get_full_path()), )
        elif set(actions) != non_determine_states:
            raise ValueError(
                'Inconsistent states provided - please talk to an admin')
Beispiel #2
0
from django.utils.translation import gettext_lazy as _

from hypha.apply.funds.workflow import DETERMINATION_OUTCOMES

REJECTED = 0
NEEDS_MORE_INFO = 1
ACCEPTED = 2

DETERMINATION_CHOICES = (
    (REJECTED, _('Dismissed')),
    (NEEDS_MORE_INFO, _('More information requested')),
    (ACCEPTED, _('Approved')),
)

DETERMINATION_TO_OUTCOME = {
    'rejected': REJECTED,
    'accepted': ACCEPTED,
    'more_info': NEEDS_MORE_INFO,
}

TRANSITION_DETERMINATION = {
    name: DETERMINATION_TO_OUTCOME[type]
    for name, type in DETERMINATION_OUTCOMES.items()
}