Exemplo n.º 1
0
class Champion(ndb.Model):
    championship = ndb.KeyProperty(kind=Championship)
    event = ndb.KeyProperty(kind=Event)
    champions = ndb.KeyProperty(kind=Result, repeated=True)

    national_champion = ndb.ComputedProperty(
        lambda e: e.championship.get().national_championship)
    region = ndb.ComputedProperty(lambda e: e.championship.get().region)
    state = ndb.ComputedProperty(lambda e: e.championship.get().state)
    year = ndb.ComputedProperty(lambda e: e.championship.get().year)

    @staticmethod
    def Id(championship_id, event_id):
        return '%s_%s' % (championship_id, event_id)
Exemplo n.º 2
0
class RankBase(BaseModel):
    person = ndb.KeyProperty(kind=Person)
    event = ndb.KeyProperty(kind=Event)
    best = ndb.IntegerProperty()
    state = ndb.ComputedProperty(lambda self: self.GetState())

    def GetState(self):
        if not self.person or not self.person.get():
            return None
        return self.person.get().state

    @staticmethod
    def GetId(row):
        return '%s_%s' % (row['personId'], row['eventId'])

    def ParseFromDict(self, row):
        self.person = ndb.Key(Person, row['personId'])
        self.event = ndb.Key(Event, row['eventId'])
        self.best = int(row['best'])

    @staticmethod
    def ColumnsUsed():
        return ['personId', 'eventId', 'best']

    def ObjectsToGet(self):
        return [self.person]
Exemplo n.º 3
0
class Championship(ndb.Model):
    national_championship = ndb.BooleanProperty()
    region = ndb.KeyProperty(kind=Region)
    state = ndb.KeyProperty(kind=State)

    competition = ndb.KeyProperty(kind=Competition)

    year = ndb.ComputedProperty(lambda self: self.competition.get().year)

    residency_deadline = ndb.DateTimeProperty()
    residency_timezone = ndb.StringProperty()

    @staticmethod
    def NationalsId(year):
        return str(year)

    @staticmethod
    def RegionalsId(year, region):
        return '%s_%d' % (region.key.id(), year)

    @staticmethod
    def StateChampionshipId(year, state):
        return '%s_%d' % (state.key.id(), year)

    def GetEligibleStateKeys(self):
        if self.state:
            return [self.state]
        if self.region:
            return State.query(State.region == self.region).fetch(
                keys_only=True)
        # National championships are not based on residence, they're based on
        # citizenship.
        return None
Exemplo n.º 4
0
class _blobmigrator_BlobKeyMapping(data_types.Model):
    """Migrated blob."""

    old_blob_key = ndb.ComputedProperty(lambda self: self.key.id())
    gcs_filename = ndb.StringProperty(required=True)
    new_blob_key = ndb.StringProperty(required=True)
Exemplo n.º 5
0
 class CModel(ndb.Model):
     s_foobar = ndb.StringProperty()
     key_b = ndb.KeyProperty(kind="BModel", indexed=True)
     key_a = ndb.ComputedProperty(  # Issue here
         lambda self: self.key_b.get().key_a if self.key_b else None, )
Exemplo n.º 6
0
class RegionalChampionshipEligibility(ndb.Model):
    championship = ndb.KeyProperty(kind=Championship)
    year = ndb.ComputedProperty(lambda self: self.championship.get().year)
    region = ndb.ComputedProperty(lambda self: self.championship.get().region)
Exemplo n.º 7
0
class StateChampionshipEligibility(ndb.Model):
    championship = ndb.KeyProperty(kind=Championship)
    year = ndb.ComputedProperty(lambda self: self.championship.get().year)
    state = ndb.ComputedProperty(lambda self: self.championship.get().state)
Exemplo n.º 8
0
class CModel(ndb.Model):
    s_foobar = ndb.StringProperty()
    k_bmodel = ndb.KeyProperty(kind="BModel", indexed=True)
    k_amodel = ndb.ComputedProperty(
        lambda self: self.k_bmodel.get().k_amodel if self.k_bmodel else None, )