"""auth_service2 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from ts25_auth import views
from django.contrib import admin
from django.urls import path, re_path
from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets


# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username', 'email', 'is_staff']


# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer


router = routers.DefaultRouter()
router.register(r'users', UserViewSet)

urlpatterns = [
    path('', include(router.urls)),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),

    path('admin/', admin.site.urls),  ## contains a URL pattern.
    path('user/find', views.find_user),
    path('user/login_check', views.login_check),
    re_path(r'^user/login_check', views.login_check),  ## contains a regular expression.

    url(r'^article/(\d+)/', views.viewArticle, name='article'),
    ## r: to use regular expression operations     e.g): (\d+).
    url(r'^hello/', views.hello, name='hello'),
    # url() : This function is an alias to django.urls.re_path(), Deprecated since version 3.1:.

    # rest_framework

]

# from django.contrib import admin
# from django.urls import path
# from rest_framework import routers
# from ts25_auth.views import UserViewSet
# from django.conf.urls import url, include
#
#
# router = routers.DefaultRouter()
# router.register('userId', UserViewSet)
#
# urlpatterns = [
#     url(r'^admin/', admin.site.urls),
#     url(r'^', include(router.urls)),
# ]
