Esempio n. 1
0
    def setScore(self, score):
        try:
            score = int(score)
        except ValueError:
            raise DomainException("Score must be an integer")

        if score > 99999 or score < -99999:
            raise DomainException("Score must be between -99999 and +99999")

        self._score = score
Esempio n. 2
0
    def setId(self, value):
        try:
            value = int(value)
        except ValueError:
            raise DomainException("The id must be an integer")

        if value < 0:
            raise DomainException("The id must be greater than one")

        self._id = value
Esempio n. 3
0
	def setVerified(self, value):
		try:
			value = bool(value)				# converts it to boolean type (1 = True and 0 = False)
		except NameError:
			raise DomainException("You can only set verified to true or false")

		self._verified = value
Esempio n. 4
0
    def setTime(self, time):
        if type(time) is not datetime:
            raise DomainException(
                "Time attribute must be a datetime object not a %s" %
                str(type(time)))

        self._time = time
Esempio n. 5
0
    def setEndTime(self, time):
        if type(time) is not datetime and time is not None:
            raise DomainException(
                "The end time must be either empty or a datetime object not %s"
                % str(type(time)))

        self._endTime = time
Esempio n. 6
0
    def setToken(self, token):
        if token is not None:
            if not isinstance(token, Apitoken):
                raise DomainException(
                    "Token must be an API Token Model Object")

        self._token = token
Esempio n. 7
0
    def setCreator(self, creator):
        from Model.user import User

        if not isinstance(creator, User):
            raise DomainException(
                "Creator must be an instance of the User object")

        self._creator = creator
Esempio n. 8
0
    def setGameType(self, gameType):
        from Model.gametype import GameType

        if not isinstance(gameType, GameType):
            raise DomainException(
                "gametype must be an instance of the GameType object")

        self._gameType = gameType
Esempio n. 9
0
    def setGame(self, game_):
        if game_ is not None:
            if not isinstance(game_, Game):
                raise DomainException(
                    "Game attribute must be a reference to another Game object"
                )

            self._game = game_
Esempio n. 10
0
    def setUser(self, user_):
        from Model.user import User

        if not isinstance(user_, User):
            raise DomainException("Must reference a User object not a %s" %
                                  str(type(user_)))

        user_.setToken(self)
        self._user = user_
Esempio n. 11
0
    def setEmail(self, email):

        if email is not None:
            email = str(email)

            pattern = r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
            if not re.match(pattern, email):
                raise DomainException("'%s' is not a valid email address" %
                                      email)

        # email checking needs to be added to user
        self._email = email
Esempio n. 12
0
	def setVictim(self, victim):
		if victim is not None:
			if not isinstance(victim, Player):
				raise DomainException("Victim must be a Player object")

		self._victim = victim
Esempio n. 13
0
	def setKiller(self, killer):
		if killer is not None:
			if not isinstance(killer, Player):
				raise DomainException("Killer must be a Player object")

		self._killer = killer
Esempio n. 14
0
    def setToken(self, token):
        if len(token) != 64:
            raise DomainException(
                "That is not a valid API Token, should be a 64 character hash")

        self._token = token
Esempio n. 15
0
    def setName(self, name):
        if len(name) > 255:
            raise DomainException(
                "The name of a game cannot be more than 255 characters")

        self._name = name
Esempio n. 16
0
    def setUser(self, user_):
        if not isinstance(user_, User):
            raise DomainException(
                "User attribute must be a reference to another User object")

        self._user = user_
Esempio n. 17
0
    def setTime(self, time_):
        if time_ is not None:
            if type(time_) is not datetime:
                raise DomainException("Time must a datetime object")

            self._time = time_
Esempio n. 18
0
    def setName(self, name):
        if len(name) > 60:
            raise DomainException(
                "User's name must be less than 60 characters")

        self._name = name
Esempio n. 19
0
    def setPhoto(self, photo):
        if photo is not None:
            if len(photo) is not 32:
                raise DomainException("That is not a photo")

        self._photo = photo
Esempio n. 20
0
    def setTime(self, time):
        if type(time) is not datetime:
            raise DomainException("Time must be a datetime object, not a %s" %
                                  type(time))

        self._time = time
Esempio n. 21
0
	def setTime(self, time_):
		if type(time_) is "<type 'datetime.datetime'>":
			raise DomainException("Time must a datetime object")

		self._time = time_
Esempio n. 22
0
    def setPhoto(self, photo):
        if photo is not None:
            if len(photo) != 32:
                raise DomainException("Photo must be a 32 character string")

        self._photo = photo