コード例 #1
0
    def testForNonStudentProfile(self):
        """Tests that True is returned if a non-student profile exists."""
        # seed a non-student profile
        profile_utils.seedNDBProfile(self.program.key(), user=self.user)

        result = validate.hasNonStudentProfileForProgram(
            self.user.key, self.program.key())
        self.assertTrue(result)
コード例 #2
0
    def testForStudentProfile(self):
        """Tests that False is returned if a student profile exists."""
        # seed a student profile
        profile_utils.seedNDBStudent(self.program, user=self.user)

        result = validate.hasNonStudentProfileForProgram(
            self.user.key, self.program.key())
        self.assertFalse(result)
コード例 #3
0
ファイル: test_validate.py プロジェクト: rhyolight/nupic.son
  def testForStudentProfile(self):
    """Tests that False is returned if a student profile exists."""
    # seed a student profile
    profile_utils.seedNDBStudent(self.program, user=self.user)

    result = validate.hasNonStudentProfileForProgram(
        self.user.key, self.program.key())
    self.assertFalse(result)
コード例 #4
0
ファイル: test_validate.py プロジェクト: rhyolight/nupic.son
  def testForNonStudentProfile(self):
    """Tests that True is returned if a non-student profile exists."""
    # seed a non-student profile
    profile_utils.seedNDBProfile(self.program.key(), user=self.user)

    result = validate.hasNonStudentProfileForProgram(
        self.user.key, self.program.key())
    self.assertTrue(result)
コード例 #5
0
ファイル: test_validate.py プロジェクト: rhyolight/nupic.son
  def testForNonActiveProfile(self):
    """Tests that False is returned if a profile is not active."""
    # seed a non-student, banned profile
    profile_utils.seedNDBProfile(
        self.program.key(), user=self.user, status=profile_model.Status.BANNED)

    result = validate.hasNonStudentProfileForProgram(
        self.user.key, self.program.key())
    self.assertFalse(result)
コード例 #6
0
    def testForNonActiveProfile(self):
        """Tests that False is returned if a profile is not active."""
        # seed a non-student, banned profile
        profile_utils.seedNDBProfile(self.program.key(),
                                     user=self.user,
                                     status=profile_model.Status.BANNED)

        result = validate.hasNonStudentProfileForProgram(
            self.user.key, self.program.key())
        self.assertFalse(result)
コード例 #7
0
ファイル: org_app.py プロジェクト: rhyolight/nupic.son
  def validateBackupAdminProfile(self, backup_admin_user, profile_model):
    """Validates if backup admin has a profile for the current program.

    Args:
      backup_admin_user: User entity for the backup admin.
      profile_model: Model class from which the profile must be fetched.

    Raises:
      django_forms.ValidationError if the backup admin does not have a profile.
    """
    if not validate.hasNonStudentProfileForProgram(
        backup_admin_user.key, self.request_data.program.key(),
        models=self.request_data.models):
      redirector = self.request_data.redirect.createProfile('org_admin')

      raise django_forms.ValidationError(
          DEF_BACKUP_ADMIN_NO_PROFILE % (
              self.request_data.program.name,
              self._getCreateProfileURL(redirector)))
コード例 #8
0
ファイル: access_checker.py プロジェクト: rhyolight/nupic.son
  def canTakeOrgApp(self):
    """A user can take the GSoC org app if he has org admin profile in the
    program.
    """
    self.isLoggedIn()

    program = self.data.program

    # TODO(nathaniel): Eliminate this state-setting call.
    self.data.redirect.createProfile('org_admin')

    msg = DEF_NO_ORG_ADMIN_PROFILE % (
          program.short_name,
          self.data.redirect.urlOf('create_gsoc_profile', secure=True))

    if not self.data.ndb_user:
      raise exception.Forbidden(message=msg)

    if not validate.hasNonStudentProfileForProgram(
        self.data.ndb_user.key, self.data.program.key(),
        models=self.data.models):
      raise exception.Forbidden(message=msg)
コード例 #9
0
    def canTakeOrgApp(self):
        """A user can take the GSoC org app if he has org admin profile in the
    program.
    """
        self.isLoggedIn()

        program = self.data.program

        # TODO(nathaniel): Eliminate this state-setting call.
        self.data.redirect.createProfile('org_admin')

        msg = DEF_NO_ORG_ADMIN_PROFILE % (
            program.short_name,
            self.data.redirect.urlOf('create_gsoc_profile', secure=True))

        if not self.data.ndb_user:
            raise exception.Forbidden(message=msg)

        if not validate.hasNonStudentProfileForProgram(
                self.data.ndb_user.key,
                self.data.program.key(),
                models=self.data.models):
            raise exception.Forbidden(message=msg)
コード例 #10
0
 def testForNoProfile(self):
     """Tests that False is returned if no profile for the user exists."""
     result = validate.hasNonStudentProfileForProgram(
         self.user.key, self.program.key())
     self.assertFalse(result)
コード例 #11
0
ファイル: test_validate.py プロジェクト: rhyolight/nupic.son
 def testForNoProfile(self):
   """Tests that False is returned if no profile for the user exists."""
   result = validate.hasNonStudentProfileForProgram(
       self.user.key, self.program.key())
   self.assertFalse(result)