def handle_request(mpan_cores=None): start_year = req_int("start_year") start_month = req_int("start_month") start_day = req_int("start_day") start_date_ct = ct_datetime(start_year, start_month, start_day) finish_year = req_int("finish_year") finish_month = req_int("finish_month") finish_day = req_int("finish_day") finish_date_ct = ct_datetime(finish_year, finish_month, finish_day, 23, 30) imp_related = req_bool("imp_related") channel_type = req_str("channel_type") is_zipped = req_bool("is_zipped") supply_id = req_int("supply_id") if "supply_id" in request.values else None user = g.user args = ( start_date_ct, finish_date_ct, imp_related, channel_type, is_zipped, supply_id, mpan_cores, user, ) threading.Thread(target=content, args=args).start() return chellow_redirect("/downloads", 303)
def handle_request(mpan_cores=None): start_date = req_date('start') finish_date = req_date('finish') imp_related = req_bool('imp_related') channel_type = req_str('channel_type') is_zipped = req_bool('is_zipped') supply_id = req_int('supply_id') if 'supply_id' in request.values else None user = g.user threading.Thread(target=content, args=(start_date, finish_date, imp_related, channel_type, is_zipped, supply_id, mpan_cores, user)).start() return chellow_redirect("/downloads", 303)
def handle_request(mpan_cores=None): start_date = req_date('start') finish_date = req_date('finish') imp_related = req_bool('imp_related') channel_type = req_str('channel_type') is_zipped = req_bool('is_zipped') supply_id = req_int('supply_id') if 'supply_id' in request.values else None user = g.user threading.Thread( target=content, args=( start_date, finish_date, imp_related, channel_type, is_zipped, supply_id, mpan_cores, user)).start() return chellow_redirect("/downloads", 303)
def do_post(sess): start_date = req_date("start") finish_date = req_date("finish") supply_id = req_int("supply_id") if "supply_id" in request.values else None if "mpan_cores" in request.values: mpan_cores_str = req_str("mpan_cores") mpan_cores = mpan_cores_str.splitlines() if len(mpan_cores) == 0: mpan_cores = None else: for i in range(len(mpan_cores)): mpan_cores[i] = parse_mpan_core(mpan_cores[i]) else: mpan_cores = None if finish_date < start_date: raise BadRequest("The finish date can't be before the start date.") is_zipped = req_bool("is_zipped") user = g.user threading.Thread( target=content, args=(start_date, finish_date, supply_id, mpan_cores, is_zipped, user), ).start() return chellow_redirect("/downloads", 303)
def do_post(sess): start_date = req_date('start') finish_date = req_date('finish') supply_id = req_int('supply_id') if 'supply_id' in request.values else None if 'mpan_cores' in request.values: mpan_cores_str = req_str('mpan_cores') mpan_cores = mpan_cores_str.splitlines() if len(mpan_cores) == 0: mpan_cores = None else: for i in range(len(mpan_cores)): mpan_cores[i] = parse_mpan_core(mpan_cores[i]) else: mpan_cores = None if finish_date < start_date: raise BadRequest("The finish date can't be before the start date.") is_zipped = req_bool('is_zipped') user = g.user threading.Thread( target=content, args=( start_date, finish_date, supply_id, mpan_cores, is_zipped, user) ).start() return chellow_redirect("/downloads", 303)
def do_get(sess): base_name = [] year = req_int("finish_year") month = req_int("finish_month") months = req_int("months") start_date = utc_datetime(year, month, 1) - relativedelta(months=months - 1) base_name.append('g_monthly_duration') site_id = req_int('site_id') if 'site_id' in request.values else None if 'g_supply_id' in request.values: g_supply_id = req_int('g_supply_id') else: g_supply_id = None if 'compression' in request.values: compression = req_bool('compression') else: compression = True user = g.user threading.Thread(target=content, args=(base_name, site_id, g_supply_id, user, compression, start_date, months)).start() return chellow_redirect("/downloads", 303)
def do_get(sess): base_name = [] if 'scenario_id' in request.values: scenario_id = req_int('scenario_id') scenario_props = None else: year = req_int("finish_year") month = req_int("finish_month") months = req_int("months") start_date = Datetime(year, month, 1) - \ relativedelta(months=months - 1) scenario_props = { 'scenario_start': start_date, 'scenario_duration': months} scenario_id = None base_name.append('monthly_duration') site_id = req_int('site_id') if 'site_id' in request.values else None supply_id = req_int('supply_id') if 'supply_id' in request.values else None if 'compression' in request.values: compression = req_bool('compression') else: compression = True user = g.user threading.Thread( target=content, args=( scenario_props, scenario_id, base_name, site_id, supply_id, user, compression)).start() return chellow_redirect("/downloads", 303)
def do_get(sess): base_name = [] if 'scenario_id' in request.values: scenario_id = req_int('scenario_id') scenario_props = None else: year = req_int("finish_year") month = req_int("finish_month") months = req_int("months") start_date = Datetime(year, month, 1) - \ relativedelta(months=months - 1) scenario_props = { 'scenario_start': start_date, 'scenario_duration': months } scenario_id = None base_name.append('monthly_duration') site_id = req_int('site_id') if 'site_id' in request.values else None supply_id = req_int('supply_id') if 'supply_id' in request.values else None if 'compression' in request.values: compression = req_bool('compression') else: compression = True user = g.user threading.Thread(target=content, args=(scenario_props, scenario_id, base_name, site_id, supply_id, user, compression)).start() return chellow_redirect("/downloads", 303)
def do_get(sess): start_year = req_int("start_year") start_month = req_int("start_month") start_day = req_int("start_day") finish_year = req_int("finish_year") finish_month = req_int("finish_month") finish_day = req_int("finish_day") is_import = req_bool("is_import") supply_id = req_int("supply_id") threading.Thread( target=content, args=( start_year, start_month, start_day, finish_year, finish_month, finish_day, is_import, supply_id, g.user, ), ).start() return chellow_redirect("/downloads", 303)
def do_get(sess): show_ignored = req_bool("show_ignored") report_run = ReportRun.insert( sess, FNAME, g.user, FNAME, {}, ) sess.commit() threading.Thread(target=content, args=(g.user, show_ignored, report_run.id)).start() return chellow_redirect(f"/report_runs/{report_run.id}", 303)
def do_get(sess): start_year = req_int('start_year') start_month = req_int('start_month') start_day = req_int("start_day") finish_year = req_int('finish_year') finish_month = req_int('finish_month') finish_day = req_int('finish_day') is_import = req_bool('is_import') supply_id = req_int('supply_id') threading.Thread( target=content, args=( start_year, start_month, start_day, finish_year, finish_month, finish_day, is_import, supply_id, g.user)).start() return chellow_redirect("/downloads", 303)
def do_get(sess): start_year = req_int('start_year') start_month = req_int('start_month') start_day = req_int("start_day") finish_year = req_int('finish_year') finish_month = req_int('finish_month') finish_day = req_int('finish_day') is_import = req_bool('is_import') supply_id = req_int('supply_id') return send_response( content, args=( start_year, start_month, start_day, finish_year, finish_month, finish_day, is_import, supply_id, sess), file_name='daily_supplier_virtual_bill.csv')
def do_get(sess): finish_year = req_int("finish_year") finish_month = req_int("finish_month") months = req_int("months") site_id = req_int("site_id") if "site_id" in request.values else None if "g_supply_id" in request.values: g_supply_id = req_int("g_supply_id") else: g_supply_id = None if "compression" in request.values: compression = req_bool("compression") else: compression = True user = g.user args = (site_id, g_supply_id, user, compression, finish_year, finish_month, months) threading.Thread(target=content, args=args).start() return chellow_redirect("/downloads", 303)
def do_post(sess): base_name = [] now = utc_datetime_now() if "scenario_id" in request.values: scenario_id = req_int("scenario_id") scenario = Scenario.get_by_id(sess, scenario_id) scenario_props = scenario.props base_name.append(scenario.name) start_year = scenario_props["scenario_start_year"] start_month = scenario_props["scenario_start_month"] start_date_ct = ct_datetime(now.year, now.month, 1) if start_year is None: scenario_props["scenario_start_year"] = start_date_ct.year if start_month is None: scenario_props["scenario_start_month"] = start_date_ct.month else: year = req_int("finish_year") month = req_int("finish_month") months = req_int("months") start_date, _ = next( c_months_c(finish_year=year, finish_month=month, months=months)) by_hh = req_bool("by_hh") scenario_props = { "scenario_start_year": start_date.year, "scenario_start_month": start_date.month, "scenario_duration": months, "by_hh": by_hh, } base_name.append("monthly_duration") try: site_id = req_int("site_id") if "site_id" in request.values else None if "site_codes" in request.values: site_codes = req_str("site_codes").splitlines() # Check sites codes are valid for site_code in site_codes: Site.get_by_code(sess, site_code) else: site_codes = [] if "supply_id" in request.values: supply_id = req_int("supply_id") else: supply_id = None if "compression" in request.values: compression = req_bool("compression") else: compression = True user = g.user args = ( scenario_props, base_name, site_id, supply_id, user, compression, site_codes, now, ) threading.Thread(target=content, args=args).start() return chellow_redirect("/downloads", 303) except BadRequest as e: flash(e.description) now = Datetime.utcnow() month_start = Datetime(now.year, now.month, 1) - relativedelta(months=1) month_finish = Datetime(now.year, now.month, 1) - HH return make_response( render_template( "ods_monthly_duration.html", month_start=month_start, month_finish=month_finish, ), 400, )