Exemplo n.º 1
0
    def checkIsStudent(self, django_args, key_location, status):
        """Checks if the current user is the given student.

    Args:
      django_args: a dictionary with django's arguments
      key_location: the key for django_args in which the key_name
                    from the student is stored
      status: the allowed status for the student
    """

        self.checkIsUser(django_args)

        if 'seed' in django_args:
            key_name = django_args['seed'][key_location]
        else:
            key_name = django_args[key_location]

        student_entity = student_logic.getFromKeyName(key_name)

        if not student_entity or student_entity.status not in status:
            raise out_of_band.AccessViolation(
                message_fmt=DEF_SIGN_UP_AS_STUDENT_MSG)

        if student_entity.user.key() != self.user.key():
            # this is not the page for the current user
            self.deny(django_args)

        return
Exemplo n.º 2
0
  def checkIsStudent(self, django_args, key_location, status):
    """Checks if the current user is the given student.

    Args:
      django_args: a dictionary with django's arguments
      key_location: the key for django_args in which the key_name
                    from the student is stored
      status: the allowed status for the student
    """

    self.checkIsUser(django_args)

    if 'seed' in django_args:
      key_name = django_args['seed'][key_location]
    else:
      key_name = django_args[key_location]

    student_entity = student_logic.getFromKeyName(key_name)

    if not student_entity or student_entity.status not in status:
      raise out_of_band.AccessViolation(
        message_fmt=DEF_SIGN_UP_AS_STUDENT_MSG)

    if student_entity.user.key() != self.user.key():
      # this is not the page for the current user
      self.deny(django_args)

    return
Exemplo n.º 3
0
    def checkCanStudentPropose(self, django_args, key_location, check_limit):
        """Checks if the program for this student accepts proposals.

    Args:
      django_args: a dictionary with django's arguments
      key_location: the key for django_args in which the key_name
                    from the student is stored
      check_limit: iff true checks if the student reached the apps_tasks_limit
                   for the given program.
    """

        from soc.logic.helper import timeline as timeline_helper

        self.checkIsUser(django_args)

        if django_args.get('seed'):
            key_name = django_args['seed'][key_location]
        else:
            key_name = django_args[key_location]

        student_entity = student_logic.getFromKeyName(key_name)

        if not student_entity or student_entity.status == 'invalid':
            raise out_of_band.AccessViolation(
                message_fmt=DEF_SIGN_UP_AS_STUDENT_MSG)

        program_entity = student_entity.scope

        if not timeline_helper.isActivePeriod(program_entity.timeline,
                                              'student_signup'):
            raise out_of_band.AccessViolation(
                message_fmt=access.DEF_PAGE_INACTIVE_MSG)

        if check_limit:
            # count all studentproposals by the student
            fields = {'scope': student_entity}
            proposal_query = student_proposal_logic.getQueryForFields(fields)

            if proposal_query.count() >= program_entity.apps_tasks_limit:
                # too many proposals access denied
                raise out_of_band.AccessViolation(
                    message_fmt=DEF_MAX_PROPOSALS_REACHED)

        return
Exemplo n.º 4
0
  def checkCanStudentPropose(self, django_args, key_location, check_limit):
    """Checks if the program for this student accepts proposals.

    Args:
      django_args: a dictionary with django's arguments
      key_location: the key for django_args in which the key_name
                    from the student is stored
      check_limit: iff true checks if the student reached the apps_tasks_limit
                   for the given program.
    """

    from soc.logic.helper import timeline as timeline_helper

    self.checkIsUser(django_args)

    if django_args.get('seed'):
      key_name = django_args['seed'][key_location]
    else:
      key_name = django_args[key_location]

    student_entity = student_logic.getFromKeyName(key_name)

    if not student_entity or student_entity.status == 'invalid':
      raise out_of_band.AccessViolation(
        message_fmt=DEF_SIGN_UP_AS_STUDENT_MSG)

    program_entity = student_entity.scope

    if not timeline_helper.isActivePeriod(program_entity.timeline,
                                          'student_signup'):
      raise out_of_band.AccessViolation(message_fmt=access.DEF_PAGE_INACTIVE_MSG)

    if check_limit:
      # count all studentproposals by the student
      fields = {'scope': student_entity}
      proposal_query = student_proposal_logic.getQueryForFields(fields)

      if proposal_query.count() >= program_entity.apps_tasks_limit:
        # too many proposals access denied
        raise out_of_band.AccessViolation(message_fmt=DEF_MAX_PROPOSALS_REACHED)

    return