Browse Source

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

devel
bashmak 9 years ago
parent
commit
ef483d801a
  1. 4
      abonapp/views.py
  2. 3
      devapp/dev_types.py
  3. 2
      devapp/forms.py
  4. 2
      mapapp/templates/maps/map_tooltip.html
  5. 23
      statistics/models.py

4
abonapp/views.py

@ -22,6 +22,7 @@ from devapp.models import Device, Port as DevPort
from datetime import datetime, date
from taskapp.models import Task
from dialing_app.models import AsteriskCDR
from statistics.models import getModel, get_dates
@login_required
@ -678,7 +679,6 @@ def clear_dev(request, gid, uid):
@login_required
@mydefs.only_admins
def charts(request, gid, uid):
from statistics.models import getModel
high = 100
wandate = request.GET.get('wantdate')
@ -725,7 +725,7 @@ def charts(request, gid, uid):
'abon': abon,
'charts_data': ',\n'.join(charts_data) if charts_data is not None else None,
'high': high,
'dates': StatElem.objects.get_dates()
'dates': get_dates()
})

3
devapp/dev_types.py

@ -62,9 +62,10 @@ class DLinkDevice(DevBase, SNMPBaseWorker):
macs = self.get_list(oids['get_ports']['macs'])
speeds = self.get_list(oids['get_ports']['speeds'])
res = []
ln = len(macs)
ln = len(speeds)
for n in range(ln):
status = True if int(stats[n]) == 1 else False
print(len(nams), len(speeds), len(macs))
res.append(DLinkPort(
n+1,
nams[n] if len(nams) > 0 else _('does not fetch the name'),

2
devapp/forms.py

@ -27,7 +27,7 @@ class DeviceForm(forms.ModelForm):
'placeholder': '192.168.0.100',
'class': 'form-control'
}),
'comment': forms.Textarea(attrs={
'comment': forms.TextInput(attrs={
'required': True,
'class': 'form-control'
}),

2
mapapp/templates/maps/map_tooltip.html

@ -1,7 +1,7 @@
<h4>{{ dot.title }}</h4>
<div class="list-group">
{% for dev in devs %}
<a class="list-group-item" href="{% url 'devapp:view' dev.id %}" target="_blank">
<a class="list-group-item" href="{% url 'devapp:view' dev.user_group.pk dev.pk %}" target="_blank">
{{ dev.comment }}
</a>
{% empty %}

23
statistics/models.py

@ -7,6 +7,12 @@ from mydefs import MyGenericIPAddressField
from .fields import UnixDateTimeField
def get_dates():
tables = connection.introspection.table_names()
tables = [t.replace('flowstat_', '') for t in tables if t.startswith('flowstat_')]
return [datetime.strptime(t, '%d%m%Y').date() for t in tables]
class StatManager(models.Manager):
def chart(self, ip_addr, count_of_parts=12, want_date=date.today()):
@ -41,11 +47,6 @@ class StatManager(models.Manager):
else:
return
def get_dates(self):
tables = connection.introspection.table_names()
tables = [t.replace('flowstat_', '') for t in tables if t.startswith('flowstat_')]
return [datetime.strptime(t, '%d%m%Y').date() for t in tables]
class StatElem(models.Model):
cur_time = UnixDateTimeField(primary_key=True)
@ -55,11 +56,19 @@ class StatElem(models.Model):
objects = StatManager()
# ReadOnly
def save(self, *args, **kwargs):
return
pass
# ReadOnly
def delete(self, *args, **kwargs):
return
pass
def delete_month(self):
cursor = connection.cursor()
table_name = self._meta.db_table
sql = "DROP TABLE %s;" % table_name
cursor.execute(sql)
@staticmethod
def percentile(N, percent, key=lambda x:x):

Loading…
Cancel
Save