Exemplo n.º 1
0
def is_email_existed(email):
    try:
        ChatAppUser.get(ChatAppUser.email == email)
        return True
    except ChatAppUser.DoesNotExist:
        pass
    return False
Exemplo n.º 2
0
def register(username, password, birthday, fullname, email, address, sex=None):
    try:
        ChatAppUser.create(username=username,
                           password=password,
                           birthday=birthday,
                           fullname=fullname,
                           email=email,
                           address=address,
                           sex=sex)
        return True
    except Exception as Ex:
        pass
    return False
Exemplo n.º 3
0
def login(email, password):
    try:
        user = ChatAppUser.get((ChatAppUser.email == email)
                               & (ChatAppUser.password == password))
        return user
    except ChatAppUser.DoesNotExist:
        pass
Exemplo n.º 4
0
def search_friends_by_user_id_and_friend_name(user_id, username):
    _ret_data = ChatAppUser.select().where(
        ChatAppUser.id.in_(
            ChatAppFriend.select(ChatAppFriend.friend).where(
                (ChatAppFriend.user == user_id)
                & (ChatAppUser.username.contains(username)))))

    return _ret_data
Exemplo n.º 5
0
def detail_user(user_id):
    try:
        _ret_data = ChatAppUser.select(
            ChatAppUser.username, ChatAppUser.fullname, ChatAppUser.email,
            ChatAppUser.sex, ChatAppUser.birthday,
            ChatAppUser.address).where(ChatAppUser.id == user_id)
        return _ret_data
    except Exception as Ex:
        pass
Exemplo n.º 6
0
def get_all_friends(user_id):
    try:
        _ret_data = (ChatAppUser.select(
            ChatAppUser.id, ChatAppUser.username).where(
                ChatAppUser.id.in_(
                    ChatAppFriend.select(ChatAppFriend.friend).where(
                        ChatAppFriend.user == user_id))))
        return _ret_data
    except Exception as Ex:
        pass
Exemplo n.º 7
0
def get_receiver_message(sender_id):
    try:
        _ret_dat = (ChatAppUser.select(
            ChatAppUser.id, ChatAppUser.username).where(
                ChatAppUser.id.in_(
                    ChatAppMessage.select(
                        ChatAppMessage.receiver.distinct()).where(
                            ChatAppMessage.sender == sender_id))))
        return _ret_dat
    except Exception as Ex:
        print(Ex)
Exemplo n.º 8
0
def get_all_blocks_user(user_id):
    try:
        _ret_data = (ChatAppUser.select(
            ChatAppUser.id, ChatAppUser.username).where(
                ChatAppUser.id.in_(
                    ChatAppBlockUser.select(ChatAppBlockUser.user).where(
                        ChatAppBlockUser.blocker == user_id))).order_by(
                            ChatAppUser.username.asc()))
        return _ret_data
    except Exception as Ex:
        pass
Exemplo n.º 9
0
def get_sender_message(receiver_id):
    try:
        _ret_data = (ChatAppUser.select(
            ChatAppUser.id, ChatAppUser.username).where(
                ChatAppUser.id.in_(
                    ChatAppMessage.select(
                        ChatAppMessage.sender.distinct()).where(
                            (ChatAppMessage.receiver == receiver_id)
                            & (ChatAppMessage.is_read == 0)))))
        return _ret_data
    except Exception as Ex:
        print(Ex)
Exemplo n.º 10
0
def search_user_by_id_and_by_name(user_id, username):
    try:
        _ret_data = (ChatAppUser.select(
            ChatAppUser.id,
            ChatAppUser.username).order_by(ChatAppUser.username.asc()).where(
                ChatAppUser.id.not_in(
                    ChatAppBlockUser.select(ChatAppBlockUser.user).where(
                        ChatAppBlockUser.blocker == user_id))
                & (ChatAppUser.username.contains(username)
                   & (ChatAppUser.id != user_id))))

        return _ret_data
    except Exception as Ex:
        pass