Example #1
0
    def execute(self):
        result = Result()

        token = SoundBank().token_for_user(user=self._user)
        result.set_object(token)

        return result
Example #2
0
    def execute(self):
        result = Result()

        sounds = SoundBank().sounds_for_user(user=self._user,
                                             query=self._query)
        result.set_object(sounds)

        return result
Example #3
0
 def execute(self):
     result = Result()
     user = SoundBank().get_create_or_update_user(
         user_id=self._user_id,
         username=self._username,
         first_name=self._first_name,
         last_name=self._last_name)
     result.set_object(user)
     return result
Example #4
0
    def execute(self):
        result = Result()

        try:
            user, token_has_expired = SoundBank().user_from_token(
                token=self._token)
            if token_has_expired:
                result.add_error("Token has expired")
            else:
                two_hours = 60 * 60 * 2
                self._request.session.set_expiry(two_hours)
                self._request.session['user_id'] = user.user_id()
                result.set_object(user)
        except UserNotFoundException:
            result.add_error("User not found")

        return result
Example #5
0
    def execute(self):
        result = Result()

        try:
            sound = SoundBank().sound_from_id(sound_id=self._sound_id)
            result.set_object(sound)
        except SoundNotFoundException:
            result.add_error("Sound not found")

        return result
Example #6
0
    def execute(self):
        result = Result()

        try:
            user = SoundBank().user_from_id(user_id=self._user_id)
            result.set_object(user)
        except UserNotFoundException:
            result.add_error("User not found")

        return result
Example #7
0
 def execute(self):
     SoundBank().user_listened_sound(user=self._user, sound=self._sound)
     return Result()
Example #8
0
 def execute(self):
     result = Result()
     result.set_object(
         UserFromIdCommand(user_id=self._request.session['user_id']).
         execute().get_object())
     return result
Example #9
0
 def execute(self):
     result = Result()
     result.set_object('user_id' in self._request.session)
     return result
Example #10
0
 def execute(self):
     del self._request.session['user_id']
     return Result()