Esempio n. 1
0
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
Esempio n. 2
0
def video_view_page(user_file_id):
    if is_int_number(user_file_id):
        user_file_id = int(user_file_id)
        auth, user_id = RGUIController.do_auth()
        if not auth:
            return redirect(url_for('login_page'))
        if user_file_id == -1 or files.user_file_info(
                user_id=user_id, id=user_file_id, type=1) is not None:
            code = RGRequestHelp.did_encode(user_file_id, user_id)
            return redirect(
                url_for('RGFileUpDown.play_list_page',
                        user_id_directory_id=code))
    return RGUIController.ui_render_template('VideoPreview.html')
Esempio n. 3
0
def user_file_path_get(user_file_id, path):
    if user_file_id is None:
        return jsonify(form_res(RGResCode.lack_param))
    user_file_id = re.sub("[^A-Za-z0-9].*", "", user_file_id)
    if not is_int_number(user_file_id):
        return jsonify(form_res(RGResCode.lack_param))
    auth, user_id = RGUIController.do_auth()
    session.removeVaryCookie = True
    file = files.user_file_info(user_id=user_id, id=user_file_id, type=0)

    if path is not None:
        file['filename'] = file['filename'] + '/' + path
        file['name'] = path.split('/')[-1]
        del file['mime']
    return __get_file_stream(file, max_age=86400)
Esempio n. 4
0
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))
Esempio n. 5
0
def blog_view_page(other_id):
    if is_int_number(other_id):
        auth, view_user_id = RGUIController.do_auth()
        return blog_view_page_render(view_user_id, other_id)
    else:
        return redirect(url_for('RGBlog.auto_blog_view_page'))
Esempio n. 6
0
def blog_page(other_id):
    if is_int_number(other_id):
        auth, view_user = RGUIController.do_auth()
        return blog_page_render(other_id, view_user)
    return redirect(url_for('login_page'))
Esempio n. 7
0
def photos_page(other_id, album_id):
    if is_int_number(other_id) and is_int_number(album_id):
        auth, user_id = RGUIController.do_auth()
        return photos_page_render(user_id, other_id, album_id)
    return redirect(url_for('login_page'))
Esempio n. 8
0
def photo_page(other_id):
    if is_int_number(other_id):
        auth, user_id = RGUIController.do_auth()
        return photo_page_render(user_id, other_id)
    else:
        return redirect(url_for('RGPhoto.auto_photo_page'))