def info(login): try: user = User("login", login) except UserNotFound: raise NotFound try: data = users.info(user) except SubscribeError: raise Forbidden data["id"] = user.id data["login"] = user.login try: data["created"] = data["created"] except (KeyError, AttributeError): pass try: data["birthdate"] = data["birthdate"] except (KeyError, AttributeError): pass if env.user.id: data["subscribed"] = user.check_subscriber(env.user) data["rec_sub"] = user.check_rec_subscriber(env.user) if not data["subscribed"]: data["bl"] = env.user.check_blacklist(user) if not data["bl"]: data["wl"] = env.user.check_blacklist(user) return data
def info(login): try: user = User('login', login) except UserNotFound: raise NotFound try: data = users.info(user) except SubscribeError: raise Forbidden data['id'] = user.id data['login'] = user.login try: data['created'] = data['created'] except (KeyError, AttributeError): pass try: data['birthdate'] = data['birthdate'] except (KeyError, AttributeError): pass if env.user.id: data['subscribed'] = user.check_subscriber(env.user) data['rec_sub'] = user.check_rec_subscriber(env.user) if not data['subscribed']: data['bl'] = env.user.check_blacklist(user) if not data['bl']: data['wl'] = env.user.check_blacklist(user) return data
def info(login): try: user = User('login', login) except UserNotFound: raise NotFound try: data = users.info(user) except SubscribeError: raise Forbidden data['login'] = login try: data['created'] = timestamp(data['created']) except (KeyError, AttributeError): pass try: data['birthdate'] = timestamp(data['birthdate']) except (KeyError, AttributeError): pass if env.user.id: data['subscribed'] = user.check_subscriber(env.user) data['rec_sub'] = user.check_rec_subscriber(env.user) if not data['subscribed']: data['bl'] = env.user.check_blacklist(user) if not data['bl']: data['wl'] = env.user.check_blacklist(user) return Response(json.dumps(data), mimetype='application/json')
def info(login, show=False, offset=None, limit=None): """Get user info """ try: user = User('login', login) data = users.info(user) except UserNotFound: return xmpp_template('user_not_found', login=login) except SubscribeError: return xmpp_template('user_denied', login=login) data['realname'] = data['name'] del data['name'] #_posts = None if show: if offset: offset = int(offset) if limit: limit = int(limit) else: limit = 10 if env.user and env.user.id and env.user.id == user.id: private = None else: private = False #plist = posts.select_posts(author=user, private=private, # offset=offset, limit=limit) plist = posts.recent_blog_posts(author=user, offset=offset, limit=limit) plist.reverse() data['posts'] = plist else: data['posts_count'] = user.posts_count() return xmpp_template('user_info', login=login, **data)
def my_info(): login = env.user.login if not login: raise NotAuthorized return users.info(login)