Esempio n. 1
0
    def update(self, color=None, sponsor_id=None, league_id=None, year=None):
        """Updates an existing team.

        Raises:
            InvalidField
            SponsorDoesNotExist
            LeagueDoesNotExist
        """
        # does nothing with espys given
        if color is not None and string_validator(color):
            self.color = color
        elif color is not None:
            raise InvalidField(payload={'details': "Team - color"})
        if (sponsor_id is not None
                and Sponsor.query.get(sponsor_id) is not None):
            self.sponsor_id = sponsor_id
        elif sponsor_id is not None:
            raise SponsorDoesNotExist(payload={'details': sponsor_id})
        if league_id is not None and League.query.get(league_id) is not None:
            self.league_id = league_id
        elif league_id is not None:
            raise LeagueDoesNotExist(payload={'details': league_id})
        if year is not None and year_validator(year):
            self.year = year
        elif year is not None:
            raise InvalidField(payload={'details': "Team - year"})
Esempio n. 2
0
 def update(self,
            color=None,
            sponsor_id=None,
            league_id=None,
            year=None):
     '''
     updates an existing team
     Raises:
         InvalidField
         SponsorDoesNotExist
         LeagueDoesNotExist
     '''
     # does nothing with espys given
     if color is not None and string_validator(color):
         self.color = color
     elif color is not None:
         raise InvalidField(payload={'details':"Team - color"})
     if sponsor_id is not None and Sponsor.query.get(sponsor_id) is not None:
         self.sponsor_id = sponsor_id
     elif sponsor_id is not None:
         raise SponsorDoesNotExist(payload={'details':sponsor_id})
     if league_id is not None and League.query.get(league_id) is not None:
         self.league_id = league_id
     elif league_id  is not None:
         raise LeagueDoesNotExist(payload={'details':league_id})
     if year is not None and year_validator(year):
         self.year = year
     elif year is not None:
         raise InvalidField(payload={'details':"Team - year"})
Esempio n. 3
0
    def __init__(self,
                 color=None,
                 sponsor_id=None,
                 league_id=None,
                 year=date.today().year):
        """ The constructor.

        Raises
            InvalidField
            SponsorDoesNotExist
            LeagueDoesNotExist
        """
        if color is not None and not string_validator(color):
            raise InvalidField(payload={'details': "Team - color"})
        if sponsor_id is not None and Sponsor.query.get(sponsor_id) is None:
            raise SponsorDoesNotExist(payload={'details': sponsor_id})
        if league_id is not None and League.query.get(league_id) is None:
            raise LeagueDoesNotExist(payload={'details': league_id})
        if year is not None and not year_validator(year):
            raise InvalidField(payload={'details': "Team - year"})
        self.color = color
        self.sponsor_id = sponsor_id
        self.league_id = league_id
        self.year = year
        self.kik = None
Esempio n. 4
0
 def __init__(self,
              color=None,
              sponsor_id=None,
              league_id=None,
              year=date.today().year):
     '''
     Raises
         InvalidField
         SponsorDoesNotExist
         LeagueDoesNotExist
     '''
     if color is not None and not string_validator(color):
         raise InvalidField(payload={'details':"Team - color"})
     if sponsor_id is not None and Sponsor.query.get(sponsor_id) is None:
         raise SponsorDoesNotExist(payload={'details':sponsor_id})
     if league_id is not None and League.query.get(league_id) is None:
         raise LeagueDoesNotExist(payload={'details':league_id})
     if year is not None and not year_validator(year):
         raise InvalidField(payload={'details':"Team - year"})
     self.color = color
     self.sponsor_id = sponsor_id
     self.league_id = league_id
     self.year = year
     self.kik = None