"""datacenter URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/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. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework.documentation import include_docs_urls
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from django.conf.urls.static import static

import company.views as company_views
import inventory.views as inventory_views
import utils.views as utils_views
import promotion.views as promotion_views
import crm.views as crm_views

admin.site.site_header =_("天鉴-物流后台管理")
admin.site.site_title = _("数据后台")
admin.site.index_title = _("天鉴物流")

urlpatterns = [
    url(r'^$', company_views.home),
    url(r'docs/', include_docs_urls(title="后台接口")),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),    
    url(r'^admin/', admin.site.urls),

    url(r'^api/company/', include('company.api_urls')),
    url(r'^company/', include('company.urls')),

    url(r'^accounts/login/$', company_views.accounts_login),
    url(r'^user/login/', company_views.user_login),
    url(r'^user/logout/', company_views.user_logout),
    url(r'^user/chgpwd/', company_views.user_chgpwd),


    url(r'^inventory/fg/update/', inventory_views.fg_update),
    url(r'^inventory/stk/(?P<company_id>\d+)/$', inventory_views.inventory_stk),
    url(r'^inventory/list/(?P<company_id>\d+)/$', inventory_views.inventory_list),
    url(r'^inventory/delivery/list/(?P<company_id>\d+)/$', inventory_views.delivery_list),
    url(r'^inventory/inbound/list/(?P<company_id>\d+)/$', inventory_views.inbound_list),

    
    url(r'^inventory/unhandled/(?P<company_id>\d+)/$', inventory_views.list_unhandled_batch),
    url(r'^inventory/process/unhandled/(?P<batch_id>\d+)/$', inventory_views.handle_batch),

    #url(r'^inventory/notes/template/(?P<obj>\w+)/$', inventory_views.notes_template),
    #url(r'^inventory/notes/list/(?P<obj>\w+)/$', inventory_views.notes_list),

    #url(r'^inventory/batch/template/(?P<id>\d+)/$', inventory_views.batch_template),
    #url(r'^inventory/batch/list/(?P<id>\d+)/$', inventory_views.batch_list),


    
    
    url(r'^inventory/stock/(?P<company_id>\d+)/$',inventory_views.inventory_stock),
    url(r'^inventory/stock/$',inventory_views.inventory_stock),

    url(r'^inventory/batch/details/(?P<id>\d+)/$',inventory_views.batch_details),  


    url(r'^inventory/batch/(?P<obj>\w+)/$',inventory_views.inventory_batch),    
    url(r'^inventory/batch/(?P<obj>\w+)/(?P<company_id>\d+)/$',inventory_views.inventory_batch),    
   
   
    



    url(r'^inventory/html/(?P<what>\w+)/', inventory_views.inventory_html),
    url(r'^inventory/upload/label_replace/$', inventory_views.upload_label_replace),
    # url(r'^inventory/ajax/jiugui/local/(?P<box_code>\d+)/$', inventory_views.ajax_jiugui_local),

    url(r'^legacy/delivery/', inventory_views.legacy_delivery),

    url(r'^obj/list/(?P<company_id>\d+)/(?P<obj>\w+)/$', company_views.get_obj_list),
    url(r'^get/production/structure/(?P<company_id>\d+)/(?P<obj>\w+)/$', company_views.get_prd_structure),

    url(r'^list/(?P<obj>\w+)/$', company_views.list_obj),

    url(r'^label/infor/(?P<code>\w+)/$', inventory_views.get_label_info),
    url(r'^label/app/(?P<company_id>\d+)/(?P<code>\w+)/$', inventory_views.app_label_info),





    url(r'^utils/migrate/(?P<db>\w+)/(?P<tb>\w+)/$', utils_views.migrate_sql_pg),



    url(r'^promotion/xfbqt/$', promotion_views.xfbqt_batch),
    url(r'^promotion/xfbqt/details/$', promotion_views.xfbqt_details),
    url(r'^promotion/xfbqt/get/$', promotion_views.get_xfbqt),
    url(r'^promotion/xfbqt/get/(?P<dept_id>\d+)/$', promotion_views.get_xfbqt),


    url(r'^promotion/upload/receipt/image/$', promotion_views.upload_receipt_img),




    url(r'^crm/(?P<operation>\w+)/(?P<obj>\w+)/$', crm_views.crm_operation),

    url(r'^import/crm/(?P<external_id>\d+)/$', crm_views.import_crm),







]

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













