def post(self): date1 = request.form.get('date1') date2 = request.form.get('date2') print(date1, date2) if date1 == '' and date2 == '': return restful.params_error(message='请选择时间范围或者某一天!') if date1 == '' and date2 != '': return restful.params_error(message='请在第一个时间框内输入,查询当天的信息!') if date1: if date2: if dateTOtimestamp(date1) > dateTOtimestamp(date2): return restful.params_error(message='查询的时间不合法!') else: account = Account.objects(operator=g.eog_user.email, today__gte=date1, today__lte=date2).order_by('-operate_time').all() print(account) if not account: return restful.params_error(message='没有找到这一时间段的账号信息') else: return restful.success(data=account) else: account = Account.objects(operator=g.eog_user.email,today=date1).order_by('-operate_time').all() print(account) if not account: return restful.params_error(message='没有找到{}的账号信息'.format(date1)) else: return restful.success(data=account)
def before_request(): if config.DevelopmentConfig.CMS_USER_ID in session: user_id = session.get(config.DevelopmentConfig.CMS_USER_ID) user = User.objects(_id=user_id).first() event_count = Event_Search_Engine.objects().count() rules_count = Rule.objects().count() log = Log.objects(handler=user.email).order_by('-login_time').first() all_today_log = Log.objects(handler=user.email, today=str(datetime.datetime.now().strftime('%Y-%m-%d')) + ' ' + '0:00:00').order_by( '-login_time').all() account = Account.objects(operator=user.email, operate_time__gte=(datetime.datetime.now() - datetime.timedelta(days=7)).strftime( "%Y-%m-%d %H:%M:%S"), operate_time__lt=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")).order_by( '-operate_time').all() if user: g.eog_user = user g.user_log = log g.all_log = all_today_log g.event_count = event_count g.rules_count = rules_count g.account = account