示例#1
0
def queryForProgramAndStatus(program, status, keys_only=False):
    query = GCIOrganization.all()
    query.filter('program', program)

    if isinstance(status, list):
        query.filter('status IN', status)
    else:
        query.filter('status', status)

    return query
示例#2
0
def queryForProgramAndStatus(program, status, keys_only=False):
    query = GCIOrganization.all()
    query.filter("program", program)

    if isinstance(status, list):
        query.filter("status IN", status)
    else:
        query.filter("status", status)

    return query
示例#3
0
    def getListData(self):
        if lists.getListIndex(self.request) != self.idx:
            return None

        q = GCIOrganization.all()
        q.filter("scope", self.data.program)
        q.filter("status IN", ["new", "active"])

        response_builder = lists.RawQueryContentResponseBuilder(self.request, self._list_config, q, lists.keyStarter)

        return response_builder.build()
示例#4
0
def clear(*args, **kwargs):
  """Removes all entities from the datastore.
  """

  # there no explicit ranker model anywhere, so make one for
  # our own convenience to delete all rankers
  class ranker(db.Model):
    """ranker model used with ranklist module.
    """
    pass

  # TODO(dbentley): If there are more than 1000 instances of any model,
  # this method will not clear all instances.  Instead, it should continually
  # call .all(), delete all those, and loop until .all() is empty.
  entities = itertools.chain(*[
      Notification.all(),
      GSoCMentor.all(),
      GCIMentor.all(),
      GSoCStudent.all(),
      GCIStudent.all(),
      Survey.all(),
      SurveyContent.all(),
      SurveyRecord.all(),
      GSoCOrgAdmin.all(),
      GCIOrgAdmin.all(),
      ranker.all(),
      RankerRoot.all(),
      StudentProposal.all(),
      GSoCOrganization.all(),
      GCIOrganization.all(),
      GSoCTimeline.all(),
      GCITimeline.all(),
      GSoCProgram.all(),
      GCIProgram.all(),
      Host.all(),
      Sponsor.all(),
      User.all(),
      Site.all(),
      Document.all(),
      ])

  try:
    for entity in entities:
      entity.delete()
  except db.Timeout:
    return http.HttpResponseRedirect('#')
  # pylint: disable=E1101
  memcache.flush_all()

  return http.HttpResponse('Done')
示例#5
0
def clear(*args, **kwargs):
    """Removes all entities from the datastore.
  """

    # there no explicit ranker model anywhere, so make one for
    # our own convenience to delete all rankers
    class ranker(db.Model):
        """ranker model used with ranklist module.
    """
        pass

    # TODO(dbentley): If there are more than 1000 instances of any model,
    # this method will not clear all instances.  Instead, it should continually
    # call .all(), delete all those, and loop until .all() is empty.
    entities = itertools.chain(*[
        Notification.all(),
        GSoCMentor.all(),
        GCIMentor.all(),
        GSoCStudent.all(),
        GCIStudent.all(),
        Survey.all(),
        SurveyContent.all(),
        SurveyRecord.all(),
        GSoCOrgAdmin.all(),
        GCIOrgAdmin.all(),
        ranker.all(),
        RankerRoot.all(),
        StudentProposal.all(),
        GSoCOrganization.all(),
        GCIOrganization.all(),
        GSoCTimeline.all(),
        GCITimeline.all(),
        GSoCProgram.all(),
        GCIProgram.all(),
        Host.all(),
        Sponsor.all(),
        User.all(),
        Site.all(),
        Document.all(),
    ])

    try:
        for entity in entities:
            entity.delete()
    except db.Timeout:
        return http.HttpResponseRedirect('#')
    # pylint: disable=E1101
    memcache.flush_all()

    return http.HttpResponse('Done')
示例#6
0
  def getListData(self):
    idx = lists.getListIndex(self.request)
    if idx == 0:
      q = GCIOrganization.all()
      q.filter('scope', self.data.program)
      q.filter('status IN', ['new', 'active'])

      starter = lists.keyStarter

      response_builder = lists.RawQueryContentResponseBuilder(
          self.request, self._list_config, q, starter)
      return response_builder.build()
    else:
      return None
示例#7
0
  def getListData(self):
    if lists.getListIndex(self.data.request) != self.idx:
      return None

    q = GCIOrganization.all()
    q.filter(
        '__key__ IN',
        map(lambda org_key: org_key.to_old_key(),
            self.data.ndb_profile.admin_for))
    q.filter('status IN', ['new', 'active'])

    response_builder = lists.RawQueryContentResponseBuilder(
        self.data.request, self._list_config, q, lists.keyStarter)

    return response_builder.build()
示例#8
0
    def getListData(self):
        if lists.getListIndex(self.data.request) != self.idx:
            return None

        q = GCIOrganization.all()
        q.filter(
            '__key__ IN',
            map(lambda org_key: org_key.to_old_key(),
                self.data.ndb_profile.admin_for))
        q.filter('status IN', ['new', 'active'])

        response_builder = lists.RawQueryContentResponseBuilder(
            self.data.request, self._list_config, q, lists.keyStarter)

        return response_builder.build()
