# -*- coding: utf-8 -*-

"""pai2 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from rest_framework import routers

from account import account_views
from group import group_views, grouppage_views, groupuser_views, tourguidegroupuser_views
from miniapp import views as mini_views
from pay import views as pay_views
from photo import views as photo_views
from website import views as website_views


router = routers.DefaultRouter()
# router.register(r'users', account_views.UserViewSet)
# router.register(r'groups', account_views.GroupViewSet)

router.register(r'lensmans', account_views.LensmanInfoViewSet)
router.register(r'users', account_views.UserInfoViewSet)

router.register(r'groups', group_views.GroupInfoViewSet)
router.register(r'group_users', group_views.GroupUserInfoViewSet)
router.register(r'group_photos', group_views.GroupPhotoInfoViewSet)

router.register(r'photos', photo_views.PhotoInfoViewSet)

urlpatterns = [
    url(r'^pai2admin/', include(admin.site.urls)),
]

# Mini App
urlpatterns += [
    url(r'^pai2/home$', group_views.pai2_home_api, name='pai2_home_api'),  # 首页照片信息

    url(r'^mini/userinfo$', mini_views.get_userinfo_api, name='get_userinfo_api2'),  # 获取用户信息
    url(r'^mini/order_create$', pay_views.wx_order_create_api, name='wx_order_create_api'),  # 订单创建
    url(r'^mini/order_query$', pay_views.wx_order_query_api, name='wx_order_query_api'),  # 订单查询补单

    url(r'^s/join$', photo_views.session_join_api, name='session_join_api'),  # Session 加群
    url(r'^g/join$', groupuser_views.group_user_join_api, name='group_join_api'),  # 群成员加群
    url(r'^tgu/join$', tourguidegroupuser_views.tgu_group_user_join_api, name='tgu_group_user_join_api'),  # 旅行团成员加团

    url(r'^f/bought$', group_views.lensman_photo_bought, name='lensman_photo_bought'),  # 摄影师照片已购买
]

urlpatterns += [
    # url(r'^api/', include('api.urls', namespace='api')),
    url(r'^s/(?P<session_id>\w+)$', photo_views.session_detail, name='session_detail'),  # Session 详情
    url(r'^p/(?P<photo_id>\w+)$', photo_views.photo_standard, name='photo_standard'),  # standard thumbnail, available for free
    url(r'^m/(?P<photo_id>\w+)$', photo_views.photo_medium, name='photo_medium'),  # medium/mobile version, without watermark, login or paid by others
    url(r'^l/(?P<photo_id>\w+)$', photo_views.photo_large, name='photo_large'),  # large, might support server side panning later, login required
    url(r'^r/(?P<photo_id>\w+)$', photo_views.photo_raw, name='photo_raw'),  # raw image, only for finishers
]

urlpatterns += [
    url(r'^g/(?P<group_id>\w+)$', grouppage_views.group_detail, name='group_detail'),  # 群组详情(拍爱用户端下载页)
]

urlpatterns += [
    url(r'^gp/(?P<photo_id>\w+)$', grouppage_views.group_photo_detail, name='group_photo_detail'),  # 群组照片详情
]

urlpatterns += [
    url(r'^tg/(?P<admin_id>\w+)$', grouppage_views.tgu_group_detail, name='tgu_group_detail'),  # 旅行团详情(拍爱导游端下载页)
]

urlpatterns += [
    url(r'^tgu/(?P<admin_id>\w+)$', grouppage_views.tgu_group_user_detail, name='tgu_group_user_detail'),  # 旅行团成员详情(拍爱用户端下载页)
]

urlpatterns += [
    url(r'^$', website_views.pai2_home, name='pai2_home'),  # 官网首页
]

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns += [
    url(r'^api/', include(router.urls)),
    url(r'^uniapi/', include('django_uniapi.urls', namespace='uniapi')),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),

    # url(r'^p/', include('page.urls', namespace='shortpage')),
    url(r'^page/', include('page.urls', namespace='page')),

    url(r'^w/', include('django_we.urls', namespace='shortwechat')),
    url(r'^we/', include('django_we.urls', namespace='wechat')),
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

admin.site.site_header = u'［拍爱］后台管理系统'
