# 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 _
        }

    def __str__(self):
        return 'Default view for Aninstance project.'

    def view_cacher(self, request):
        if self.USE_CACHE:
            # return cached version if cached variable set
            cached_template_fragments = caches['template_fragments']
            # child view overrides self.fragment_key
            key = make_template_fragment_key(self.FRAGMENT_KEY, [request.get_full_path()])
            if cached_template_fragments.get(key):
                print('Returning cached response ...')
                return render(request, self.TEMPLATE_NAME, self.context)  # returned to view if cached response
            else:
                # carry on with the processing. Output will be cached for subsequent requests.
                print('CACHING THE RESPONSE FOR FUTURE USE ...')
                return None  # returned to view if no cached response
        print('Not using cache for this view ...')
        return None  # returned if cache not being used (self.USE_CACHE = None )

    def dispatch(self, request, *args, **kwargs):
        # checks auth status and redirects to login if not auth'd
        if self.authentication_required and not auth.Authenticate(request, level=self.auth_level).auth():
            return self.handle_no_permission()
        return super(AninstanceGenericView, self).dispatch(request, *args, **kwargs)

    def get(self, request):
        # default shared contexts
        self.context.update({

# 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 _

        }

    def __str__(self):
        return 'Default view for Aninstance project.'

    def view_cacher(self, request):
        if self.USE_CACHE:
            # return cached version if cached variable set
            cached_template_fragments = caches['template_fragments']
            # child view overrides self.fragment_key
            key = make_template_fragment_key(self.FRAGMENT_KEY, [request.get_full_path()])
            if cached_template_fragments.get(key):
                print('Returning cached response ...')
                return render(request, self.TEMPLATE_NAME, self.context)  # returned to view if cached response
            else:
                # carry on with the processing. Output will be cached for subsequent requests.
                print('CACHING THE RESPONSE FOR FUTURE USE ...')
                return None  # returned to view if no cached response
        print('Not using cache for this view ...')
        return None  # returned if cache not being used (self.USE_CACHE = None )

    def dispatch(self, request, *args, **kwargs):
        # checks auth status and redirects to login if not auth'd
        if self.authentication_required and not auth.Authenticate(request, level=self.auth_level).auth():
            return self.handle_no_permission()
        return super(AninstanceGenericView, self).dispatch(request, *args, **kwargs)

    def get(self, request):
        # default shared contexts
        self.context.update({

            'param_str': helpers.update_url_param(request, param_name=self.PARAM_STR),