# Path: django_de/news/views.py
# def news_list(request, year=None, month=None, day=None):
#     """
#     A simple index view that can be restricted to a certain year, year+month or
#     year+month+day.
#     """
#     query = models.NewsItem.objects
#     filter_ = Q()
#     if year is not None:
#         filter_ &= Q(pub_date__year=int(year))
#     if month is not None:
#         filter_ &= Q(pub_date__month=int(month))
#     if day is not None:
#         filter_ &= Q(pub_date__day=int(day))
#     if filter_ is not None:
#         query = query.filter(filter_)
# 
#     return render(request, 'news/list.html', {
#         'object_list': query,
#         'months': models.NewsItem.objects.dates('pub_date', 'month',
#                                                 order='DESC'),
#     })
# 
# def news_detail(request, pk, slug=None):
#     """
#     Presents a single newsitem.
#     """
#     item = get_object_or_404(models.NewsItem.objects, pk=pk)
# 
#     return render(request, 'news/detail.html', {
#         'object': item,
#     })


from django.conf.urls import url, patterns
from .views import news_list, news_detail



urlpatterns = patterns('',
    url(r'^(?:(?P<year>\d{4})/(?:(?P<month>\d{2})/(?:(?P<day>\d{2})/)?)?)?$', news_list,
        name='news_list'),
    # url(r'^(?:(?P<year>\d{4})/)?$', news_list,
    #     name='news_list'),

# Path: django_de/news/views.py
# def news_list(request, year=None, month=None, day=None):
#     """
#     A simple index view that can be restricted to a certain year, year+month or
#     year+month+day.
#     """
#     query = models.NewsItem.objects
#     filter_ = Q()
#     if year is not None:
#         filter_ &= Q(pub_date__year=int(year))
#     if month is not None:
#         filter_ &= Q(pub_date__month=int(month))
#     if day is not None:
#         filter_ &= Q(pub_date__day=int(day))
#     if filter_ is not None:
#         query = query.filter(filter_)
# 
#     return render(request, 'news/list.html', {
#         'object_list': query,
#         'months': models.NewsItem.objects.dates('pub_date', 'month',
#                                                 order='DESC'),
#     })
# 
# def news_detail(request, pk, slug=None):
#     """
#     Presents a single newsitem.
#     """
#     item = get_object_or_404(models.NewsItem.objects, pk=pk)
# 
#     return render(request, 'news/detail.html', {
#         'object': item,
#     })


# Path: django_de/news/urls.py
from django.conf.urls import url, patterns
from .views import news_list, news_detail




urlpatterns = patterns('',
    url(r'^(?:(?P<year>\d{4})/(?:(?P<month>\d{2})/(?:(?P<day>\d{2})/)?)?)?$', news_list,
        name='news_list'),
    # url(r'^(?:(?P<year>\d{4})/)?$', news_list,
    #     name='news_list'),

    url(r'^(?P<slug>.*)-(?P<pk>.*)/$', news_detail, name='news_detail'),