Exemplo n.º 1
0
    def testForOneFormSubmitted(self):
        """Tests the behavior when one form has been submitted."""
        # only enrollment form is submitted but not verified
        self.profile.student_data.consent_form = None
        self.profile.student_data.enrollment_form = ndb.BlobKey('blob-key')
        self.profile.student_data.is_enrollment_form_verified = False
        self.assertFalse(profile_logic.isFormVerificationAwaiting(
            self.profile))

        # only enrollment form is submitted and verified
        self.profile.student_data.is_enrollment_form_verified = True
        self.assertFalse(profile_logic.isFormVerificationAwaiting(
            self.profile))

        # only consent form is submitted but not verified
        self.profile.student_data.consent_form = ndb.BlobKey('blob-key')
        self.profile.student_data.is_consent_form_verified = False
        self.profile.student_data.enrollment_form = None
        self.profile.student_data.is_enrollment_form_verified = None
        self.assertFalse(profile_logic.isFormVerificationAwaiting(
            self.profile))

        # only consent form is submitted and verified
        self.profile.student_data.is_consent_form_verified = True
        self.assertFalse(profile_logic.isFormVerificationAwaiting(
            self.profile))
Exemplo n.º 2
0
  def context(self, data, check, mutator):
    """Handler for default HTTP GET request."""
    context = {'page_name': 'Student form upload'}

    form_data = {}
    if data.ndb_profile.student_data.consent_form:
      form_data['consent_form'] = blobstore.BlobInfo(
          data.ndb_profile.student_data.consent_form)
    if data.ndb_profile.student_data.enrollment_form:
      form_data['enrollment_form'] = blobstore.BlobInfo(
          data.ndb_profile.student_data.enrollment_form)

    upload_form = UploadForm(data, initial=form_data)

    if profile_logic.hasStudentFormsUploaded(data.ndb_profile):
      kwargs = dicts.filter(data.kwargs, ['sponsor', 'program'])
      claim_tasks_url = reverse('gci_list_tasks', kwargs=kwargs)
      context['form_instructions'] = CLAIM_TASKS_NOW % claim_tasks_url
    # TODO(ljvderijk): This can be removed when AppEngine supports 200 response
    # in the BlobStore API.
    if data.GET:
      for key, error in data.GET.iteritems():
        if not key.startswith('error_'):
          continue
        field_name = key.split('error_', 1)[1]
        upload_form.errors[field_name] = upload_form.error_class([error])

    context['form'] = upload_form
    context['form_verification_awaiting'] = (
        ci_profile_logic.isFormVerificationAwaiting(data.ndb_profile))

    return context
Exemplo n.º 3
0
    def context(self, data, check, mutator):
        """Handler for default HTTP GET request."""
        context = {'page_name': 'Student form upload'}

        form_data = {}
        if data.ndb_profile.student_data.consent_form:
            form_data['consent_form'] = blobstore.BlobInfo(
                data.ndb_profile.student_data.consent_form)
        if data.ndb_profile.student_data.enrollment_form:
            form_data['enrollment_form'] = blobstore.BlobInfo(
                data.ndb_profile.student_data.enrollment_form)

        upload_form = UploadForm(data, initial=form_data)

        if profile_logic.hasStudentFormsUploaded(data.ndb_profile):
            kwargs = dicts.filter(data.kwargs, ['sponsor', 'program'])
            claim_tasks_url = reverse('gci_list_tasks', kwargs=kwargs)
            context['form_instructions'] = CLAIM_TASKS_NOW % claim_tasks_url
        # TODO(ljvderijk): This can be removed when AppEngine supports 200 response
        # in the BlobStore API.
        if data.GET:
            for key, error in data.GET.iteritems():
                if not key.startswith('error_'):
                    continue
                field_name = key.split('error_', 1)[1]
                upload_form.errors[field_name] = upload_form.error_class(
                    [error])

        context['form'] = upload_form
        context['form_verification_awaiting'] = (
            ci_profile_logic.isFormVerificationAwaiting(data.ndb_profile))

        return context
Exemplo n.º 4
0
  def testForTwoFormsSubmitted(self):
    """Tests the behavior when two forms have been submitted."""
    self.profile.student_data.enrollment_form = ndb.BlobKey('blob-key')
    self.profile.student_data.consent_form = ndb.BlobKey('blob-key')

    # no forms have been verified
    self.profile.student_data.is_consent_form_verified = False
    self.profile.student_data.is_enrollment_form_verified = False
    self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

    # only student id form is verified
    self.profile.student_data.is_enrollment_form_verified = True
    self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

    # only consent form is verified
    self.profile.student_data.is_consent_form_verified = True
    self.profile.student_data.is_enrollment_form_verified = False
    self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

    # both forms are verified
    self.profile.student_data.is_enrollment_form_verified = True
    self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))
Exemplo n.º 5
0
  def testForOneFormSubmitted(self):
    """Tests the behavior when one form has been submitted."""
    # only enrollment form is submitted but not verified
    self.profile.student_data.consent_form = None
    self.profile.student_data.enrollment_form = ndb.BlobKey('blob-key')
    self.profile.student_data.is_enrollment_form_verified = False
    self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))

    # only enrollment form is submitted and verified
    self.profile.student_data.is_enrollment_form_verified = True
    self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))

    # only consent form is submitted but not verified
    self.profile.student_data.consent_form = ndb.BlobKey('blob-key')
    self.profile.student_data.is_consent_form_verified = False
    self.profile.student_data.enrollment_form = None
    self.profile.student_data.is_enrollment_form_verified = None
    self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))

    # only consent form is submitted and verified
    self.profile.student_data.is_consent_form_verified = True
    self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))
Exemplo n.º 6
0
    def testForTwoFormsSubmitted(self):
        """Tests the behavior when two forms have been submitted."""
        self.profile.student_data.enrollment_form = ndb.BlobKey('blob-key')
        self.profile.student_data.consent_form = ndb.BlobKey('blob-key')

        # no forms have been verified
        self.profile.student_data.is_consent_form_verified = False
        self.profile.student_data.is_enrollment_form_verified = False
        self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

        # only student id form is verified
        self.profile.student_data.is_enrollment_form_verified = True
        self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

        # only consent form is verified
        self.profile.student_data.is_consent_form_verified = True
        self.profile.student_data.is_enrollment_form_verified = False
        self.assertTrue(profile_logic.isFormVerificationAwaiting(self.profile))

        # both forms are verified
        self.profile.student_data.is_enrollment_form_verified = True
        self.assertFalse(profile_logic.isFormVerificationAwaiting(
            self.profile))
Exemplo n.º 7
0
 def testForNoFormsSubmitted(self):
     """Tests the behavior when no forms have been submitted."""
     self.profile.student_data.consent_form = ndb.BlobKey('blob-key')
     self.profile.student_data.enrollment_form = None
     self.assertFalse(profile_logic.isFormVerificationAwaiting(
         self.profile))
Exemplo n.º 8
0
 def testForNoFormsSubmitted(self):
   """Tests the behavior when no forms have been submitted."""
   self.profile.student_data.consent_form = ndb.BlobKey('blob-key')
   self.profile.student_data.enrollment_form = None
   self.assertFalse(profile_logic.isFormVerificationAwaiting(self.profile))