Browse Source

fix bugs

devel
www-data 8 years ago
parent
commit
67bafb9f95
  1. 10
      abonapp/views.py
  2. 2
      djing/global_base_views.py
  3. 2
      ip_pool/models.py
  4. 3
      taskapp/forms.py
  5. 4
      taskapp/models.py

10
abonapp/views.py

@ -14,6 +14,7 @@ from django.utils.translation import gettext_lazy as _
from django.utils.decorators import method_decorator
from django.views.generic import ListView, UpdateView, CreateView, DeleteView
from django.conf import settings
from djing.lib import DuplicateEntry
from jsonview.decorators import json_view
from agent.commands.dhcp import dhcp_commit, dhcp_expiry, dhcp_release
@ -55,10 +56,7 @@ class PeoplesListView(OrderedFilteredList):
for abon in peoples_list.iterator():
ips = tuple(p.ip for p in abon.ip_addresses.filter(is_active=True))
if len(ips) > 0:
try:
abon.stat_cache = StatCache.objects.get(ip__in=ips)
except StatCache.DoesNotExist:
pass
abon.stat_cache = StatCache.objects.filter(ip__in=ips).first()
except lib.LogicError as e:
messages.warning(self.request, e)
ordering = self.get_ordering()
@ -1247,3 +1245,7 @@ class DhcpLever(SecureApiView):
except lib.LogicError as e:
print('LogicError', e)
return str(e)
except DuplicateEntry as e:
print('Duplicate:', e)
return str(e)

2
djing/global_base_views.py

@ -57,7 +57,7 @@ class AllowedSubnetMixin(object):
return super(AllowedSubnetMixin, self).dispatch(request, *args, **kwargs)
try:
for subnet in api_auth_subnet:
if ip in ip_network(subnet):
if ip in ip_network(subnet, strict=False):
return super(AllowedSubnetMixin, self).dispatch(request, *args, **kwargs)
except TypeError:
if ip in ip_network(str(api_auth_subnet)):

2
ip_pool/models.py

@ -150,7 +150,7 @@ class IpLeaseManager(models.Manager):
)
except IntegrityError as e:
if 'Duplicate entry' in str(e):
raise DuplicateEntry(_('Ip has already taken'))
raise DuplicateEntry("%s: %s" %(_('Ip has already taken'), str(e)))
raise e
def expired(self):

3
taskapp/forms.py

@ -48,7 +48,8 @@ class ExtraCommentForm(forms.ModelForm):
comment = super(ExtraCommentForm, self).save(commit=False)
comment.author = author
comment.task = task
return comment.save()
comment.save()
return comment
def save(self, commit=True):
raise Exception('You must use ExtraCommentForm.make_save() method')

4
taskapp/models.py

@ -3,6 +3,7 @@ from datetime import timedelta
import os
from django.db import models
from django.conf import settings
from django.shortcuts import resolve_url
from django.utils import timezone
from django.utils.translation import ugettext as _
from abonapp.models import Abon
@ -125,6 +126,9 @@ class ExtraComment(models.Model):
def __str__(self):
return self.text
def get_absolute_url(self):
return resolve_url('taskapp:edit', self.task.pk)
class Meta:
db_table = 'extra_comments'
permissions = (

Loading…
Cancel
Save