Пример #1
0
    def get_messages(self, request):
        """Send a friend request."""
        verify_and_get_user(token=request.token)

        msg = actions.get_messages(ndb.Key(urlsafe=request.parent_key))

        return msg
Пример #2
0
    def get_nearby_users(self, request):
        """
		Get nearby users
		"""
        actions.verify_and_get_user(token=request.token)

        msg = actions.get_nearby_users(request)
        return msg
Пример #3
0
    def user_search(self, request):
        """
		Searchers for users
		"""
        actions.verify_and_get_user(token=request.token)

        msg = actions.user_search(request.term)
        return msg
Пример #4
0
    def get_friends_list(self, request):
        """Return a list of friends for the specified user."""
        actions.verify_and_get_user(token=request.token)

        friends_list = actions.get_friends_list(request.user)

        msg = messages.FriendList()
        msg.friends = [k.id() for k in friends_list.friends]

        return msg
Пример #5
0
    def get_relationship(self, request):
        """
		Returns the relationship between two users.
		"""
        actions.verify_and_get_user(token=request.token)

        relationship = actions.get_relationship(request.userA, request.userB)

        msg = mmglue.message_from_model(relationship, messages.Relationship)
        msg.users = [k.id() for k in relationship.users]

        return msg
Пример #6
0
    def get_user_thread_key(self, request):
        """Returns the key to the thread between the authenticating user and another."""
        auth_user = verify_and_get_user(token=request.token)

        msg = actions.get_two_user_thread(auth_user, request.user)

        return msg
Пример #7
0
    def add_message(self, request):
        """Send a friend request."""
        auth_user = verify_and_get_user(token=request.token)

        msg = actions.add_message(request, auth_user)

        return actions.auth_chat_message_to_chat_message(msg, auth_user)
Пример #8
0
    def leave_game(self, request):
        """The authenticating user leaves a game."""
        auth_user = verify_and_get_user(token=request.token)

        game = actions.leave_game(auth_user, ndb.Key(urlsafe=request.key))

        return actions.game_model_to_message(game)
Пример #9
0
    def test_verify_and_get_user(self):
        user = models.User(full_name='hello', first_name="hello")
        user.initialise_new_token()
        user.put()

        result = actions.verify_and_get_user(token=user.get_token())

        assert user == result
Пример #10
0
    def create_new_game(self, request):
        """Adds a new game to the system."""

        auth_user = verify_and_get_user(token=request.token)

        game = actions.create_new_game(auth_user, request)

        return actions.game_model_to_message(game)
Пример #11
0
    def delete_sport_profile(self, request):
        """Delets a sport profile from the authenticating user."""

        auth_user = verify_and_get_user(token=request.token)

        actions.delete_sport_profile(auth_user, request)

        return VoidMessage()
Пример #12
0
    def add_sport_profile(self, request):
        """Adds a sport profile to the authenticating user."""

        auth_user = verify_and_get_user(token=request.token)

        profile = actions.add_sport_profile(auth_user, request)

        return profile
Пример #13
0
    def search_for_sportmates(self, request):
        """Search for nearby sportmates."""

        auth_user = verify_and_get_user(token=request.token)

        profiles = actions.search_for_sportmates(request)

        return profiles
Пример #14
0
    def add_game_comment(self, request):
        """Adds a comment to a game."""

        auth_user = verify_and_get_user(token=request.token)

        comment = actions.add_comment_to_game(auth_user, request.game_key,
                                              request.text)

        return comment
Пример #15
0
    def friend_request(self, request):
        """Send a friend request."""
        auth_user = actions.verify_and_get_user(token=request.token)

        relationship = actions.friend_request(auth_user.key.id(), request.user)

        msg = mmglue.message_from_model(relationship, messages.Relationship)
        msg.users = [k.id() for k in relationship.users]

        return msg
Пример #16
0
    def unfriend(self, request):
        """
		Remove the specified user as a friend of the authenticating user.
		"""
        auth_user = actions.verify_and_get_user(token=request.token)

        relationship = actions.unfriend(auth_user.key.id(), request.user)

        msg = mmglue.message_from_model(relationship, messages.Relationship)
        msg.users = [k.id() for k in relationship.users]

        return msg
Пример #17
0
    def get_user(self, request):
        """
		Get information about a user.
		"""
        auth_user = actions.verify_and_get_user(token=request.token)

        if request.user is None:
            msg = actions.user_to_message(auth_user)
        else:
            msg = actions.get_user(request.user)

        return msg
Пример #18
0
    def respond_to_friend_request(self, request):
        """
		Answer a friend request from a user to the authenticating user.
		"""
        auth_user = actions.verify_and_get_user(token=request.token)

        relationship = actions.respond_to_friend_request(
            auth_user, request.user, request.accept)

        msg = mmglue.message_from_model(relationship, messages.Relationship)
        msg.users = [k.id() for k in relationship.users]

        return msg
Пример #19
0
 def get_upcoming(self, request):
     """Returns a list of all the user's upcoming games."""
     auth_user = verify_and_get_user(token=request.token)
     return actions.get_upcoming(auth_user)
Пример #20
0
 def testVerifyAndGetUserFail(self):
     actions.verify_and_get_user(token='nothing')
Пример #21
0
 def get_all_categories(self, request):
     """Returns a list of all the user's upcoming games."""
     verify_and_get_user(token=request.token)
     return actions.get_all_categories()