# Path: thezombies/views.py
# class HomeView(RedirectView):
#     url = '/audits/'
#     pattern_name = 'audit-list'
# 
# class AgencyList(ListView):
#     model = Agency
#     template_name = 'agency_list.html'
# 
# class AgencyView(DetailView):
#     model = Agency
#     template_name = 'agency_detail.html'
# 
# class AuditListView(ListView):
#     model = Audit
#     paginate_by = 50
#     template_name = 'audits_list.html'
# 
#     def get_queryset(self, **kwargs):
#         audit_filter_kwargs = {}
#         self.audit_type_string = self.kwargs.get('audit_type', None)
#         if self.audit_type_string:
#             if self.audit_type_string == 'generic':
#                 audit_filter_kwargs['audit_type'] = Audit.GENERIC_AUDIT
#             elif self.audit_type_string == 'validation':
#                 audit_filter_kwargs['audit_type'] = Audit.DATA_CATALOG_VALIDATION
#             elif self.audit_type_string == 'crawl':
#                 audit_filter_kwargs['audit_type'] = Audit.DATA_CATALOG_CRAWL
#             else:
#                 raise Http404
#         self.audit_list = Audit.objects.filter(**audit_filter_kwargs).prefetch_related('agency')
#         return self.audit_list
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuditListView, self).get_context_data(**kwargs)
#         context['audit_type'] = self.audit_type_string
#         return context
# 
# class AuditView(SingleObjectMixin, ListView):
#     paginate_by = 20
#     template_name = 'audit_detail.html'
# 
#     def get(self, request, *args, **kwargs):
#         self.object = self.get_object(queryset=Audit.objects.all())
#         return super(AuditView, self).get(request, *args, **kwargs)
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuditView, self).get_context_data(**kwargs)
#         context['audit'] = self.object
#         return context
# 
#     def get_queryset(self):
#         # Paginate probe objects
#         return self.object.probe_set.order_by('id')
# 
#     def get_template_names(self):
#         template_names = super(AuditView, self).get_template_names()
#         template_choices = dict(AUDIT_TYPE_TEMPLATES)
#         template_addition = template_choices.get(self.object.audit_type, None) if self.object else None
#         if template_addition:
#             template_names.insert(0, template_addition)
#         return template_names
# 
# class AuditDayArchiveView(DayArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     month_format = "%m"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class AuditMonthArchiveView(MonthArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     month_format = "%m"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class AuditYearArchiveView(YearArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class ProbeView(DetailView):
#     model = Probe
#     template_name = "probe_detail.html"


from django.conf.urls import patterns, include, url
from django.contrib import admin
from thezombies.views import (HomeView, AgencyList, AgencyView, AuditListView, AuditView,
                              AuditDayArchiveView, AuditMonthArchiveView, AuditYearArchiveView, ProbeView)


