fix block edit

issues:
1. IPAddressField is deprecated. We can change this without consequence
because the underlying field type is not changed.
2. New admin was not wired up.
3. There was a admin bug when one end of the block is zero.
pull/1/head
eric 2016-11-09 15:24:11 -05:00
parent a49be9e61f
commit b252d0b7df
2 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,7 @@ from selectable.base import ModelLookup
from selectable.registry import registry
from django import forms
from django.contrib.admin import ModelAdmin
from django.contrib.admin import ModelAdmin, site
from django.contrib.auth.models import User, Group
class UserLookup(ModelLookup):
@ -47,3 +47,8 @@ class CardPatternAdmin(ModelAdmin):
class EmailPatternAdmin(ModelAdmin):
list_display = ('library', 'pattern', )
search_fields = ('library__name',)
site.register(models.Library, LibraryAdmin)
site.register(models.Block, BlockAdmin)
site.register(models.CardPattern, CardPatternAdmin)
site.register(models.EmailPattern, EmailPatternAdmin)

View File

@ -140,7 +140,7 @@ class IP(object):
if not isinstance(other, IP):
other = IP(other)
if self.int and other.int:
if self.int is not None and other.int is not None:
return self.int.__cmp__(other.int)
raise ValueError('Invalid arguments')
@ -177,7 +177,7 @@ class IPAddressFormField(BaseIPAddressField):
raise ValidationError(self.default_error_messages['invalid'],
code='invalid')
class IPAddressModelField(models.IPAddressField):
class IPAddressModelField(models.GenericIPAddressField):
__metaclass__ = models.SubfieldBase
empty_strings_allowed = False
@ -205,10 +205,10 @@ class IPAddressModelField(models.IPAddressField):
def formfield(self, **kwargs):
defaults = {'form_class': IPAddressFormField}
defaults.update(kwargs)
return super(models.IPAddressField, self).formfield(**defaults)
return super(models.GenericIPAddressField, self).formfield(**defaults)
def deconstruct(self):
name, path, args, kwargs = super(models.IPAddressField, self).deconstruct()
name, path, args, kwargs = super(models.GenericIPAddressField, self).deconstruct()
return name, path, args, kwargs
class Block(models.Model):