Esempio n. 1
0
def get_user_from_id(id,
                     id_type="url_slug",
                     show_secrets=False,
                     include_items=True):
    if id_type == "id":
        try:
            user = User.query.get(id)
        except DataError:  # id has to be an int
            logger.debug(
                u"get_user_from_id no user found from userid {id}".format(
                    id=id))
            user = None

    elif id_type == "email":
        user = User.query.filter(
            func.lower(User.email) == func.lower(id)).first()

    elif id_type == "url_slug":
        user = User.query.filter(
            func.lower(User.url_slug) == func.lower(id)).first()

    if not show_secrets:
        user = hide_user_secrets(user)

    try:
        user.profile_awards = profile_award.make_awards_list(user)
    except AttributeError:
        # there ain't no user
        pass

    return user
Esempio n. 2
0
def get_user_from_id(id, id_type="url_slug", show_secrets=False, include_items=True):
    if id_type == "id":
        try:
            user = User.query.get(id)
        except DataError:  # id has to be an int
            logger.debug(u"get_user_from_id no user found from userid {id}".format(
                id=id))
            user = None

    elif id_type == "email":
        user = User.query.filter(func.lower(User.email) == func.lower(id)).first()

    elif id_type == "url_slug":
        user = User.query.filter(func.lower(User.url_slug) == func.lower(id)).first()

    if not show_secrets:
        user = hide_user_secrets(user)

    try:
        user.profile_awards = profile_award.make_awards_list(user)
    except AttributeError:
        # there ain't no user
        pass

    return user
Esempio n. 3
0
 def awards(self):
     return profile_award.make_awards_list(self)
Esempio n. 4
0
 def awards(self):
     return profile_award.make_awards_list(self)