Commits

Mark Lavin  committed fb38256

Remove support for search_field. Remove legacy tests.

  • Participants
  • Parent commits f72d7ba

Comments (0)

Files changed (5)

File docs/releases.rst

 - Easier passing of query parameters. See the :ref:`Additional Parameters <additional-parameters>` section
 
 
+Backwards Incompatible Changes
+________________________________
+
+- Support for ``ModelLookup.search_field`` string has been removed. You should use the ``ModelLookup.search_fields`` tuple instead.
+
+
 v0.3.0 (Released 2012-02-15)
 --------------------------------------
 

File selectable/base.py

 class ModelLookup(LookupBase):
     model = None
     filters = {}
-    search_field = ''
     search_fields = ()
 
-    def __init__(self):
-        super(ModelLookup, self).__init__()
-        if self.search_field and not self.search_fields:
-            self.search_fields = (self.search_field, )
-
     def get_query(self, request, term):
         qs = self.get_queryset()
         if term:

File selectable/registry.py

     def validate(self, lookup):
         if not issubclass(lookup, LookupBase):
             raise LookupInvalid(u'Registered lookups must inherit from the LookupBase class')
-        if issubclass(lookup, ModelLookup) and getattr(lookup, 'search_field'):
+        if issubclass(lookup, ModelLookup) and getattr(lookup, 'search_field', None):
             import warnings
             warnings.warn(
                 u"ModelLookup.search_field is deprecated; Use ModelLookup.search_fields instead.", 

File selectable/tests/__init__.py

 
 class ThingLookup(ModelLookup):
     model = Thing
-    search_field = 'name__icontains'
+    search_fields = ('name__icontains', )
 
 
 registry.register(ThingLookup)

File selectable/tests/base.py

 __all__ = (
     'ModelLookupTestCase',
     'MultiFieldLookupTestCase',
-    'LegacyModelLookupTestCase',
 )
 
 
         qs = lookup.get_query(request=None, term='other')
         self.assertTrue(thing.pk not in qs.values_list('id', flat=True))
         self.assertTrue(other_thing.pk in qs.values_list('id', flat=True))
-
-
-class LegacyModelLookup(ModelLookup):
-    model = Thing
-    search_field = 'name__icontains'
-
-
-class LegacyModelLookupTestCase(ModelLookupTestCase):
-    lookup_cls = LegacyModelLookup
-
-    def test_get_name(self):
-        name = self.__class__.lookup_cls.name()
-        self.assertEqual(name, 'tests-legacymodellookup')
-
-    def test_get_url(self):
-        url = self.__class__.lookup_cls.url()
-        test_url = reverse('selectable-lookup', args=['tests-legacymodellookup'])
-        self.assertEqual(url, test_url)