# Path: aninstance_framework/search_forms.py
# class AninstanceSearchForm(ModelSearchForm):
#     # override elements of default SearchForm to add styling classes to fields
# 
#     def __init__(self, *args, **kwargs):
#         super(AninstanceSearchForm, self).__init__(*args, **kwargs)
# 
#         # Only used if inheriting from ModelSearchForm (not SearchForm)
#         self.fields['models'] = forms.MultipleChoiceField(choices=model_choices(),
#                                                           required=False,
#                                                           label=_('Search in'),
#                                                           widget=forms.CheckboxSelectMultiple(attrs={
#                                                               'class': 'form-control'
#                                                           }),
#                                                           )
# 
#     q = forms.CharField(required=False,
#                         label=_('Search for'),
#                         widget=forms.TextInput(attrs={'type': 'search',
#                                                       'class': 'form-control',
#                                                       'size': '20',
#                                                       }))
# 
#     def get_models(self):
#         return self.models
# 
#     def search(self):
#         # First, store the SearchQuerySet received from other processing.
#         sqs = super(AninstanceSearchForm, self).search()
#         if not self.is_valid():
#             return self.no_query_found()
#         return sqs
# 
# Path: aninstance_framework/helpers.py
# def set_session_data(request):
# def get_page(request):
# def get_client_ip(request):
# def utc_to_local(value, client_timezone, autoescape=True):
# def format_utc_str_for_template(value, autoescape=True):
# def local_to_utc(value):
# def is_num(value):
# def update_url_param(request, param_name):
# def remove_url_param(request, param):
# def strip_url_params(request):
# def sanitize_url_param(param):
# def sanitize_post_data(data):
# def format_data_for_display(data, file_formatting, media_type):
# def phrase_check(string):
# 
# Path: aninstance_framework/auth.py
# def auth(self):
#     return self.test_func()


from django.conf import settings
from django.contrib.auth.mixins import AccessMixin
from django.shortcuts import redirect
from haystack.generic_views import SearchView
from django.utils.translation import ugettext_lazy as _
from .search_forms import AninstanceSearchForm
from aninstance_framework import helpers, auth

        - Certainly don't forget to query request.GET for 'q' (as above) and redirect to the search URL if present, as
          the request to the view was therefore coming in after the search button had been clicked.

        - Don't forget to set the results_url in AninstanceSearchView "model_search_conf" method (below)

        - Update index with: ./manage.py rebuild_index
    Auth:
        Auth in the same way as AninstanceGenericView & it's child CBVs.
        AccessMixin included here to provide self.handle_no_permission() method
        for use when auth fails. AninstanceGenericView does auth by overriding dispatch method,
        but here it's done in get(), to keep it simple.
    """

    RESULTS_HEADING = 'Matching search results'

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.models = []
        self.result_url = None
        self.auth_required = False  # false as default

    def get_queryset(self):
        queryset = super(AninstanceSearchView, self).get_queryset()
        ## further filter queryset based on some set of criteria
        return queryset

    def get_context_data(self, *args, **kwargs):
        context = super(AninstanceSearchView, self).get_context_data(**kwargs)
        context.update({'panel_heading': _('Search'),

# Path: aninstance_framework/search_forms.py
# class AninstanceSearchForm(ModelSearchForm):
#     # override elements of default SearchForm to add styling classes to fields
# 
#     def __init__(self, *args, **kwargs):
#         super(AninstanceSearchForm, self).__init__(*args, **kwargs)
# 
#         # Only used if inheriting from ModelSearchForm (not SearchForm)
#         self.fields['models'] = forms.MultipleChoiceField(choices=model_choices(),
#                                                           required=False,
#                                                           label=_('Search in'),
#                                                           widget=forms.CheckboxSelectMultiple(attrs={
#                                                               'class': 'form-control'
#                                                           }),
#                                                           )
# 
#     q = forms.CharField(required=False,
#                         label=_('Search for'),
#                         widget=forms.TextInput(attrs={'type': 'search',
#                                                       'class': 'form-control',
#                                                       'size': '20',
#                                                       }))
# 
#     def get_models(self):
#         return self.models
# 
#     def search(self):
#         # First, store the SearchQuerySet received from other processing.
#         sqs = super(AninstanceSearchForm, self).search()
#         if not self.is_valid():
#             return self.no_query_found()
#         return sqs
# 
# Path: aninstance_framework/helpers.py
# def set_session_data(request):
# def get_page(request):
# def get_client_ip(request):
# def utc_to_local(value, client_timezone, autoescape=True):
# def format_utc_str_for_template(value, autoescape=True):
# def local_to_utc(value):
# def is_num(value):
# def update_url_param(request, param_name):
# def remove_url_param(request, param):
# def strip_url_params(request):
# def sanitize_url_param(param):
# def sanitize_post_data(data):
# def format_data_for_display(data, file_formatting, media_type):
# def phrase_check(string):
# 
# Path: aninstance_framework/auth.py
# def auth(self):
#     return self.test_func()


# Path: aninstance_framework/search.py
from django.conf import settings
from django.contrib.auth.mixins import AccessMixin
from django.shortcuts import redirect
from haystack.generic_views import SearchView
from django.utils.translation import ugettext_lazy as _
from .search_forms import AninstanceSearchForm
from aninstance_framework import helpers, auth


        - Certainly don't forget to query request.GET for 'q' (as above) and redirect to the search URL if present, as
          the request to the view was therefore coming in after the search button had been clicked.

        - Don't forget to set the results_url in AninstanceSearchView "model_search_conf" method (below)

        - Update index with: ./manage.py rebuild_index
    Auth:
        Auth in the same way as AninstanceGenericView & it's child CBVs.
        AccessMixin included here to provide self.handle_no_permission() method
        for use when auth fails. AninstanceGenericView does auth by overriding dispatch method,
        but here it's done in get(), to keep it simple.
    """

    RESULTS_HEADING = 'Matching search results'

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.models = []
        self.result_url = None
        self.auth_required = False  # false as default

    def get_queryset(self):
        queryset = super(AninstanceSearchView, self).get_queryset()
        ## further filter queryset based on some set of criteria
        return queryset

    def get_context_data(self, *args, **kwargs):
        context = super(AninstanceSearchView, self).get_context_data(**kwargs)
        context.update({'panel_heading': _('Search'),

                        'form': AninstanceSearchForm({'models': self.models}),