# Path: hyperadmin/filters.py
# class BaseChoicesFilter(BaseFilter):
#     def get_links(self, **link_kwargs):
#         links = list()
#         for choice in self.choices():
#             kwargs = dict(link_kwargs)
#             classes = kwargs.get('classes', [])
#             kwargs['group'] = self.title
#             kwargs['classes'] = classes
#             if choice.get('selected', False):
#                 classes.append('selected')
#             #CONSIDER prompt may want to include group if not supported
#             kwargs['prompt'] = force_unicode(choice['display'])
#             kwargs['url'] = u'./' + choice['query_string']
#             links.append(self.make_link(**kwargs))
#         return links
#     
#     def choices(self):
#         return []
# 
# class BaseFilter(object):
#     title = None  # Human-readable title to appear in the right sidebar.
#     
#     def __init__(self, index):
#         self.index = index
#         self.resource = index.resource
#         if self.title is None:
#             raise ImproperlyConfigured(
#                 "The filter '%s' does not specify "
#                 "a 'title'." % self.__class__.__name__)
#     
#     @property
#     def state(self):
#         return self.resource.state
#     
#     def make_link(self, **kwargs):
#         return self.index.get_link(**kwargs)
#     
#     def populate_state(self):
#         pass
#     
#     def get_links(self, **link_kwargs):
#         """
#         Returns links representing the filterable actions.
#         """
#         return []
#     
#     def filter_index(self, active_index):
#         """
#         Returns the filtered queryset.
#         """
#         raise NotImplementedError
#     
#     def expected_parameters(self):
#         """
#         Returns the list of parameter names that are expected from the
#         request's query string and that will be used by this filter.
#         """
#         raise NotImplementedError
#     
#     def is_active(self):
#         return False
#     
#     def values(self):
#         vals = list()
#         filter_params = self.state.params
#         for param in self.expected_parameters():
#             vals.append(filter_params.get(param, None))
#         return vals


import datetime
import operator
    import pytz as timezone
from django.db import models
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
    from django.utils import timezone
from django.contrib.admin.util import (get_model_from_relation,
    reverse_field_path, get_limit_choices_to_from_path, )
    from django.contrib.admin.util import lookup_needs_distinct, prepare_lookup_value
    from hyperadmin.resources.models.util import lookup_needs_distinct, prepare_lookup_value
from hyperadmin.filters import BaseChoicesFilter, BaseFilter
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
            self.lookup_title = field.verbose_name
        else:
            self.lookup_title = other_model._meta.verbose_name
        self.title = self.lookup_title

    def has_output(self):
        if (isinstance(self.field, models.related.RelatedObject)
                and self.field.field.null or hasattr(self.field, 'rel')
                    and self.field.null):
            extra = 1
        else:
            extra = 0
        return len(self.lookup_choices) + extra > 1
    
    def is_active(self):
        if not self.has_output():
            return False
        return super(RelatedFieldFilter, self).is_active()

    def expected_parameters(self):
        return [self.lookup_kwarg, self.lookup_kwarg_isnull]
    
    def choices(self):
        lookup_val, lookup_val_isnull = self.values()
        yield {
            'selected': lookup_val is None and not lookup_val_isnull,
            'query_string': self.state.get_query_string({},
                [self.lookup_kwarg, self.lookup_kwarg_isnull]),
            'display': _('All'),
        }

# Path: hyperadmin/filters.py
# class BaseChoicesFilter(BaseFilter):
#     def get_links(self, **link_kwargs):
#         links = list()
#         for choice in self.choices():
#             kwargs = dict(link_kwargs)
#             classes = kwargs.get('classes', [])
#             kwargs['group'] = self.title
#             kwargs['classes'] = classes
#             if choice.get('selected', False):
#                 classes.append('selected')
#             #CONSIDER prompt may want to include group if not supported
#             kwargs['prompt'] = force_unicode(choice['display'])
#             kwargs['url'] = u'./' + choice['query_string']
#             links.append(self.make_link(**kwargs))
#         return links
#     
#     def choices(self):
#         return []
# 
# class BaseFilter(object):
#     title = None  # Human-readable title to appear in the right sidebar.
#     
#     def __init__(self, index):
#         self.index = index
#         self.resource = index.resource
#         if self.title is None:
#             raise ImproperlyConfigured(
#                 "The filter '%s' does not specify "
#                 "a 'title'." % self.__class__.__name__)
#     
#     @property
#     def state(self):
#         return self.resource.state
#     
#     def make_link(self, **kwargs):
#         return self.index.get_link(**kwargs)
#     
#     def populate_state(self):
#         pass
#     
#     def get_links(self, **link_kwargs):
#         """
#         Returns links representing the filterable actions.
#         """
#         return []
#     
#     def filter_index(self, active_index):
#         """
#         Returns the filtered queryset.
#         """
#         raise NotImplementedError
#     
#     def expected_parameters(self):
#         """
#         Returns the list of parameter names that are expected from the
#         request's query string and that will be used by this filter.
#         """
#         raise NotImplementedError
#     
#     def is_active(self):
#         return False
#     
#     def values(self):
#         vals = list()
#         filter_params = self.state.params
#         for param in self.expected_parameters():
#             vals.append(filter_params.get(param, None))
#         return vals


# Path: hyperadmin/resources/models/filters.py
import datetime
import operator
    import pytz as timezone
from django.db import models
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
    from django.utils import timezone
from django.contrib.admin.util import (get_model_from_relation,
    reverse_field_path, get_limit_choices_to_from_path, )
    from django.contrib.admin.util import lookup_needs_distinct, prepare_lookup_value
    from hyperadmin.resources.models.util import lookup_needs_distinct, prepare_lookup_value
from hyperadmin.filters import BaseChoicesFilter, BaseFilter
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE

            self.lookup_title = field.verbose_name
        else:
            self.lookup_title = other_model._meta.verbose_name
        self.title = self.lookup_title

    def has_output(self):
        if (isinstance(self.field, models.related.RelatedObject)
                and self.field.field.null or hasattr(self.field, 'rel')
                    and self.field.null):
            extra = 1
        else:
            extra = 0
        return len(self.lookup_choices) + extra > 1
    
    def is_active(self):
        if not self.has_output():
            return False
        return super(RelatedFieldFilter, self).is_active()

    def expected_parameters(self):
        return [self.lookup_kwarg, self.lookup_kwarg_isnull]
    
    def choices(self):
        lookup_val, lookup_val_isnull = self.values()
        yield {
            'selected': lookup_val is None and not lookup_val_isnull,
            'query_string': self.state.get_query_string({},
                [self.lookup_kwarg, self.lookup_kwarg_isnull]),
            'display': _('All'),
        }

        for pk_val, val in self.lookup_choices: