def worker(req): context = {} contract = req.params()['service_contract'] service = req.params()['service'] balancesView = BalancesView(contract=contract) if balancesView.getSuccess(): balances = balancesView.get() periods = balancesView.getPeriods() context['balances'] = balances context['periods'] = periods paymentsView = PaymentsView(contract=contract) if paymentsView.getSuccess(): payments = paymentsView.get() payment_months = paymentsView.getMonths() context['payments'] = payments context['payment_months'] = payment_months #определяем ссылки на другие услуги _service = Service(contract=contract) context['show_internet_link'] = _service.is_internet_activated() context['show_phone_link'] = _service.is_phone_activated() #определяем остальные переменные контекста context['fio'] = contract.fio context['contract'] = contract.contract context['change_passwd'] = False return {'success': True, 'template': '%s.html' % service, 'template_context': context}
def worker(req): contract = req.params()["service_contract"] period_start = req.params()["period_start"] period_end = req.params()["period_end"] balancesView = BalancesView(contract=contract, period_start=period_start, period_end=period_end) if balancesView.getSuccess(): return {"success": True, "balances": balancesView.get()} else: return { "success": False, "title": balancesView.getError()["title"], "message": balancesView.getError()["message"], }
def worker(req): context = {} contract = req.params()['service_contract'] service = req.params()['service'] balancesView = BalancesView(contract=contract) #баланс if balancesView.getSuccess(): balances = balancesView.get() periods = balancesView.getPeriods() context['balances'] = balances context['periods'] = periods paymentsView = PaymentsView(contract=contract) #платежи if paymentsView.getSuccess(): payments = paymentsView.get() payment_months = paymentsView.getMonths() context['payments'] = payments context['payment_months'] = payment_months #определяем текущий тариф tariff = Tariff(contract=contract) context['personal_tariff'] = tariff.is_personal() if not tariff.is_personal(): context['current_internet_tariff'] = tariff.getCurrentTarPlan().tarplan #запланирован ли переход на новый тариф if tariff.isTarPlanChanging(): contractTarPlan_planned = tariff.getOpenTarPlan().tarplan contractTarPlan_planned.day_start = tariff.getOpenTarPlan().start_date.strftime("%Y-%m-%d") else: contractTarPlan_planned = None context['planned_internet_tariff'] = contractTarPlan_planned #получаем список тарифов и сортируем их по цене tarplans = TarPlan.objects.filter(id__in=settings.TARPLAN[service].keys()) tarplans = sorted(tarplans, key=lambda tarplan: tarplan.price) context['internet_tariffs'] = tarplans #проверяем доступно ли данному абоненту понижение лимита limit_down = LimitDown(contract=contract) if limit_down.can_make(): context['can_make_promise_pay'] = True else: context['can_make_promise_pay'] = False context['promise_pay_disabled_title'] = limit_down.get_trust_pay_not_available_reason()['title'] context['promise_pay_disabled_message'] = limit_down.get_trust_pay_not_available_reason()['message'] #получаем даты перехода на новые ТП context['start_dates'] = StartDate.get() #определяем ссылки на другие услуги _service = Service(contract=contract) context['show_tv_link'] = _service.is_tv_activated() context['show_phone_link'] = _service.is_phone_activated() #определяем остальные переменные контекста context['fio'] = contract.fio context['contract'] = contract.contract context['change_passwd'] = False return {'success': True, 'template': '%s.html' % service, 'template_context': context}