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(): context['payments'] = paymentsView.get() context['payment_months'] = paymentsView.getMonths() cdrsView = CDRsView(contract=contract) if cdrsView.get_success(): context['cdrs'] = cdrsView.get() context['cdr_months'] = cdrsView.get_months() (context['page_count'], context['pages']) = (lambda x: (x, xrange(x)))(cdrsView.get_page_count()) #определяем ссылки на другие услуги _service = Service(contract=contract) context['show_internet_link'] = _service.is_internet_activated() context['show_tv_link'] = _service.is_tv_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'] page = req.params()['page'] cdrsView = CDRsView(contract=contract, period_start=period_start, period_end=period_end) if cdrsView.get_success(): return {'success': True, 'cdrs': cdrsView.get(page=page), 'pages': cdrsView.get_page_count(), 'active_page': page} else: return {'success': False, 'title': cdrsView.get_error()['title'], 'message': cdrsView.get_error()['message']}