Beispiel #1
0
def decline_projectapplication(request, application_id):
    application = get_object_or_404(ProjectApplication, pk=application_id)

    if not request.user.get_profile() in application.institute.delegates.all():
        return HttpResponseForbidden('<h1>Access Denied</h1>')
    
    if application.state != Application.WAITING_FOR_DELEGATE:
        return render_to_response('applications/unable_to_approve.html', {'application': application}, context_instance=RequestContext(request))

    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            to_email = application.applicant.email
            subject, body = form.get_data()
            log(request.user, application.application_ptr, 3, 'Application declined')
            application.decline()
            send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email], fail_silently=False)
            return HttpResponseRedirect(reverse('kg_application_pendinglist'))

    else:
        subject, body = render_email('project_declined', {'receiver': application.applicant})
        initial_data = {'body': body, 'subject': subject}
        form = EmailForm(initial=initial_data)

    return render_to_response('applications/project_confirm_decline.html', {'application': application, 'form': form}, context_instance=RequestContext(request))
Beispiel #2
0
def decline_userapplication(request, application_id):
    application = get_object_or_404(UserApplication, pk=application_id)

    if application.state != Application.WAITING_FOR_ADMIN:
        raise Http404
    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            to_email = application.applicant.email
            subject, body = form.get_data()
            log(request.user, application.application_ptr, 3, 'Application declined')
            messages.success(request, "%s declined successfully." % application)
            application.decline()
            send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email], fail_silently=False)
            return HttpResponseRedirect(reverse('kg_application_list'))
    else:
        subject, body = render_email('account_declined', {'receiver': application.applicant, 'project': application.project})
        initial_data = {'body': body, 'subject': subject}
        form = EmailForm(initial=initial_data)

    return render_to_response('applications/confirm_decline.html', {'application': application, 'form': form}, context_instance=RequestContext(request))