# 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
    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}),
                        'result_url': self.result_url,
                        'results_heading': self.RESULTS_HEADING})
        # return the context
        return context

    def get(self, request, *args, **kwargs):
        """
        Handles GET requests and instantiates a blank version of the form.
        """
        # define specifics for model searches, including authorization if necessary
        # return redirect('search_view')
        if self.model_search_conf(request):  # if authenticated or authentication not required
            form_class = self.get_form_class()
            form = self.get_form(form_class)
            # update any session data (as this view not subclassing AninstanceGenericView, like normal)

# 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

    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}),
                        'result_url': self.result_url,
                        'results_heading': self.RESULTS_HEADING})
        # return the context
        return context

    def get(self, request, *args, **kwargs):
        """
        Handles GET requests and instantiates a blank version of the form.
        """
        # define specifics for model searches, including authorization if necessary
        # return redirect('search_view')
        if self.model_search_conf(request):  # if authenticated or authentication not required
            form_class = self.get_form_class()
            form = self.get_form(form_class)
            # update any session data (as this view not subclassing AninstanceGenericView, like normal)

            helpers.set_session_data(request)