Example #1
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(),
      Mentor.all(),
      Student.all(),
      OrgAdmin.all(),
      ranker.all(),
      RankerRoot.all(),
      StudentProposal.all(),
      Organization.all(),
      OrgApplication.all(),
      Timeline.all(),
      Program.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-msg=E1101
  memcache.flush_all()

  return http.HttpResponse('Done')
Example #2
0
def getProps(last=None):
  """Returns all proposals as a list of dictionaries.
  """

  key_order = [
      'link_id', 'scope_path', 'title', 'abstract', 'content',
      'additional_info', '_mentor', 'possible_mentors', 'score',
      'status', '_org', 'created_on', 'last_modified_on']

  from soc.models.student_proposal import StudentProposal

  gen = lambda: StudentProposal.all()

  it = dateFetch(gen, last)

  proposals = [(i.key().name(), i.toDict(key_order)) for i in it]
  if proposals:
    last = i.last_modified_on # last modified entity
  else:
    last = datetime.datetime.now()

  return dict(proposals), last
Example #3
0
def getProps(last=None):
    """Returns all proposals as a list of dictionaries.
  """

    key_order = [
        'link_id', 'scope_path', 'title', 'abstract', 'content',
        'additional_info', '_mentor', 'possible_mentors', 'score', 'status',
        '_org', 'created_on', 'last_modified_on'
    ]

    from soc.models.student_proposal import StudentProposal

    gen = lambda: StudentProposal.all()

    it = dateFetch(gen, last)

    proposals = [(i.key().name(), i.toDict(key_order)) for i in it]
    if proposals:
        last = i.last_modified_on  # last modified entity
    else:
        last = datetime.datetime.now()

    return dict(proposals), last