示例#1
0
 def clean_game_id(self):
     game_id = self.cleaned_data.get('game_id', '')
     try:
         int(game_id)
         from film20.contest.contest_helper import ContestHelper
         contest_helper = ContestHelper()
         self.the_game = contest_helper.get_game_by_id(game_id)
         if self.the_game is None:
             logger.debug("Game not found for game_id=" + str(game_id))
             raise forms.ValidationError(
                 _("Game not found for game_id=" + str(game_id)))
     except ValueError:
         logger.debug("game_id must be integer!")
         raise forms.ValidationError(_("game_id must be integer!"))
     return int(game_id)
示例#2
0
 def clean_character_id(self):
     character_id = self.cleaned_data.get('character_id', '')
     try:
         int(character_id)
         from film20.contest.contest_helper import ContestHelper
         contest_helper = ContestHelper()
         self.the_character = contest_helper.get_character_from_game(
             self.the_game, character_id)
         logger.debug(self.the_character)
         if self.the_character is None:
             logger.debug("Character not found in game, id=" +
                          str(character_id))
             raise forms.ValidationError(
                 _("Character not found in game, id=" + str(character_id)))
     except ValueError:
         logger.debug("character_id must be integer!")
         raise forms.ValidationError(_("character_id must be integer!"))
     return int(character_id)