# Path: quotes/views.py
# class QuoteDetailView(DetailView):
#     model = Quote
# 
#     def get_object(self):
#         return get_object_or_404(Quote, uuid=self.kwargs['uuid'])
# 
# class AuthorDetailView(DetailViewMixin):
#     model = Author
#     title = "Programming quotes by %s | defprogramming"
#     description = "Listing all programming quotes by %s. Quotes about " \
#                   "programming, coding, software industry."
# 
# class TagDetailView(DetailViewMixin):
#     model = Tag
#     title = "Programming quotes tagged under %s | defprogramming"
#     description = "Listing all programming quotes tagged under %s. "\
#                   "Quotes about programming, coding, software industry."
# 
# class AuthorListView(ListView):
#     model = Author
# 
#     def get_queryset(self):
#         return self.model.objects.extra(select={
#             'name_lower': 'lower(name)'}
#         ).order_by('name_lower')
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuthorListView, self).get_context_data(**kwargs)
#         context['title'] = "Listing all authors | defprogramming"
#         context['description'] = "List of all the authors with quotes " \
#                                  "published. Quotes about programming, " \
#                                  "coding, software industry."
#         return context
# 
# class TagListView(ListView):
#     model = Tag
# 
#     def get_context_data(self, **kwargs):
#         context = super(TagListView, self).get_context_data(**kwargs)
#         context['title'] = "Listing all tags | defprogramming"
#         context['description'] = "List of all the tags with quotes " \
#                                  "published. Quotes about programming, " \
#                                  "coding, software industry."
#         return context


from django.conf import settings
from django.conf.urls import patterns
from django.conf.urls import url
from django.views.decorators.cache import cache_page
from .views import (QuoteDetailView, AuthorDetailView, TagDetailView,
                    AuthorListView, TagListView)
    'quotes.views',
    url(
        regex=r'^q/(?P<uuid>[\w]+)/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            QuoteDetailView.as_view()
        ),
        name='quote'
    ),
    # url(r'^q/(?P<uuid>[\w]+)/$', 'detail', name='quote'),
    url(r'^quote/(?P<slug>[\w-]+)/$', 'quote_redirect'),

    url(
        regex=r'^authors/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            AuthorListView.as_view()
        ),
        name='authors'
    ),
    url(
        regex=r'^quotes-by/(?P<slug>[\w-]+)/(page/(?P<page>\d+)/)?$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            AuthorDetailView.as_view()
        ),
        name='author'
    ),

    url(
        regex=r'^tags/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            TagListView.as_view()

# Path: quotes/views.py
# class QuoteDetailView(DetailView):
#     model = Quote
# 
#     def get_object(self):
#         return get_object_or_404(Quote, uuid=self.kwargs['uuid'])
# 
# class AuthorDetailView(DetailViewMixin):
#     model = Author
#     title = "Programming quotes by %s | defprogramming"
#     description = "Listing all programming quotes by %s. Quotes about " \
#                   "programming, coding, software industry."
# 
# class TagDetailView(DetailViewMixin):
#     model = Tag
#     title = "Programming quotes tagged under %s | defprogramming"
#     description = "Listing all programming quotes tagged under %s. "\
#                   "Quotes about programming, coding, software industry."
# 
# class AuthorListView(ListView):
#     model = Author
# 
#     def get_queryset(self):
#         return self.model.objects.extra(select={
#             'name_lower': 'lower(name)'}
#         ).order_by('name_lower')
# 
#     def get_context_data(self, **kwargs):
#         context = super(AuthorListView, self).get_context_data(**kwargs)
#         context['title'] = "Listing all authors | defprogramming"
#         context['description'] = "List of all the authors with quotes " \
#                                  "published. Quotes about programming, " \
#                                  "coding, software industry."
#         return context
# 
# class TagListView(ListView):
#     model = Tag
# 
#     def get_context_data(self, **kwargs):
#         context = super(TagListView, self).get_context_data(**kwargs)
#         context['title'] = "Listing all tags | defprogramming"
#         context['description'] = "List of all the tags with quotes " \
#                                  "published. Quotes about programming, " \
#                                  "coding, software industry."
#         return context


# Path: quotes/urls.py
from django.conf import settings
from django.conf.urls import patterns
from django.conf.urls import url
from django.views.decorators.cache import cache_page
from .views import (QuoteDetailView, AuthorDetailView, TagDetailView,
                    AuthorListView, TagListView)

    'quotes.views',
    url(
        regex=r'^q/(?P<uuid>[\w]+)/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            QuoteDetailView.as_view()
        ),
        name='quote'
    ),
    # url(r'^q/(?P<uuid>[\w]+)/$', 'detail', name='quote'),
    url(r'^quote/(?P<slug>[\w-]+)/$', 'quote_redirect'),

    url(
        regex=r'^authors/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            AuthorListView.as_view()
        ),
        name='authors'
    ),
    url(
        regex=r'^quotes-by/(?P<slug>[\w-]+)/(page/(?P<page>\d+)/)?$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            AuthorDetailView.as_view()
        ),
        name='author'
    ),

    url(
        regex=r'^tags/$',
        view=cache_page(settings.DEFAULT_CACHE_TIME)(
            TagListView.as_view()

        ),