# Path: aninstance_framework/search_forms.py
# class RightSidebarSearchForm(SearchForm):
#     # override elements of default SearchForm to add styling classes to fields
# 
#     def __init__(self, *args, **kwargs):
#         super(RightSidebarSearchForm, self).__init__()
#         self.placeholder = kwargs.get('placeholder') if 'placeholder' in kwargs else _('Search')
#         self.fields['q'] = forms.CharField(required=False,
#                                            label=_('Search for'),
#                                            widget=forms.TextInput(attrs={'type': 'search',
#                                                                          'class': 'form-control',
#                                                                          'size': '15',
#                                                                          'placeholder': self.placeholder,
#                                                                          }))
# 
#     def get_models(self):
#         return self.models
# 
#     def search(self):
#         # First, store the SearchQuerySet received from other processing.
#         sqs = super(RightSidebarSearchForm, 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.views import generic
from django.shortcuts import render
from django.core.cache import caches
from django.core.cache.utils import make_template_fragment_key
from django.conf import settings
from aninstance_framework.search_forms import RightSidebarSearchForm
from django.contrib.auth.mixins import AccessMixin
from aninstance_framework import helpers, auth
from django.utils.translation import ugettext_lazy as _
    CACHE_TTL = settings.DEFAULT_CACHES_TTL
    TEMPLATE_NAME = None
    FOOTER_TEXT = None  # None value means default is used, as defined in custom_context_processors.py
    PANEL_HEADING = None  # None value means default is used, as defined in custom_context_processors.py
    PANEL_FOOTER = None  # None value means default is used, as defined in custom_context_processors.py
    FRAGMENT_KEY = ''
    USE_CACHE = settings.DEFAULT_USE_TEMPLATE_FRAGMENT_CACHING  # overridden in child views!
    PAGINATION = False
    PAGINATION_ITEMS_PER_PAGE = 5
    PARAM_STR = 'default_param'
    PAGE_STR = 'p'
    STATUS_MESSAGE = None
    AUTHENTICATION_REQUIRED = False  # authorization not required for views by default. Overwrite in CVBs for auth.
    RIGHT_SIDEBAR_SEARCH_PLACEHOLDER_TEXT = _('Search for')
    RIGHT_SIDEBAR_SEARCH_BUTTON_TEXT = _('Search')
    """Define models to search
    Overwrite accordingly in child CBV (otherwise authentication error thrown).
    Indexes for models set in templates/search/indexes."""
    MODELS_TO_SEARCH = {
        '': [],  # e.g. '<url_action_param'>: ['<app.model>', '<app.another_model>']
    }

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.fragment_key = None  # overridden with value in child view class
        if not self.USE_CACHE:
            self.CACHE_TTL = self.NEVER_CACHE_TTL
        self.requested_page = 1
        self.search_url = None
        self.authentication_required = self.AUTHENTICATION_REQUIRED  # change in child views to activate auth

# Path: aninstance_framework/search_forms.py
# class RightSidebarSearchForm(SearchForm):
#     # override elements of default SearchForm to add styling classes to fields
# 
#     def __init__(self, *args, **kwargs):
#         super(RightSidebarSearchForm, self).__init__()
#         self.placeholder = kwargs.get('placeholder') if 'placeholder' in kwargs else _('Search')
#         self.fields['q'] = forms.CharField(required=False,
#                                            label=_('Search for'),
#                                            widget=forms.TextInput(attrs={'type': 'search',
#                                                                          'class': 'form-control',
#                                                                          'size': '15',
#                                                                          'placeholder': self.placeholder,
#                                                                          }))
# 
#     def get_models(self):
#         return self.models
# 
#     def search(self):
#         # First, store the SearchQuerySet received from other processing.
#         sqs = super(RightSidebarSearchForm, 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/base.py
from django.views import generic
from django.shortcuts import render
from django.core.cache import caches
from django.core.cache.utils import make_template_fragment_key
from django.conf import settings
from aninstance_framework.search_forms import RightSidebarSearchForm
from django.contrib.auth.mixins import AccessMixin
from aninstance_framework import helpers, auth
from django.utils.translation import ugettext_lazy as _

    CACHE_TTL = settings.DEFAULT_CACHES_TTL
    TEMPLATE_NAME = None
    FOOTER_TEXT = None  # None value means default is used, as defined in custom_context_processors.py
    PANEL_HEADING = None  # None value means default is used, as defined in custom_context_processors.py
    PANEL_FOOTER = None  # None value means default is used, as defined in custom_context_processors.py
    FRAGMENT_KEY = ''
    USE_CACHE = settings.DEFAULT_USE_TEMPLATE_FRAGMENT_CACHING  # overridden in child views!
    PAGINATION = False
    PAGINATION_ITEMS_PER_PAGE = 5
    PARAM_STR = 'default_param'
    PAGE_STR = 'p'
    STATUS_MESSAGE = None
    AUTHENTICATION_REQUIRED = False  # authorization not required for views by default. Overwrite in CVBs for auth.
    RIGHT_SIDEBAR_SEARCH_PLACEHOLDER_TEXT = _('Search for')
    RIGHT_SIDEBAR_SEARCH_BUTTON_TEXT = _('Search')
    """Define models to search
    Overwrite accordingly in child CBV (otherwise authentication error thrown).
    Indexes for models set in templates/search/indexes."""
    MODELS_TO_SEARCH = {
        '': [],  # e.g. '<url_action_param'>: ['<app.model>', '<app.another_model>']
    }

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.fragment_key = None  # overridden with value in child view class
        if not self.USE_CACHE:
            self.CACHE_TTL = self.NEVER_CACHE_TTL
        self.requested_page = 1
        self.search_url = None
        self.authentication_required = self.AUTHENTICATION_REQUIRED  # change in child views to activate auth

        self.auth_level = auth.USER_LEVEL.get('user')  # default to required level being a basic user