# Path: quick_reports/api/serializers.py
# class ContentTypeSerializer(serializers.ModelSerializer):
#     report_set = serializers.SerializerMethodField()
# 
#     class Meta:
#         model = ContentType
# 
#     def get_report_set(self, obj):
#         meta = getattr(obj.model_class(), 'QuickReport', None)
# 
#         report_list = []
#         if meta is not None:
#             report_set = getattr(meta, 'report_sets', None)
#             if report_set is not None:
#                 for report in report_set:
#                     report_list.append(report["name"])
# 
# 
#         return report_list
# 
# Path: quick_reports/sites.py
# class ReportSite(object):
#     def __init__(self, name='report'):
#     def register(self):
#     def get_model(self, app_label, model_name):
#     def get_apps(self):
#     def get_models(self, app_label):
#     def get_reports_for_model(self, app_label, model_name):
#     def get_model_report(self, app_label, model_name, report_slug):


import calendar
import collections
import pytz as pytz
from datetime import datetime, timedelta, time, date
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404
from rest_framework import generics
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK
from quick_reports.api.serializers import ContentTypeSerializer
from quick_reports.sites import site
        for app_label in site.get_apps().keys():
            model_list = []

            for model_name in site.get_models(app_label):
                report_list = []

                for slug, report in site.get_reports_for_model(app_label, model_name).iteritems():

                    report_list.append({"slug": slug,
                                        "name": report["name"]})

                model_list.append({"name": model_name,
                                   "reports": report_list})

            app_list.append({"label": app_label,
                             "models": model_list})
        return Response(app_list, status=HTTP_200_OK)


class ReportChartView(generics.GenericAPIView):
    paginate_by = None

    def get(self, request, *args, **kwargs):
        MAX_HISTORY = 14
        app_label = kwargs.get("app_label", None)
        model_name = kwargs.get("model_name", None)

        ct = get_object_or_404(ContentType, app_label=app_label, model=model_name)
        ct_class = ct.model_class()


# Path: quick_reports/api/serializers.py
# class ContentTypeSerializer(serializers.ModelSerializer):
#     report_set = serializers.SerializerMethodField()
# 
#     class Meta:
#         model = ContentType
# 
#     def get_report_set(self, obj):
#         meta = getattr(obj.model_class(), 'QuickReport', None)
# 
#         report_list = []
#         if meta is not None:
#             report_set = getattr(meta, 'report_sets', None)
#             if report_set is not None:
#                 for report in report_set:
#                     report_list.append(report["name"])
# 
# 
#         return report_list
# 
# Path: quick_reports/sites.py
# class ReportSite(object):
#     def __init__(self, name='report'):
#     def register(self):
#     def get_model(self, app_label, model_name):
#     def get_apps(self):
#     def get_models(self, app_label):
#     def get_reports_for_model(self, app_label, model_name):
#     def get_model_report(self, app_label, model_name, report_slug):


# Path: quick_reports/api/views.py
import calendar
import collections
import pytz as pytz
from datetime import datetime, timedelta, time, date
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404
from rest_framework import generics
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK
from quick_reports.api.serializers import ContentTypeSerializer
from quick_reports.sites import site

        for app_label in site.get_apps().keys():
            model_list = []

            for model_name in site.get_models(app_label):
                report_list = []

                for slug, report in site.get_reports_for_model(app_label, model_name).iteritems():

                    report_list.append({"slug": slug,
                                        "name": report["name"]})

                model_list.append({"name": model_name,
                                   "reports": report_list})

            app_list.append({"label": app_label,
                             "models": model_list})
        return Response(app_list, status=HTTP_200_OK)


class ReportChartView(generics.GenericAPIView):
    paginate_by = None

    def get(self, request, *args, **kwargs):
        MAX_HISTORY = 14
        app_label = kwargs.get("app_label", None)
        model_name = kwargs.get("model_name", None)

        ct = get_object_or_404(ContentType, app_label=app_label, model=model_name)
        ct_class = ct.model_class()


        report_model = site.get_model(app_label, model_name)