Пример #1
0
  def txn():
    org_score_query = queryForAncestorAndOrg(student.key.to_old_key(), org_key)

    org_score = org_score_query.get()
    if not org_score:
      org_score = GCIOrgScore(parent=student.key.to_old_key(), org=org_key)

    org_score.tasks.append(task.key())
    org_score.put()
Пример #2
0
    def txn():
        org_score_query = queryForAncestorAndOrg(student.key.to_old_key(),
                                                 org_key)

        org_score = org_score_query.get()
        if not org_score:
            org_score = GCIOrgScore(parent=student.key.to_old_key(),
                                    org=org_key)

        org_score.tasks.append(task.key())
        org_score.put()
Пример #3
0
def convertGCIProfileDBEntityGroup(profile_key):
  """Converts DB based part of entity group associated with the specified
  profile.

  Args:
    profile_key: db.Key of the profile to process.
  """
  to_delete = []
  do_put = True

  org_scores = GCIOrgScore.all().ancestor(profile_key).fetch(1000)
  for org_score in org_scores:
    new_org_score = _convertParent(org_score)
    if do_put:
      new_org_score.put()
    to_delete.append(org_score)

  scores = GCIScore.all().ancestor(profile_key).fetch(1000)
  for score in scores:
    new_score = _convertParent(score)
    if do_put:
      new_score.put()
    to_delete.append(score)

  db.delete(to_delete)
Пример #4
0
def convertGCIProfileDBEntityGroup(profile_key):
    """Converts DB based part of entity group associated with the specified
  profile.

  Args:
    profile_key: db.Key of the profile to process.
  """
    to_delete = []
    do_put = True

    org_scores = GCIOrgScore.all().ancestor(profile_key).fetch(1000)
    for org_score in org_scores:
        new_org_score = _convertParent(org_score)
        if do_put:
            new_org_score.put()
        to_delete.append(org_score)

    scores = GCIScore.all().ancestor(profile_key).fetch(1000)
    for score in scores:
        new_score = _convertParent(score)
        if do_put:
            new_score.put()
        to_delete.append(score)

    db.delete(to_delete)
Пример #5
0
  def getListData(self):
    idx = lists.getListIndex(self.data.request)
    if idx == self.ORG_SCORE_LIST_IDX:
      q = GCIOrgScore.all()
      q.filter('org', self.data.organization)

      skipper = lambda entity, start: entity.numberOfTasks() <= 0

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

      return response_builder.build()
    else:
      return None
Пример #6
0
    def getListData(self):
        idx = lists.getListIndex(self.data.request)
        if idx == self.ORG_SCORE_LIST_IDX:
            q = GCIOrgScore.all()
            q.filter('org', self.data.organization)

            skipper = lambda entity, start: entity.numberOfTasks() <= 0

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

            return response_builder.build()
        else:
            return None
Пример #7
0
    def txn():
        to_put = []

        for org_key, tasks in tasks_by_org.iteritems():
            query = queryForAncestorAndOrg(student_key, org_key)

            org_score = query.get()
            if not org_score:
                org_score = GCIOrgScore(parent=student_key, org=org_key)

            for task in tasks:
                org_score.tasks.append(task.key())

            to_put.append(org_score)

        student = ndb.Key.from_old_key(student_key)
        student.student_data.number_of_completed_tasks += len(tasks)
        student.put()

        db.put(to_put)
Пример #8
0
def queryForAncestor(ancestor, keys_only=False):
  """Returns the query to fetch OrgScore entities for the specified
  ancestor.
  """
  return GCIOrgScore.all(keys_only=keys_only).ancestor(ancestor)
Пример #9
0
def queryForAncestorAndOrg(ancestor, org, keys_only=False):
  """Returns the query to fetch OrgScore entities for the specified
  ancestor and organization.
  """
  return GCIOrgScore.all(keys_only=keys_only).ancestor(
      ancestor).filter('org', org)
Пример #10
0
def queryForOrg(org, keys_only=False):
  """Return the query to fetch OrgScore entities for the specified
  organization.
  """
  return GCIOrgScore.all(keys_only=keys_only).filter('org', org)
Пример #11
0
def queryForAncestor(ancestor, keys_only=False):
    """Returns the query to fetch OrgScore entities for the specified
  ancestor.
  """
    return GCIOrgScore.all(keys_only=keys_only).ancestor(ancestor)
Пример #12
0
def queryForAncestorAndOrg(ancestor, org, keys_only=False):
    """Returns the query to fetch OrgScore entities for the specified
  ancestor and organization.
  """
    return GCIOrgScore.all(keys_only=keys_only).ancestor(ancestor).filter(
        'org', org)
Пример #13
0
def queryForOrg(org, keys_only=False):
    """Return the query to fetch OrgScore entities for the specified
  organization.
  """
    return GCIOrgScore.all(keys_only=keys_only).filter('org', org)