def route_settings(): lang = Language(get_user_lang(request.headers, current_user)) if current_user.is_banned(): return render_template("errors/banned.html", lang=lang) error, oldform, success = None, None, False if request.method == "POST": lform = SettingsForm(request.form).localized(lang) if lform.validate(): error = handle_settings(current_user.get_id(), request.form) if error: error = lang.tr(error) else: success = True else: oldform = lform nform = SettingsForm(obj=populate_dict( { "username": current_user.get_user_name(), "displayname": current_user.get_display_name(), "bio": current_user.get_user_bio(), "language": current_user.get_language(), "privatemessages": current_user.are_messages_private(), "privatefollows": current_user.are_follows_private(), "privatelikes": current_user.are_likes_private() })).localized(lang) if oldform == None: oldform = nform return render_template("auth/settings.html", lang=lang, form=nform, deleteform=DeleteAccountForm().localized(lang), oldform=oldform, error=error, success=success)
def do_main(request): return render_template( 'svcdb_main.html', user_name=current_user.get_user_name(), turbine_list_url=list_url(), Const=Const, )
def route_new(): lang = Language(get_user_lang(request.headers, current_user)) if current_user.is_banned(): return render_template("errors/banned.html", lang=lang) error, oldform = None, None if request.method == "POST": lform = NewPostForm(request.form) if lform.validate(): (postid, error) = new_message(current_user.get_id(), request.form) if error: error = lang.tr(error) else: return redirect( url_for("route_message", username=current_user.get_user_name(), postid=postid)) else: oldform = lform test_reply_id = request.args.get("reply", default=None) try: msg, reply_id = get_message_by_id(int(test_reply_id)), test_reply_id except: msg, reply_id = None, "" nform = NewPostForm().localized(lang) if oldform == None: oldform = nform return render_template("write/new.html", lang=lang, form=nform, oldform=oldform, reply=render_message(lang, msg), reply_id=reply_id, error=error)
def showCtxSearchList(db_id, request): if len(db_id) == 0: return render_template('error/404.html') db_name = "" result_cnt = 0 if app.lib.cms_lib.session.current_db: db_name = app.lib.cms_lib.session.current_db.db_name # 全文検索テキストを取得する if request.method == 'GET': ctx_search_text = request.args.get('ctx_search_text') if request.method == 'POST': ctx_search_text = request.form['ctx_search_text'] if not ctx_search_text: if request.method == 'POST': flash('検索条件を入れてください') ctx_search_list = None ctx_search_text = '' elif StrUtil.lenb(ctx_search_text) > 256 and request.method == 'POST': flash('検索条件が長すぎます') ctx_search_list = None else: # 全文検索リストを取得 cmsCtxData = CmsCtxData() ctx_cond = CtxUtil.process_ctx_search_text(ctx_search_text) result_cnt = cmsCtxData.getCtxSearchListCnt(db_id, ctx_cond) ctx_search_list = cmsCtxData.getCtxSearchList(db_id, ctx_cond) note = ctx_search_text if len(note) > 100: note = ctx_search_text[0:100] # 全文検索を記録する pkgCmsLog = PkgCmsLog() pkgCmsLog.saveOperationLog(current_user.tuid, db_id, operation_cd=Const.OPERATION_CD_CTX_SEARCH, note='SearchCond: {}, ResultCnt: {}'.format( note, result_cnt)) db.session.commit() user_name = '' if current_user.is_active: user_name = current_user.get_user_name() return render_template('ctx_search.html', db_id=db_id, db_name=db_name, result_cnt=result_cnt, user_name=user_name, ctx_search_text=ctx_search_text, ctx_search_list=ctx_search_list, appVer=current_app.config['APP_VER'])
def svcdb_processor(): resp_dict = { "system_name": Const.SYSTEM_NAME, "current_user": current_user, "user_name": current_user.get_user_name() if current_user.is_active else "", "appVer": Config.APP_VER } return resp_dict
def login(): form = LoginForm() if form.validate_on_submit(): # We need a check if the user actually exist user = User(form.user.data) user.check_pass(form.password.data) user.printdata() if user.is_authenticated() == True: if login_user(user) == True: flash("Hello {}".format(current_user.get_user_name())) return redirect(current_app.login_redirect_to) else: return render_template('login.html', title='Sign In', form=form) else: return render_template('login.html', title='Sign In', form=form) else: return render_template('login.html', title='Sign In', form=form)
def route_msg_edit(): lang = Language(get_user_lang(request.headers, current_user)) if current_user.is_authenticated and current_user.is_banned(): return render_template("errors/banned.html", lang=lang) error, oldform = None, None if request.method == "POST": lform = EditPostForm(request.form) if lform.validate(): error = edit_message(current_user.get_id(), request.form) if error: error = lang.tr(error) else: return redirect( url_for("route_message", username=current_user.get_user_name(), postid=request.form["msg"])) else: oldform = lform test_msg_id = request.args.get("msg", default=None) try: msg = get_message_by_id(int(test_msg_id)) if msg.get_author_id() != current_user.get_id(): return abort(403) except: return redirect(url_for("route_feed")) nform = EditPostForm(obj=populate_dict({ "contents": msg.get_text(), "link": msg.get_link() })).localized(lang) if oldform == None: oldform = nform return render_template("write/edit.html", lang=lang, form=nform, oldform=oldform, msg=msg, error=error, render_message=bind1(render_message, lang))
def doLogin(db_id, form): if len(db_id) == 0: flash('[db_id]パラメータを入れてください') return render_template('error/404.html') # データベースオブジェクトを取得する current_db = app.lib.cms_lib.session.get_current_db(db_id) # グローバル変数に設定する app.lib.cms_lib.session.current_db = current_db if current_db is None: flash('[db_id:{}]情報を取得できません'.format(db_id)) return render_template('error/404.html') StrUtil.print_debug("login_required. cur_db.db_id=[{}]".format( str(current_db.db_id))) # リダイレクトURLを取得する next_url = _get_next_url() if form.validate_on_submit(): user = User.query.filter_by(tuid=form.user_id.data).first() if user is None or not PkgUserAuth.check_passwd_for_cms( form.user_id.data, form.password.data): # エラーログを記録する pkgCmsErrLog = PkgCmsErrLog() pkgCmsErrLog.saveErrLog('LOGIN_ERROR', str(form.user_id.data), str(current_db.db_id), '') db.session.commit() flash('invalid user_id or password') return redirect( url_for('login', db_id=db_id, user_id=form.user_id.data, next_url=next_url)) login_user(user, False) session['last_login_user_id'] = form.user_id.data session[str(db_id) + '_is_edit_mode'] = False # ログインログを記録する pkgCmsLog = PkgCmsLog() pkgCmsLog.saveOperationLog(form.user_id.data, db_id, operation_cd=Const.OPERATION_CD_LOGIN, object_type='DB', note=current_db.db_name) db.session.commit() return set_cookie(current_db.session_cookie_name, current_user.tuid, url_for('index', db_id=db_id)) # ログイン情報を保持する last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id', session) user_id = request.args.get('user_id') or last_login_user_id if user_id: form.user_id.data = user_id user_name = '' if current_user.is_active: user_name = current_user.get_user_name() return render_template( 'login.html', title=current_db.db_name + '-ログイン画面', systemVersion="Developer Version 1.00", form=form, db_id=db_id, next_url=next_url, db_name=current_db.db_name, user_name=user_name, loginMessage=current_db.login_message, )