Beispiel #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
Beispiel #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)
Beispiel #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 })
Beispiel #4
0
 def _set_all_fields_as_reviewed(self):
     for rf in ReviewField.objects.all():
         cf = CompletedReviewField(national_id='0000000000000',
                                   review_field=rf)
         cf.save()
Beispiel #5
0
import sys

if len(sys.argv)!=2:
    print "Usage: import_completed_review_fields [input.csv]"
    quit()
file_name = sys.argv[1]

from django.conf import settings
from django_bootstrap import bootstrap
bootstrap(__file__)

from review.models import ReviewField, CompletedReviewField
from utils import get_submitted_applicant_dict

review_fields = dict([(r.short_name, r)
                      for r in ReviewField.objects.all()])

for line in open(file_name):
    items = line.strip().split(',')
    nat_id = items[0]
    fields = items[1:]

    for f in fields:
        if f in review_fields:
            rf = CompletedReviewField(national_id=nat_id,
                                      review_field=review_fields[f])
            rf.save()
    print nat_id