コード例 #1
0
ファイル: survey.py プロジェクト: jamslevy/gsoc
  def create_survey(self, survey_fields, schema, this_survey=False):
    """ Create a new survey from prototype
    """

    if not this_survey: this_survey = SurveyContent()
    else: 
        # wipe clean existing dynamic properties if they exist
        for prop in this_survey.dynamic_properties():
        	delattr(this_survey, prop) 
    for name, value in survey_fields.items(): setattr(this_survey, name, value)
    this_survey.set_schema(schema)
    from google.appengine.ext import db
    db.put(this_survey)
    return this_survey
コード例 #2
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(),
        GHOPMentor.all(),
        GSoCStudent.all(),
        GHOPStudent.all(),
        Survey.all(),
        SurveyContent.all(),
        SurveyRecord.all(),
        GSoCOrgAdmin.all(),
        GHOPOrgAdmin.all(),
        ranker.all(),
        RankerRoot.all(),
        StudentProposal.all(),
        GSoCOrganization.all(),
        GHOPOrganization.all(),
        OrgApplication.all(),
        GSoCTimeline.all(),
        GHOPTimeline.all(),
        GSoCProgram.all(),
        GHOPProgram.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')
コード例 #3
0
ファイル: seed_db.py プロジェクト: SRabbelier/Melange
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')
コード例 #4
0
ファイル: survey.py プロジェクト: ajaksu/Melange
  def createSurvey(self, survey_fields, schema, survey_content=False):
    """Create a new survey from prototype.

    params:
      survey_fields = dict of survey field items (see SurveyContent model)
      schema = metadata about survey fields (SurveyContent.schema)
      survey_content = existing SurveyContent entity
    """

    if not survey_content:
      survey_content = SurveyContent()
    else:
      # wipe clean existing dynamic properties if they exist
      for prop in survey_content.dynamic_properties():
        delattr(survey_content, prop)

    for name, value in survey_fields.items():
      setattr(survey_content, name, value)

    survey_content.schema = str(schema)

    db.put(survey_content)

    return survey_content
コード例 #5
0
ファイル: survey.py プロジェクト: pombredanne/Melange-1
    def createSurvey(self, survey_fields, schema, survey_content=False):
        """Create a new survey from prototype.

    params:
      survey_fields = dict of survey field items (see SurveyContent model)
      schema = metadata about survey fields (SurveyContent.schema)
      survey_content = existing SurveyContent entity
    """

        if not survey_content:
            survey_content = SurveyContent()
        else:
            # wipe clean existing dynamic properties if they exist
            for prop in survey_content.dynamic_properties():
                delattr(survey_content, prop)

        for name, value in survey_fields.items():
            setattr(survey_content, name, value)

        survey_content.schema = str(schema)

        db.put(survey_content)

        return survey_content