Commits

Owen Nelson committed 7085ee4

Fixes: #2, adds support for gt, gte, lt, lte query types.

Comments (0)

Files changed (9)

 include LICENSE
 include README.rst
-
+prune testsite
 Changelog
 ---------
 
+0.1.6
+    Added support for ``gt``, ``gte``, ``lt``, and ``lte`` lookups.
 0.1.5
-    Added south
+    Added south support.
 
 0.1.4
     IPy.IP instance raises exception when compared to a non-IP instance. This

ipyfield/__init__.py

-__version__ = '0.1.4'
+__version__ = '0.1.6'
 

ipyfield/models.py

             if isinstance(value, str):
                 value = IP(value)
             return [self.get_prep_value(v) for v in value]
-        elif lookup_type == 'exact':
+        elif lookup_type in ['exact', 'lt', 'lte', 'gt', 'gte']:
             return self.get_prep_value(value)
         else:
             raise TypeError('Lookup type %r not supported.' % lookup_type)

ipyfield/tests.py

 
 class IPySubclassTests(TestCase):
     def test_ipyfield_can_compare_to_non_IP(self):
-        self.assertNotEqual(IP('::1'), 'foo')
-        self.assertNotEqual(IP('::1'), 22)
+        self.assertNotEqual(IP('::1').strNormal(), 'foo')
+        self.assertNotEqual(IP('::1').int(), 22)
 
     def test_IPy_cant_compare_to_non_IP(self):
         with self.assertRaises(AttributeError):
             # it's possible people will forget this is not a char/text field.
             DummyModel.objects.filter(field__startswith='127.0.0')
 
-        with self.assertRaises(TypeError):
-            # greater/less than should be rewritten as range queries.
-            DummyModel.objects.filter(field__gt=1000)
+        
+        DummyModel.objects.filter(field__gt=1000)
+        DummyModel.objects.filter(field__gte=1000)
+        DummyModel.objects.filter(field__lt=1000)
+        DummyModel.objects.filter(field__lte=1000)
 
         # all valid, but won't return anything....
         DummyModel.objects.filter(field=1000)
     description="IPy.IP instances with BigInt storage for django models",
     long_description=open('README.rst').read(),
     keywords="ip, models, django",
-    packages=find_packages(),
-    setup_requires=("setuptools"),
+    packages=["ipyfield"],
+    setup_requires=["setuptools"],
     install_requires=("setuptools", "IPy", "django",),
     classifiers=(
         "Development Status :: 2 - Pre-Alpha",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
         "Topic :: Internet :: WWW/HTTP :: WSGI",
-        "Topic :: Software Development :: Libraries :: "
-                              "Application Frameworks",
+        "Topic :: Software Development :: Libraries :: Application Frameworks",
         "Topic :: Software Development :: Libraries :: Python Modules",),
 )
 

testsite/__init__.py

+__author__ = 'owen'

testsite/manage.py

+#!/usr/bin/env python
+import sys
+import os
+from django.core.management import execute_manager
+import imp
+
+_here = os.path.abspath(os.path.dirname(__file__))
+_root = os.path.abspath(os.path.join(_here, '..'))
+sys.path.insert(0, _here)
+sys.path.insert(0, _root)
+
+try:
+    imp.find_module('settings') # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
+    sys.exit(1)
+
+import settings
+
+if __name__ == "__main__":
+    execute_manager(settings)

testsite/settings.py

+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+    }
+}
+
+INSTALLED_APPS = ('ipyfield',)