예제 #1
0
 def serialize(self):
     return {
         'id': self.id,
         'team_id': self.team_id,
         'player_id': self.player_id,
         'match_id': self.match_id,
         'created': dump_datetime(self.created)
     }
예제 #2
0
파일: models.py 프로젝트: VJean/homepage
    def serialize(self):
        """Return object data in easily serializeable format"""
        dump_to_bed = ""
        dump_to_rise = ""
        if self.to_bed:
            dump_to_bed = dump_datetime(self.to_bed)
        if self.to_rise:
            dump_to_rise = dump_datetime(self.to_rise)

        return {
           'id': self.id,
           'sleepless': self.sleepless,
           'date': dump_datetime(self.day),
           'begin': dump_to_bed,
           'end': dump_to_rise,
           'amount': dump_datetime(self.amount),
           'alone': self.alone,
           'place_id': self.place_id
        }
예제 #3
0
 def serialize(self):
     teams = Team.query.filter(Team.id.in_(
         [self.team0_id, self.team1_id])).all()
     return {
         'id'	: self.id,
         'date'	: dump_datetime(self.match_datetime),
         'teams'	: ([t.serialize for t in teams]),
         'score'	: {teams[0].name: self.team0_score, teams[1].name: self.team1_score},
         'goals': ([g.serialize for g in self.goals.all()])
     }
예제 #4
0
    def serialize(self):
        goals = self.goals

        return {
            'id': self.id,
            'date': dump_datetime(self.match_datetime),
            'teams': [self.team0.serialize, self.team1.serialize],
            'score': {
                self.team0.id: self.team0_score,
                self.team1.id: self.team1_score
                },
            'goals': ([g.serialize for g in goals]),
            'completed': self.completed
        }
예제 #5
0
 def serialize(self):
     return {
         'id'		: self.id,
         'name'  	: self.name,
         'created'	: dump_datetime(self.created)
     }
예제 #6
0
 def serialize(self):
     return {
         'id'		: self.id,
         'player' 	: self.get_player().serialize,
         'created'	: dump_datetime(self.created)
     }