示例#9
0
def clear(*args, **kwargs):
  """Removes all entities from the datastore.
  """

  # TODO(dbentley): If there are more than 1000 instances of any model,
  # this method will not clear all instances.  Instead, it should continually
  # call .all(), delete all those, and loop until .all() is empty.
  entities = itertools.chain(*[
      Survey.all(),
      SurveyRecord.all(),
      GCIOrganization.all(),
      GSoCTimeline.all(),
      GCITimeline.all(),
      GSoCProgram.all(),
      GSoCProject.all(),
      GSoCProposal.all(),
      GCIProgram.all(),
      GCIScore.all(),
      GSoCStudentInfo.all(),
      GCIStudentInfo.all(),
      GCITask.all(),
      Sponsor.all(),
      Site.all(),
      Document.all(),
      # The below models are all subclasses of ndb.Model and therefore must
      # use .query() to return all instances instead of .all().
      soc_org_model.SOCOrganization.query(),
      profile_model.Profile.query(),
      soc_profile.SOCStudentData.query(),
      user.User.query(),
      address.Address.query(),
      contact.Contact.query()
      ])

  try:
    for entity in entities:
      if isinstance(entity, ndb.Model):
        entity.key.delete()
      else:
        entity.delete()
  except db.Timeout:
    return http.HttpResponseRedirect('#')
  memcache.flush_all()

  return http.HttpResponse('Done')
示例#10
0
def clear(*args, **kwargs):
    """Removes all entities from the datastore.
  """

    # TODO(dbentley): If there are more than 1000 instances of any model,
    # this method will not clear all instances.  Instead, it should continually
    # call .all(), delete all those, and loop until .all() is empty.
    entities = itertools.chain(*[
        Survey.all(),
        SurveyRecord.all(),
        GCIOrganization.all(),
        GSoCTimeline.all(),
        GCITimeline.all(),
        GSoCProgram.all(),
        GSoCProject.all(),
        GSoCProposal.all(),
        GCIProgram.all(),
        GCIScore.all(),
        GSoCStudentInfo.all(),
        GCIStudentInfo.all(),
        GCITask.all(),
        Sponsor.all(),
        Site.all(),
        Document.all(),
        # The below models are all subclasses of ndb.Model and therefore must
        # use .query() to return all instances instead of .all().
        soc_org_model.SOCOrganization.query(),
        profile_model.Profile.query(),
        soc_profile.SOCStudentData.query(),
        user.User.query(),
        address.Address.query(),
        contact.Contact.query()
    ])

    try:
        for entity in entities:
            if isinstance(entity, ndb.Model):
                entity.key.delete()
            else:
                entity.delete()
    except db.Timeout:
        return http.HttpResponseRedirect('#')
    memcache.flush_all()

    return http.HttpResponse('Done')
示例#11
0
文件: seed_db.py 项目: adviti/melange
def clear(*args, **kwargs):
  """Removes all entities from the datastore.
  """

  # TODO(dbentley): If there are more than 1000 instances of any model,
  # this method will not clear all instances.  Instead, it should continually
  # call .all(), delete all those, and loop until .all() is empty.
  entities = itertools.chain(*[
      Notification.all(),
      GCIStudent.all(),
      Survey.all(),
      SurveyRecord.all(),
      StudentProposal.all(),
      GSoCOrganization.all(),
      GCIOrganization.all(),
      GSoCTimeline.all(),
      GCITimeline.all(),
      GSoCProgram.all(),
      GSoCProfile.all(),
      GCIProfile.all(),
      GSoCProposal.all(),
      GCIProgram.all(),
      GCIScore.all(),
      GSoCStudentInfo.all(),
      GCIStudentInfo.all(),
      GCITask.all(),
      Host.all(),
      Sponsor.all(),
      User.all(),
      Site.all(),
      Document.all(),
      ])

  try:
    for entity in entities:
      entity.delete()
  except db.Timeout:
    return http.HttpResponseRedirect('#')
  # pylint: disable=E1101
  memcache.flush_all()

  return http.HttpResponse('Done')
示例#12
0
def queryForOrgAdminAndStatus(org_admin, status):
    """Returns a query for GCIOrganization entities with the specified org admin
  and status.

  Args:
    org_admin: GCIProfile entity
    status: the specified status or a list of acceptable statuses

  Returns:
    a Query object which may be used to retrieved GCIOrganization entities
  """
    query = GCIOrganization.all()
    query.filter("__key__ IN", org_admin.org_admin_for)

    if isinstance(status, list):
        query.filter("status IN", status)
    else:
        query.filter("status", status)

    return query
示例#13
0
def queryForOrgAdminAndStatus(org_admin, status):
    """Returns a query for GCIOrganization entities with the specified org admin
  and status.

  Args:
    org_admin: GCIProfile entity
    status: the specified status or a list of acceptable statuses

  Returns:
    a Query object which may be used to retrieved GCIOrganization entities
  """
    query = GCIOrganization.all()
    query.filter('__key__ IN', org_admin.org_admin_for)

    if isinstance(status, list):
        query.filter('status IN', status)
    else:
        query.filter('status', status)

    return query
示例#14
0
  def getListData(self):
    idx = lists.getListIndex(self.request)
    if idx == 0:
      q = GCIOrganization.all()
      q.filter('scope', self.data.program)
      q.filter('status IN', ['new', 'active'])

      starter = lists.keyStarter

      def prefetcher(entities):
        prefetched_dict = {}
        for ent in entities:
          prefetched_dict[ent.key()] = profile_logic.orgAdminsForOrg(ent)

        return [prefetched_dict], {}

      response_builder = lists.RawQueryContentResponseBuilder(
          self.request, self._list_config, q, starter, prefetcher=prefetcher)
      return response_builder.build()
    else:
      return None
示例#15
0
 def _getQuery(self):
     query = GCIOrganization.all()
     query.filter('program', self.data.program)
     query.filter('status IN', ['new', 'active'])
     return query
示例#16
0
 def _getQuery(self):
   query = GCIOrganization.all()
   query.filter('program', self.data.program)
   query.filter('status IN', ['new', 'active'])
   return query