From dab98a8b5400ab8522b7ffdb5757d85f92df8654 Mon Sep 17 00:00:00 2001 From: bashmak Date: Wed, 31 May 2017 17:36:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20view=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=20=D1=82=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abonapp/views.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/abonapp/views.py b/abonapp/views.py index db135c9..1152242 100644 --- a/abonapp/views.py +++ b/abonapp/views.py @@ -11,7 +11,7 @@ from django.http import HttpResponse from django.contrib import messages from django.utils.translation import ugettext_lazy as _ -from statistics.models import getModel +from statistics.models import StatCache from tariff_app.models import Tariff from agent import NasFailedResult, Transmitter, NasNetworkError from . import forms @@ -33,8 +33,6 @@ def peoples(request, gid): else: peoples_list = peoples_list.filter(group=gid) - StatModel = getModel() - # фильтр dr, field = mydefs.order_helper(request) if field: @@ -44,10 +42,10 @@ def peoples(request, gid): peoples_list = mydefs.pag_mn(request, peoples_list) for abon in peoples_list: if abon.ip_address is not None: - traf = StatModel.objects.traffic_by_ip(abon.ip_address) - if traf[1] is not None: - abon.traf = traf[1] - abon.is_online =traf[0] + try: + abon.stat_cache = StatCache.objects.get(ip=abon.ip_address) + except StatCache.DoesNotExist: + pass except mydefs.LogicError as e: messages.warning(request, e)