# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django.conf.urls import url, include
from django.views.generic import TemplateView
from rest_framework import routers

from . import views

router = routers.DefaultRouter()
router.register(r'creditcards', views.CreditCardOfferViewSet)

urlpatterns = [
    url(regex=r'^card-reviewer/$', view=TemplateView.as_view(template_name='content/card-reviewer.html'), name='card-reviewer'),
    url(regex=r'^pages/$', view=views.CrawledPageListView.as_view(), name='page-list'),
    url(regex=r'^pages/(?P<id>[\d]+)/$', view=views.CrawledPageDetailView.as_view(), name='page-detail'),
    url(regex=r'^creditcards/$', view=views.CreditCardOfferListView.as_view(), name='creditcard-list'),
    url(regex=r'^creditcards/(?P<id>[\d]+)/$', view=views.CreditCardOfferDetailView.as_view(),
        name='creditcard-detail'),
    url(r'^search/', include('haystack.urls')),
    # url(r'^api/creditcards/$', view=views.CreditCardOfferAPIListView.as_view(), name='creditcard-api-list'),
    url(r'^api/', include(router.urls)),
    url(r'^api/websites/$', view=views.CreditCardWebsiteView.as_view(), name='website-api-list'),
]

# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django.conf.urls import url, include
from django.contrib.auth.decorators import login_required
from django.views.generic import TemplateView
from rest_framework import routers

from . import views

router = routers.DefaultRouter()
router.register(r'creditcards', views.CreditCardOfferViewSet)

urlpatterns = [
    url(regex=r'^card-reviewer/$', view=login_required(TemplateView.as_view(template_name='content/card-reviewer.html')), name='card-reviewer'),
    url(regex=r'^pages/$', view=views.CrawledPageListView.as_view(), name='page-list'),
    url(regex=r'^pages/(?P<id>[\d]+)/$', view=views.CrawledPageDetailView.as_view(), name='page-detail'),
    url(regex=r'^creditcards/$', view=views.CreditCardOfferListView.as_view(), name='creditcard-list'),
    url(regex=r'^creditcards/(?P<id>[\d]+)/$', view=views.CreditCardOfferDetailView.as_view(),
        name='creditcard-detail'),
    url(r'^search/', include('haystack.urls')),
    # url(r'^api/creditcards/$', view=views.CreditCardOfferAPIListView.as_view(), name='creditcard-api-list'),
    url(r'^api/', include(router.urls)),
    url(r'^api/websites/$', view=views.CreditCardWebsiteView.as_view(), name='website-api-list'),
]

make card-reviewer login_required