def get(self, match_id): """ 我的状态 """ member = MatchMember.get_or_none(match_id=match_id, user_id=self.current_user.id) self.write(member.info)
def get(self, match_id): """获取赛事信息 :match_id: 赛事ID :returns: 赛事信息 """ preview = self.get_query_argument("preview", False) match = self.get_object(match_id, preview) match.team = Team.get_or_404(id=match.team_id) serializer = MatchSerializer(instance=match) info = serializer.data # 获取赛事分组信息 query = MatchGroup.select().where( MatchGroup.match_id == match.id, ).order_by( MatchGroup.sort_num.desc()) groups = [] for group in query: groups.append(group.info) info['groups'] = groups # 获取赛事海报列表 query = MatchCover.select().where( MatchCover.match_id == match.id).order_by(MatchCover.id.desc()) covers = [] for cover in query: covers.append(cover.info) info['covers'] = covers if self.current_user: member = MatchMember.get_or_none(match_id=match_id, user_id=self.current_user.id) if member: info['my_state'] = member.mini_info self.write(info)