Ejemplo n.º 1
0
 def get_missing_fields(self, find_one=False):
     reviewed_fields = CompletedReviewField.get_for_applicant(self.applicant)
     required_fields = self.get_required_fields(excluded=reviewed_fields)
     missing = []
     for f in required_fields:
         if self.__getattribute__(f).name == "":
             missing.append(f)
     return missing
Ejemplo n.º 2
0
def confirm(request):
    applicant = request.applicant
    if ((not applicant.has_online_docs()) or
        (not applicant.appdocs.is_complete())):
        return HttpResponseRedirect(reverse('upload-index'))

    if request.method!='POST':
        docs = request.applicant.get_applicant_docs_or_none()
        fields = docs.get_upload_fields()
        completed_review_fields = CompletedReviewField.get_for_applicant(request.applicant)
        completed_review_field_names = [rf.short_name 
                                        for rf 
                                        in completed_review_fields]

        field_forms = populate_upload_field_forms(docs, fields)

        return render_to_response("upload/confirm.html",
                                  { 'applicant': request.applicant,
                                    'field_forms': field_forms,
                                    'completed_review_field_names':
                                        completed_review_field_names })

    else:
        if not 'submit' in request.POST:
            return render_to_response(
                'application/submission/not_submitted.html')

        if applicant.appdocs.is_complete():
            try:
                applicant.submit(Applicant.SUBMITTED_ONLINE)
            except Applicant.DuplicateSubmissionError:
                return render_to_response(
                    'commons/submission_already_submitted.html',
                    { 'applicant': applicant })

            send_submission_confirmation_by_email(applicant)
            return render_to_response('upload/submission_success.html',
                                      { 'applicant': applicant })
        else:
            missing_fields = applicant.appdocs.get_missing_fields()
            missing_field_names = [
                AppDocs.get_verbose_name_from_field_name(f)
                for f in missing_fields
                ]
            return index(request, missing_field_names)
Ejemplo n.º 3
0
def index(request, missing_fields=None):
    if not request.applicant.has_major_preference():
        return redirect_to_applicant_first_page(request.applicant)

    notice = extract_variable_from_session_or_none(request.session, 'notice')
    uploaded_field_error = extract_variable_from_session_or_none(
        request.session, 'error')

    docs = request.applicant.get_applicant_docs_or_none()
    if docs==None:
        docs = AppDocs(applicant=request.applicant)
        docs.save()
        request.applicant.add_related_model('appdocs', 
                                            save=True)

    completed_review_fields = CompletedReviewField.get_for_applicant(request.applicant)
    completed_review_field_names = [rf.short_name 
                                    for rf 
                                    in completed_review_fields]

    fields = docs.get_upload_fields()
    required_fields = docs.get_required_fields(
        excluded=completed_review_fields)

    if len(required_fields) == 0:
        return HttpResponseRedirect(reverse('upload-confirm'))

    field_forms = populate_upload_field_forms(docs, 
                                              fields,
                                              required_fields)

    form_step_info = { 'steps': UPLOAD_FORM_STEPS,
                       'current_step': 0,
                       'max_linked_step': 1 }
    return render_to_response("upload/form.html",
                              { 'applicant': request.applicant,
                                'field_forms': field_forms,
                                'form_step_info': form_step_info,
                                'notice': notice,
                                'missing_fields': missing_fields,
                                'completed_review_field_names':
                                    completed_review_field_names,
                                'uploaded_field_error':
                                    uploaded_field_error })