urlpatterns = patterns('',
    url(r'^$', HomeView.as_view(), name='home'),
    url(r'^agency/$', AgencyList.as_view(), name='agency-list'),
    url(r'^agency/(?P<slug>[\w\-]+)/$', AgencyView.as_view(), name='agency-detail'),
    url(r'^audits/$', AuditListView.as_view(), name='audits-list'),
    url(r'^audits/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', AuditDayArchiveView.as_view(), name='audits-list-day'),
    url(r'^audits/(?P<year>\d{4})/(?P<month>\d{2})/$', AuditMonthArchiveView.as_view(), name='audits-list-month'),
    url(r'^audits/(?P<year>\d{4})/$', AuditYearArchiveView.as_view(), name='audits-list-year'),
    url(r'^audits/(?P<pk>\d+)/$', AuditView.as_view(), name='audit-detail'),
    url(r'^audits/(?P<audit_type>\w+)/$', AuditListView.as_view(), name='audits-list-filtered'),

# Path: thezombies/views.py
# class HomeView(RedirectView):
#     url = '/audits/'
#     pattern_name = 'audit-list'
# 
# class AgencyList(ListView):
#     model = Agency
#     template_name = 'agency_list.html'
# 
# class AgencyView(DetailView):
#     model = Agency
#     template_name = 'agency_detail.html'
# 
# class AuditListView(ListView):
#     model = Audit
#     paginate_by = 50
#     template_name = 'audits_list.html'
# 
#     def get_queryset(self, **kwargs):
#         audit_filter_kwargs = {}
#         self.audit_type_string = self.kwargs.get('audit_type', None)
#         if self.audit_type_string:
#             if self.audit_type_string == 'generic':
#                 audit_filter_kwargs['audit_type'] = Audit.GENERIC_AUDIT
#             elif self.audit_type_string == 'validation':
#                 audit_filter_kwargs['audit_type'] = Audit.DATA_CATALOG_VALIDATION
#             elif self.audit_type_string == 'crawl':
#                 audit_filter_kwargs['audit_type'] = Audit.DATA_CATALOG_CRAWL
#             else:
#                 raise Http404
#         self.audit_list = Audit.objects.filter(**audit_filter_kwargs).prefetch_related('agency')
#         return self.audit_list
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuditListView, self).get_context_data(**kwargs)
#         context['audit_type'] = self.audit_type_string
#         return context
# 
# class AuditView(SingleObjectMixin, ListView):
#     paginate_by = 20
#     template_name = 'audit_detail.html'
# 
#     def get(self, request, *args, **kwargs):
#         self.object = self.get_object(queryset=Audit.objects.all())
#         return super(AuditView, self).get(request, *args, **kwargs)
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuditView, self).get_context_data(**kwargs)
#         context['audit'] = self.object
#         return context
# 
#     def get_queryset(self):
#         # Paginate probe objects
#         return self.object.probe_set.order_by('id')
# 
#     def get_template_names(self):
#         template_names = super(AuditView, self).get_template_names()
#         template_choices = dict(AUDIT_TYPE_TEMPLATES)
#         template_addition = template_choices.get(self.object.audit_type, None) if self.object else None
#         if template_addition:
#             template_names.insert(0, template_addition)
#         return template_names
# 
# class AuditDayArchiveView(DayArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     month_format = "%m"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class AuditMonthArchiveView(MonthArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     month_format = "%m"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class AuditYearArchiveView(YearArchiveView):
#     queryset = Audit.objects.all()
#     allow_empty = True
#     paginate_by = 50
#     date_field = "created_at"
#     make_object_list = True
#     template_name = 'audits_list.html'
# 
# class ProbeView(DetailView):
#     model = Probe
#     template_name = "probe_detail.html"


# Path: thezombies/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
from thezombies.views import (HomeView, AgencyList, AgencyView, AuditListView, AuditView,
                              AuditDayArchiveView, AuditMonthArchiveView, AuditYearArchiveView, ProbeView)



urlpatterns = patterns('',
    url(r'^$', HomeView.as_view(), name='home'),
    url(r'^agency/$', AgencyList.as_view(), name='agency-list'),
    url(r'^agency/(?P<slug>[\w\-]+)/$', AgencyView.as_view(), name='agency-detail'),
    url(r'^audits/$', AuditListView.as_view(), name='audits-list'),
    url(r'^audits/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d+)/$', AuditDayArchiveView.as_view(), name='audits-list-day'),
    url(r'^audits/(?P<year>\d{4})/(?P<month>\d{2})/$', AuditMonthArchiveView.as_view(), name='audits-list-month'),
    url(r'^audits/(?P<year>\d{4})/$', AuditYearArchiveView.as_view(), name='audits-list-year'),
    url(r'^audits/(?P<pk>\d+)/$', AuditView.as_view(), name='audit-detail'),
    url(r'^audits/(?P<audit_type>\w+)/$', AuditListView.as_view(), name='audits-list-filtered'),

    url(r'^probes/(?P<pk>\d+)/$', ProbeView.as_view(), name='probe-detail'),