# Path: app/blog_lab/cbv/src/dss/Serializer.py
# def serializer(data, datetime_format='timestamp', output_type='raw', include_attr=None, exclude_attr=None,
#                foreign=False, many=False, **kwargs):
#     foreign = remove_check(**kwargs) or foreign
#     time_func = TimeFormatFactory.get_time_func(datetime_format)
#     result = _data_convert(data, time_func, foreign, many, include_attr, exclude_attr)
#     return _output_convert(output_type, result)
# 
# Path: app/blog_lab/cbv/src/dss/TimeFormatFactory.py
# class TimeFormatFactory(object):
#     def __init__(self):
#         super(TimeFormatFactory, self).__init__()
# 
#     @staticmethod
#     def datetime_to_string(datetime_time, time_format='%Y-%m-%d %H:%M:%S'):
#         if datetime_time.tzinfo is None:
#             return datetime_time.strftime(time_format)
#         datetime_time = datetime_time.astimezone(timezone.get_current_timezone())
#         return datetime_time.strftime(time_format)
# 
#     @staticmethod
#     def datetime_to_timestamp(datetime_time):
#         if datetime_time.tzinfo is None:
#             return time.mktime(datetime_time.timetuple())
#         datetime_time = datetime_time.astimezone(timezone.get_current_timezone())
#         return time.mktime(datetime_time.timetuple())
# 
#     @staticmethod
#     def get_time_func(func_type='string', time_format='%Y-%m-%d %H:%M:%S'):
#         if func_type == 'string':
#             return partial(TimeFormatFactory.datetime_to_string, time_format=time_format)
#         elif func_type == 'timestamp':
#             return TimeFormatFactory.datetime_to_timestamp
#         else:
#             return partial(TimeFormatFactory.datetime_to_string, time_format=time_format)


import datetime
import json
from django.core.paginator import EmptyPage
from .Serializer import serializer
from .TimeFormatFactory import TimeFormatFactory
    from django.http import HttpResponse
                          output_type='raw',
                          foreign=self.foreign,
                          many=self.many,
                          include_attr=self.include_attr,
                          exclude_attr=self.exclude_attr)
    @staticmethod
    def json_serializer(context):
        return json.dumps(context, indent=4)

    def render_to_response(self, context, **response_kwargs):
        context_dict = self.context_serialize(context)
        json_context = self.json_serializer(context_dict)
        return HttpResponse(json_context, content_type='application/json', **response_kwargs)


class FormJsonResponseMixin(JsonResponseMixin):
    def context_serialize(self, context):
        form_list = []
        form = context.get('form', None)
        if form:
            for itm in form.fields:
                f_dict = {'field': unicode(itm)}
                form_list.append(f_dict)
        context_dict = super(FormJsonResponseMixin, self).context_serialize(context)
        context_dict['form'] = form_list
        return context_dict


class MultipleJsonResponseMixin(JsonResponseMixin):
    def context_serialize(self, context):

# Path: app/blog_lab/cbv/src/dss/Serializer.py
# def serializer(data, datetime_format='timestamp', output_type='raw', include_attr=None, exclude_attr=None,
#                foreign=False, many=False, **kwargs):
#     foreign = remove_check(**kwargs) or foreign
#     time_func = TimeFormatFactory.get_time_func(datetime_format)
#     result = _data_convert(data, time_func, foreign, many, include_attr, exclude_attr)
#     return _output_convert(output_type, result)
# 
# Path: app/blog_lab/cbv/src/dss/TimeFormatFactory.py
# class TimeFormatFactory(object):
#     def __init__(self):
#         super(TimeFormatFactory, self).__init__()
# 
#     @staticmethod
#     def datetime_to_string(datetime_time, time_format='%Y-%m-%d %H:%M:%S'):
#         if datetime_time.tzinfo is None:
#             return datetime_time.strftime(time_format)
#         datetime_time = datetime_time.astimezone(timezone.get_current_timezone())
#         return datetime_time.strftime(time_format)
# 
#     @staticmethod
#     def datetime_to_timestamp(datetime_time):
#         if datetime_time.tzinfo is None:
#             return time.mktime(datetime_time.timetuple())
#         datetime_time = datetime_time.astimezone(timezone.get_current_timezone())
#         return time.mktime(datetime_time.timetuple())
# 
#     @staticmethod
#     def get_time_func(func_type='string', time_format='%Y-%m-%d %H:%M:%S'):
#         if func_type == 'string':
#             return partial(TimeFormatFactory.datetime_to_string, time_format=time_format)
#         elif func_type == 'timestamp':
#             return TimeFormatFactory.datetime_to_timestamp
#         else:
#             return partial(TimeFormatFactory.datetime_to_string, time_format=time_format)


# Path: app/blog_lab/cbv/src/dss/Mixin.py
import datetime
import json
from django.core.paginator import EmptyPage
from .Serializer import serializer
from .TimeFormatFactory import TimeFormatFactory
    from django.http import HttpResponse

                          output_type='raw',
                          foreign=self.foreign,
                          many=self.many,
                          include_attr=self.include_attr,
                          exclude_attr=self.exclude_attr)
    @staticmethod
    def json_serializer(context):
        return json.dumps(context, indent=4)

    def render_to_response(self, context, **response_kwargs):
        context_dict = self.context_serialize(context)
        json_context = self.json_serializer(context_dict)
        return HttpResponse(json_context, content_type='application/json', **response_kwargs)


class FormJsonResponseMixin(JsonResponseMixin):
    def context_serialize(self, context):
        form_list = []
        form = context.get('form', None)
        if form:
            for itm in form.fields:
                f_dict = {'field': unicode(itm)}
                form_list.append(f_dict)
        context_dict = super(FormJsonResponseMixin, self).context_serialize(context)
        context_dict['form'] = form_list
        return context_dict


class MultipleJsonResponseMixin(JsonResponseMixin):
    def context_serialize(self, context):

        page_dict = {}