def addQueryRecord(querytext, queryresult): query = QueryRecord() query.user_id = current_user.getUname() query.query_text = querytext query.query_result = queryresult query.time = datetime.datetime.utcnow() db.session.add(query) db.session.commit()
def queryReview(query_number): record = QueryRecord.query.filter_by(record_number=query_number).first() if record is None: return secureResponse(render_template('QueryNotFound.html')) elif current_user.isAdmin or (record.user_id == current_user.getUname()): return secureResponse( render_template('queryReview.html', query_number=record.record_number, uname=record.user_id, text=record.query_text, results=record.query_result)) else: return secureResponse(render_template('QueryNotAuthorized.html'))
def login_history(): form = AdminHistoryForm() if current_user.is_anonymous: return secureResponse(render_template('QueryNotAuthorized.html')) else: uname = current_user.getUname() if current_user.isAdmin and form.validate_on_submit(): results = LoginRecord.query.filter_by( user_id=form.userquery.data).order_by(LoginRecord.record_number) return secureResponse( render_template('loginHistory.html', records=results)) elif current_user.isAdmin: return secureResponse( render_template('loginHistoryForm.html', form=form)) else: return secureResponse(render_template('QueryNotAuthorized.html'))
def history(): form = AdminHistoryForm() uname = current_user.getUname() if current_user.isAdmin and form.validate_on_submit(): uname = form.userquery.data elif current_user.isAdmin: return secureResponse( render_template('historyAdminForm.html', form=form)) results = QueryRecord.query.filter_by(user_id=uname).order_by( QueryRecord.record_number) return secureResponse( render_template('recordResults.html', records=results, count=results.count()))
def logout(): if current_user.is_authenticated: updateLogonRecordAtLogoff(current_user.getUname()) logout_user() return redirect('/login')