Пример #1
0
def complete_profile(request):
    """ An authenticated *applicant* is trying to access an application. """
    application = trial_application_get_or_create(request.user.pk)
    state_machine = base.get_state_machine(application)
    return state_machine.process(request, application,
                                 expected_state=None,
                                 label=None)
Пример #2
0
def application_unauthenticated(request, token, state=None, label=None):
    """ An unauthenticated user is trying to access an application. """
    application = base.get_application(secret_token=token, expires__gt=datetime.datetime.now())

    # redirect user to real url if possible.
    if request.user.is_authenticated():
        if request.user == application.applicant:
            url = base.get_url(request, application, {"is_applicant": True}, label)
            return HttpResponseRedirect(url)

    state_machine = base.get_state_machine(application)
    return state_machine.process(request, application, state, label, {"is_applicant": True})
Пример #3
0
def invitation_token(request, token, state=None, label=None):
    """An authenticated user is trying to access an application using
    a token."""
    application = base.get_application(
        secret_token=token, expires__gt=datetime.datetime.now())

    # If the applicant is a real Person, don't allow the application
    # to be stolen.
    if application.content_type.model != 'applicant':
        return redirect('index')

    # redirect user to real url if possible.
    if request.user.is_authenticated():
        if request.user == application.applicant:
            url = base.get_url(request, application, {'is_applicant': True},
                               label)
            return HttpResponseRedirect(url)

    state_machine = base.get_state_machine(application)
    return state_machine.process(request, application, state, label,
                                 {'is_applicant': True})
Пример #4
0
def application_detail(request, application_id, state=None, label=None):
    """ An authenticated admin is trying to access an application. """
    application = base.get_application(pk=application_id)
    state_machine = base.get_state_machine(application)
    return state_machine.process(request, application, state, label, { 'is_admin': True })
Пример #5
0
def application_simple_state(context, application):
    """ Render current state of application, verbose. """
    state_machine = get_state_machine(application)
    state = state_machine.get_state(application)
    return state.name
Пример #6
0
 def render_state(self, record):
     state_machine = get_state_machine(record)
     state = state_machine.get_state(record)
     return state.name