# Path: festi/festi/encoder.py
# class DjangoJSONEncoder(OrigDjangoJSONEncoder):
#     def default(self, o):
#         if isinstance(o, set):
#             return tuple(o)
#         elif hasattr(o, 'as_dict'):
#             return o.as_dict()
#         elif hasattr(o, 'as_list'):
#             return o.as_list()
#         elif isinstance(o, Model):
#             return {
#                 'id': o.id,
#                 'message': 'not implemented as_dict()',
#             }
#         elif isinstance(o, types.GeneratorType):
#             return tuple(o)
#         elif isinstance(o, QuerySet):
#             return tuple(o)
#         elif isinstance(o, uuid.UUID):
#             return o.hex
#         return super(DjangoJSONEncoder, self).default(o)


import json
from django.db.models import Model
from django.db.models.query import QuerySet
from django.http import HttpResponse, QueryDict
from .encoder import DjangoJSONEncoder


class PutMethodMiddleware(object):
    def process_view(self, request, view_func, view_args, view_kwargs):
        if request.method == 'PUT':
            request.PUT = QueryDict(request.body)
        else:
            request.PUT = QueryDict('')


class JsonResponseMiddleware(object):

# Path: festi/festi/encoder.py
# class DjangoJSONEncoder(OrigDjangoJSONEncoder):
#     def default(self, o):
#         if isinstance(o, set):
#             return tuple(o)
#         elif hasattr(o, 'as_dict'):
#             return o.as_dict()
#         elif hasattr(o, 'as_list'):
#             return o.as_list()
#         elif isinstance(o, Model):
#             return {
#                 'id': o.id,
#                 'message': 'not implemented as_dict()',
#             }
#         elif isinstance(o, types.GeneratorType):
#             return tuple(o)
#         elif isinstance(o, QuerySet):
#             return tuple(o)
#         elif isinstance(o, uuid.UUID):
#             return o.hex
#         return super(DjangoJSONEncoder, self).default(o)


# Path: festi/festi/middleware.py
import json
from django.db.models import Model
from django.db.models.query import QuerySet
from django.http import HttpResponse, QueryDict
from .encoder import DjangoJSONEncoder



class PutMethodMiddleware(object):
    def process_view(self, request, view_func, view_args, view_kwargs):
        if request.method == 'PUT':
            request.PUT = QueryDict(request.body)
        else:
            request.PUT = QueryDict('')


class JsonResponseMiddleware(object):

    def process_response(self, request, response):