Esempio n. 1
0
 def form_to_dao_match(self, alias_name, **update):
     try:
         match = Match()
         match.name = update['name']
         #Create an automatic alias for the match
         match.alias = alias_name
         match.sport = update['sport']
         match.participant_type = update['participant_type']
         match.start_datetime = update['start_datetime']
         match.end_datetime = update['end_datetime']
         match.result = update['result']
     except StandardError as e:
         logger.error('Error occured, %s, for %s:%s' %
                      (str(e), type, update['name']))
         raise
     return match
Esempio n. 2
0
    def form_to_dao(self, match_id):
        match = None
        if match_id is not None and len(match_id) > 1:
            match = self.matchDao.get_record(long(match_id))
        else:
            match = Match()
        match.name = self.form.name.data
        match.sport = self.form.sport.data
        #Create an automatic alias for the match
        match.alias = utils.slugify(self.form.name.data)
        match.start_datetime = self.form.start_datetime.data
        match.end_datetime = self.form.end_datetime.data
        match.result = self.form.result.data
        match.summary = self.form.summary.data
        match.participant_type = self.form.participant_type.data
        sel_team = self.request.get_all('team')
        sel_player = self.request.get_all('player')
        logger.debug('sel_team:  ' + str(sel_team))
        logger.debug('sel_player:  ' + str(sel_player))

        if match.participant_type == 'team':
            if len(sel_team) > 0:
                teams = []
                teams_count = len(sel_team)
                logger.debug('Teams Count: ' + str(teams_count))
                for x in xrange(teams_count):
                    teams.append(self.teamDao.get_record(sel_team[x]).key)
                logger.debug('Participants ' + str(teams))
                match.participants = teams
        else:
            if len(sel_player) > 0:
                players = []
                players_count = len(sel_player)
                logger.debug('Teams Count: ' + str(players_count))
                for x in xrange(players_count):
                    players.append(
                        self.playerDao.get_record(sel_player[x]).key)
                logger.debug('Participants ' + str(players))
                match.participants = players
        return match