def blog_view_page_render(view_user_id, art_user_id): relation = user.get_relation(view_user_id, art_user_id) t = { "user": user.get_user(art_user_id), "relation": relation, } return RGUIController.ui_render_template("blogView.html", **t)
def photos_page_render(user_id, other_id, album_id): t = get_data_with_request(request) page = t['page'] if 'page' in t else 0 size = t['size'] if 'size' in t else 10 relation = user.get_relation(user_id, other_id) flag, album_detail = album.album_detail(album_id=album_id, relation=relation) if flag is False: photos, page_count, now_page, page_size, count = \ ([], 1, 1, 10, 0) else: photos, page_count, now_page, page_size, count = \ pic.page_list(other_id, album_id, page, size, relation) t = { "list": photos, "pageCount": page_count, "pageSize": page_size, "nowPage": now_page, "count": count, "user": user.get_user(other_id, need_icon=True), "home": user.isHome(user_id, other_id), 'album': album_detail } return RGUIController.ui_render_template("photos.html", **t)
def do_auth_more_info(need_request_email=False): user_id = None auth = False email = None username = None if 'token' in session and 'type' in session and session[ 'type'] == 0 and session['token'] is not None: if 'user_id' in session: user_id = session['user_id'] email = session['email'] if 'email' in session else None username = session['username'] if 'username' in session else None if need_request_email or username is None: from Model import user _user = user.get_user(user_id=user_id, need_bg=False, need_email=need_request_email) if username is None: session['username'] = _user.username username = _user.username if need_request_email: session['email'] = _user.email email = _user.email auth = True elif 'auth' in request.headers: token = request.headers.get('auth') user_id, auth = tokens.certify_token(token) return auth, user_id, email, username
def ui_render_template(template_name_or_list, **context): art_user_id = request_value(request, 'user_id', None) need_user = int(request_value(request, 'needUserInfo', 0)) if need_user > 0 and (art_user_id is None or is_int_number(art_user_id) is False): return jsonify(form_res(RGResCode.lack_param)) params = dict({"js_ver": RGJSVersion, "css_ver": RGCSSVersion}, **context) render = render_template(template_name_or_list, **params) if need_user > 0: from Model import user auth, view_user_id = do_auth() relation = user.get_relation(view_user_id, art_user_id) re_relation = user.get_relation(art_user_id, view_user_id) t = { "user": user.get_user(art_user_id).__dict__, "home": user.isHome(view_user_id, art_user_id), "auth": view_user_id is not None, "relation": relation, "re_relation": re_relation, 'render': render } return jsonify(form_res(RGResCode.ok, t)) return render
def new_blog_page(user_id): if user_id is not None: return RGUIController.ui_render_template( "edit_blog.html", **{ "user": user.get_user(user_id), }) else: return RGUIController.ui_render_template("login.html")
def photo_page_render(user_id, other_id): albums, re_relation = album.album_list(user_id, other_id) t = { "list": albums, "user": user.get_user(other_id), "home": user.isHome(user_id, other_id), } return RGUIController.ui_render_template("albums.html", **t)
def blog_page_render(art_user_id, view_user_id): relation = user.get_relation(view_user_id, art_user_id) re_relation = user.get_relation(art_user_id, view_user_id) t = { "user": user.get_user(art_user_id), "home": user.isHome(view_user_id, art_user_id), "authed": view_user_id is not None, "relation": relation, "re_relation": re_relation, } return RGUIController.ui_render_template("index.html", **t)
def user_visit_page_info(view_user_id): art_user_id = request_value(request, 'user_id', None) if art_user_id is None or is_int_number(art_user_id) is False: return jsonify(form_res(RGResCode.lack_param)) relation = user.get_relation(view_user_id, art_user_id) re_relation = user.get_relation(art_user_id, view_user_id) t = { "user": user.get_user(art_user_id).__dict__, "home": user.isHome(view_user_id, art_user_id), "auth": view_user_id is not None, "relation": relation, "re_relation": re_relation, } return jsonify(form_res(RGResCode.ok, t))
def edit_blog_page_render(art_id): auth, user_id = RGUIController.do_auth() if auth is True: if art_id is not None: art = article.art_detail(user_id, art_id) if art is None: return redirect(url_for('RGBlog.new_blog_page')) a_user_id = art['user_id'] if a_user_id == user_id: return RGUIController.ui_render_template( "edit_blog.html", **{ 'art': art, "user": user.get_user(user_id), }) return redirect(url_for('RGBlog.new_blog_page')) else: return RGUIController.ui_render_template("login.html")
def art_detail(art_id): auth, user_id = RGUIController.do_auth() art = article.art_detail(user_id, art_id) if art is not None: a_user_id = art['user_id'] _user = user.get_user(a_user_id) home = a_user_id == user_id if home is False: collect_read_count(art_id=art_id, user_id=user_id) else: _user = None home = False return RGUIController.ui_render_template( "blog_page.html", **{ 'art': art, 'flag': art is not None, 'home': home, "user": _user, "authed": auth, })
def set_page(user_id): t = { "user": user.get_user(user_id, need_icon=True, need_username=True), } return RGUIController.ui_render_template("setting.html", **t)