Browse Source

Merge branch 'devel' of https://github.com/nerosketch/djing into djing_mon_feauture

devel
bashmak 9 years ago
parent
commit
b7015341df
  1. 6
      abonapp/templates/abonapp/peoples.html
  2. 14
      abonapp/views.py
  3. 9
      searchapp/views.py
  4. 18
      static/js/all.min.js
  5. 1
      statistics/models.py
  6. 2
      templates/all_base.html

6
abonapp/templates/abonapp/peoples.html

@ -50,7 +50,7 @@
{% if order_by == 'house' %}<span class="glyphicon glyphicon-filter"></span>{% endif %} {% if order_by == 'house' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
</th> </th>
<th width="150">{% trans 'Telephone' %}</th> <th width="150">{% trans 'Telephone' %}</th>
<th width="150">{% trans 'Service' %}</th>
<!--<th width="150">{% trans 'Service' %}</th>-->
<th width="50"> <th width="50">
<a href="{% url 'abonapp:people_list' abon_group.pk %}?order_by=ballance&dir={{ dir|default:"down" }}"> <a href="{% url 'abonapp:people_list' abon_group.pk %}?order_by=ballance&dir={{ dir|default:"down" }}">
{% trans 'Ballance' %} {% trans 'Ballance' %}
@ -83,7 +83,7 @@
<td>{{ human.street|default:_('Not assigned') }}</td> <td>{{ human.street|default:_('Not assigned') }}</td>
<td>{{ human.house|default:_('Not assigned') }}</td> <td>{{ human.house|default:_('Not assigned') }}</td>
<td><a href="tel:{{ human.telephone }}">{{ human.telephone }}</a></td> <td><a href="tel:{{ human.telephone }}">{{ human.telephone }}</a></td>
<td>
<!--<td>
{ % if human.active_tariff %} { % if human.active_tariff %}
{ % if perms.tariff_app.change_tariff %} { % if perms.tariff_app.change_tariff %}
<a href="{ % url 'tarifs:edit' human.active_tariff.pk %}">{ { human.active_tariff.title }}</a> <a href="{ % url 'tarifs:edit' human.active_tariff.pk %}">{ { human.active_tariff.title }}</a>
@ -92,7 +92,7 @@
{ % endif %} { % endif %}
{ % else %}&mdash;&mdash;&mdash; { % else %}&mdash;&mdash;&mdash;
{ % endif %} { % endif %}
</td>
</td>-->
<td>{{ human.ballance }}</td> <td>{{ human.ballance }}</td>
<td> <td>
{% if perms.abonapp.delete_abon %} {% if perms.abonapp.delete_abon %}

14
abonapp/views.py

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from json import dumps from json import dumps
from django.contrib.gis.shortcuts import render_to_text from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied, MultipleObjectsReturned
from django.core.exceptions import PermissionDenied
from django.db import IntegrityError, ProgrammingError from django.db import IntegrityError, ProgrammingError
from django.db.models import Count from django.db.models import Count
from django.shortcuts import render, redirect, get_object_or_404, resolve_url from django.shortcuts import render, redirect, get_object_or_404, resolve_url
@ -25,10 +25,11 @@ from datetime import datetime
@mydefs.only_admins @mydefs.only_admins
def peoples(request, gid): def peoples(request, gid):
street_id = mydefs.safe_int(request.GET.get('street')) street_id = mydefs.safe_int(request.GET.get('street'))
peoples_list = models.Abon.objects.select_related('group', 'street')
if street_id > 0: if street_id > 0:
peoples_list = models.Abon.objects.filter(group=gid, street=street_id)
peoples_list = peoples_list.filter(group=gid, street=street_id)
else: else:
peoples_list = models.Abon.objects.filter(group=gid)
peoples_list = peoples_list.filter(group=gid)
StatModel = getModel() StatModel = getModel()
@ -725,11 +726,10 @@ def charts(request, gid, uid):
if abon.ip_address is None: if abon.ip_address is None:
charts_data = None charts_data = None
else: else:
charts_data = StatElem.objects.filter(ip=abon.ip_address.ip)
oct_limit = StatElem.percentile([cd.octets for cd in charts_data], 0.01)
charts_data = StatElem.objects.filter(ip=abon.ip_address)
#oct_limit = StatElem.percentile([cd.octets for cd in charts_data], 0.05)
# ниже возвращаем пары значений трафика который переведён в mByte, и unix timestamp # ниже возвращаем пары значений трафика который переведён в mByte, и unix timestamp
charts_data = ["{x:%d,y:%.4f}" % (cd.cur_time.timestamp(), byte_to_mbit(cd.octets)) for cd in charts_data if
cd.octets < oct_limit]
charts_data = ["{x:%d,y:%.4f}" % (cd.cur_time.timestamp(), byte_to_mbit(cd.octets)) for cd in charts_data]
except models.Abon.DoesNotExist: except models.Abon.DoesNotExist:
messages.error(request, _('Abon does not exist')) messages.error(request, _('Abon does not exist'))

9
searchapp/views.py

@ -3,6 +3,7 @@ from django.db.models import Q
from django.shortcuts import render from django.shortcuts import render
from django.utils.html import escape from django.utils.html import escape
from abonapp.models import Abon from abonapp.models import Abon
from mydefs import ip_addr_regex
def replace_without_case(orig, old, new): def replace_without_case(orig, old, new):
@ -13,8 +14,12 @@ def home(request):
s = request.GET.get('s') s = request.GET.get('s')
if s: if s:
query = Q(fio__icontains=s) | Q(username__icontains=s) | Q(telephone__icontains=s) | Q(ip_address=s)
abons = Abon.objects.filter(query)
if bool(re.match(ip_addr_regex, s)):
abons = Abon.objects.filter(ip_address=s)
else:
abons = Abon.objects.filter(
Q(fio__icontains=s) | Q(username__icontains=s) | Q(telephone__icontains=s)
)
else: else:
abons = [] abons = []

18
static/js/all.min.js
File diff suppressed because it is too large
View File

1
statistics/models.py

@ -13,7 +13,6 @@ class StatManager(models.Manager):
traf = self.order_by('-cur_time').filter(ip=ip, octets__gt=524288)[0] traf = self.order_by('-cur_time').filter(ip=ip, octets__gt=524288)[0]
now = datetime.now() now = datetime.now()
if traf.cur_time < now - timedelta(minutes=55): if traf.cur_time < now - timedelta(minutes=55):
# значит трафа небыло больше 5 минут
return False, traf return False, traf
else: else:
return True, traf return True, traf

2
templates/all_base.html

@ -8,6 +8,8 @@
<link rel="stylesheet" href="/static/css/all.min.css"> <link rel="stylesheet" href="/static/css/all.min.css">
<link rel="stylesheet" href="/static/css/custom.css"> <link rel="stylesheet" href="/static/css/custom.css">
<script src="/static/js/all.min.js"></script> <script src="/static/js/all.min.js"></script>
<script src="/static/js/datetime_with_moment.min.js"></script>
<script src="/static/js/Chart.min.js"></script>
<script src="/static/js/my.js"></script> <script src="/static/js/my.js"></script>
<link rel="shortcut icon" href="/static/img/favicon_m.ico"> <link rel="shortcut icon" href="/static/img/favicon_m.ico">
<meta name="author" content="Дмитрий Новиков"> <meta name="author" content="Дмитрий Новиков">

Loading…
Cancel
Save