Exemple #1
0
    def _updateField(self, entity, entity_properties, name):
        """Called when the fields of the mentor are updated

      When status is changed to invalid, removes the Mentor from all Student
      Proposals possible mentor lists.
    """

        from soc.modules.gsoc.logic.models.student_proposal import logic \
            as student_proposal_logic

        value = entity_properties[name]

        if name == 'status' and value != entity.status and value == 'invalid':
            fields = {'org': entity.scope}

            # TODO make this work for more then 1000 entities
            proposals_query = student_proposal_logic.getQueryForFields(fields)

            # store all updated proposals
            changed = []

            for proposal in proposals_query:

                if proposal.possible_mentors.count(entity.key()):
                    # remove from list and add to changed
                    proposal.possible_mentors.remove(entity.key())
                    changed.append(proposal)

            # store all changed proposals
            db.put(changed)

        return super(Logic, self)._updateField(entity, entity_properties, name)
Exemple #2
0
  def _updateField(self, entity, entity_properties, name):
    """Called when the fields of the mentor are updated

      When status is changed to invalid, removes the Mentor from all Student
      Proposals possible mentor lists.
    """

    from soc.modules.gsoc.logic.models.student_proposal import logic \
        as student_proposal_logic

    value = entity_properties[name]

    if name == 'status' and value != entity.status and value == 'invalid':
      fields = {'org': entity.scope}

      # TODO make this work for more then 1000 entities
      proposals_query = student_proposal_logic.getQueryForFields(fields)

      # store all updated proposals
      changed = []

      for proposal in proposals_query:

        if proposal.possible_mentors.count(entity.key()):
          # remove from list and add to changed
          proposal.possible_mentors.remove(entity.key())
          changed.append(proposal)

      # store all changed proposals
      db.put(changed)

    return super(Logic, self)._updateField(entity, entity_properties, name)
def reject_proposals_query(org):
  """Query proposals to reject
  """

  fields = {
    'status': ['new', 'pending'],
    'org': org,
    }

  return student_proposal_logic.getQueryForFields(fields)
Exemple #4
0
def reject_proposals_query(org):
    """Query proposals to reject
  """

    fields = {
        'status': ['new', 'pending'],
        'org': org,
    }

    return student_proposal_logic.getQueryForFields(fields)
Exemple #5
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
Exemple #6
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