def update_user(self, user):
        """

        :type user: User
        """
        user_api = UserAPI()
        return user_api.update_user(user)
    def add_user(self, user):
        """

        :type user: User
        """
        user_api = UserAPI()
        return user_api.add_user(user)
    def update_password(self, user_name, password):

        user_api = UserAPI()
        user = user_api.get_user(user_name)
        if user:
            user.password = password
            return user_api.update_user(user)
        else:
            return ManageUserStatus().error
Ejemplo n.º 4
0
def add_user(user):
    """

    :type user: User
    """
    if not user:
        user = User()
        user.user_name="mostafa"
    user_api = UserAPI()
    return user_api.add_user(user)
Ejemplo n.º 5
0
def update_user():
    """

    :type user: User
    """

    user = User()
    user.user_name="mostafa"
    user.password="******"
    user.role_id=2
    user_api = UserAPI()
    return user_api.update_user(user)
Ejemplo n.º 6
0
def check_auth(username, password):
    """
    This function is called to check if a username / password combination is valid.
    """
    user_api = UserAPI()
    user = user_api.get_user(str(username).lower())
    if user and user.user_name == str(
            username).lower() and user.password == password:
        session['user'] = user.user_name
        session['role_id'] = user.role_id
        return True
    return False
Ejemplo n.º 7
0
    def _get_followers(self):
        user_list = UserAPI().get_users()
        followers = []
        for usr in user_list:
            if usr.notfiy:
                followers.append(usr)

        return followers
Ejemplo n.º 8
0
    def test_email(self, sender_email, server, port, password, security,
                   logged_in_user_name):
        user_api = UserAPI()
        status = EmailStatus()
        user = user_api.get_user(logged_in_user_name)
        if not user.notfiy:
            status.success = False
            status.err_msg = gettext(
                "core_email_test_user_not_set_receive_notify")
            return status
        elif len(user.email.strip()) == 0:
            status.success = False
            status.err_msg = gettext(
                "core_email_test_user_not_set_receive_email")
            return status

        msg = email_utils.create_msg(sender_email, user.email,
                                     gettext("core_email_test_subject"),
                                     gettext("core_email_test_body"))
        status = email_utils.send_email(server, port, msg, password, security)
        return status
Ejemplo n.º 9
0
def get_user(name):
    user_api = UserAPI()
    u=user_api.get_user("mostafa")
    print  u.user_name,u.password,u.role_id
Ejemplo n.º 10
0
def del_user(name):
    user_api = UserAPI()
    return user_api.delete_user(name)
Ejemplo n.º 11
0
def get_list():
    user_api = UserAPI()
    for u in user_api.get_users():
        print u.user_name
 def get_user(self, user_name):
     user_api = UserAPI()
     return user_api.get_user(user_name)
 def delete_user(self, user_name):
     user_api = UserAPI()
     return user_api.delete_user(user_name)
 def get_users(self):
     user_api = UserAPI()
     return user_api.get_users()