from django.urls import path, include
import oauth2_provider.views as oauth2_views
from rest_framework import routers
from django.conf import settings

from authentication.healthcheck import health_check
from authentication.message.views import (
    UserMessageViewSet,
    SendingMessageMethodViewSet,
    SendSMSViewSet
)
from authentication.register import get_driver_excel, create_driver_excel_template, upload_driver_excel, get_poultry_hatching_excel, check_poultry_hatching_excel, \
    reset_hatching_excel, enter_driver_hamedan, integration_of_hatching, check_poultry_in_db, \
    update_chicken_age_from_login, violation_archive_true, update_chicken_breed_from_excel, ye_chee_bani, \
    get_server_time, transaction_fix, internal_transaction_fix, convert_utm_to_location, change_last_digit_to_six, \
    fix_guild_steward, check_product, kill_house_requests_product_warehousing, \
    kill_house_free_buying_product_warehousing, kill_house_allocations_product_warehousing, \
    kill_house_free_sale_product_warehousing, kill_house_cold_house_allocations_product_warehousing, \
    check_kill_house_request_calculate, check_kill_house_free_bar_information_calculate, \
    check_kill_house_free_sale_bar_information_calculate, check_steward_allocations_calculate, temporary_trash_true, \
    archive_hatching_temporary_true, PoultryRequest_temporary_trash_true, CityOperatorCheckRequest_temporary_trash_true, \
    KillRequest_temporary_trash_true, ProvinceKillRequest_temporary_trash_true, KillHouseRequest_temporary_trash_true, \
    KillHouseAssignmentInformation_temporary_trash_true, KillHouseFreeBarInformation_temporary_trash_true, \
    StewardAllocation_temporary_trash_true, ColdHouseAllocations_temporary_trash_true, \
    StewardFreeBarInformation_temporary_trash_true, StewardFreeSaleBarInformation_temporary_trash_true, \
    InternalTransaction_temporary_trash_true, ExternalTransaction_temporary_trash_true, \
    ChainAllocation_temporary_trash_true, duplicate_order_code, fix_duplicate_order_code, fix_duplicate_order_code_new, \
    add_vet_farm_to_poultry_request, create_city_guild, add_killing_age_to_poultry_request, add_poultry_prediction, \
    fix_out_quantity_hatching, live_chicken_transportation, heards_meat_flow, chat_bot_info, detail_heards_meat_flow, \
    breed, fix_kill_req_njsndb, add_to_warehouse_manual, add_free_bar_to_warehouse_manual, \
    warning_free_bar_to_warehouse_manual, warning_to_warehouse_manual, warning_province_kill_request_without_bar_manual, \
    update_chicken_age_from_login_manual, add_free_bar_to_warehouse_automatic_type_manual, KillHouseStressTestView, \
    fix_warehouse_input_province_bars_for_limitation, fix_warehouse_out_buying_bars_for_limitation, \
    fix_warehouse_in_province_allocations_for_limitation, fix_warehouse_free_sale_for_limitation, \
    fix_warehouse_cold_house_for_limitation, fix_warehouse_segmentation_for_limitation, fix_warehouse_for_limitation, \
    fix_time_error, fix_steward_free_buying_product_warehousing_for_limitation, \
    fix_guild_steward_product_segmentation_warehousing_for_limitation, \
    fix_guild_steward_free_sale_warehousing_for_limitation, \
    fix_steward_guild_steward_allocations_warehousing_for_limitation, \
    fix_steward_guild_pos_allocations_warehousing_for_limitation, fix_steward_warehouse_for_limitation, fix_pos_owner, \
    fix_guild_steward_archive_warehousing, fix_guild_steward_pos_allocation_weight_for_product, \
    fix_kill_house_archive_warehousing
from authentication.sms_management import user_sms, kill_house_vet_check_receive_sms, \
    send_again_sms_for_final_approval_out_province, send_gate_way_sms_manual, send_deactivate_panel_debt_sms_manual, \
    ManagementSendSmsViewSet, test_sms_endpoint
from authentication.views import (
    login,
    register,
    new_login,
    new_register,
    new_send_otp,
    forget_password,
    UserProfileViewSet,
    check_otp,
    change_password,
    AddressViewSet,
    BankCardViewSet,
    UserProfileSearchViewSet,
    CheckChickenQuntityViewSet,
    ProvinceViewSet,
    CityViewSet,
    CityUnitViewSet,
    SystemAddressViewSet,
    SystemUserProfileViewSet, ShowSystemUserProfileViewSet, ForceDiagramViewSet, CityWithOutProvinceKeyViewSet,
    ProvinceChangeBankCardViewSet, TotalSystemUserProfileStatisticsDashboardViewSet,
    TotalPricingStatisticsDashboardViewSet, ExternalTransactionViewSet, pos_login, show_transaction_info,
    TokenVerification, new_pos_login, CityForProducctPricingViewSet, register_tenant,
    SystemUserProfileّForFactorProfileViewSet, CitysViewSet
)

router = routers.DefaultRouter()
router.register(r'user-profile', UserProfileViewSet, basename='user-profile')
router.register(r'transactions', ExternalTransactionViewSet, basename='transactions')
router.register(r'system_user_profile', SystemUserProfileViewSet, basename='system-user-profile')
router.register(r'system_user_profile-for-factor', SystemUserProfileّForFactorProfileViewSet, basename='system_user_profile-for-factor')
router.register(r'user-profile_search', UserProfileSearchViewSet, basename='user-profile_search')
router.register(r'user-bank_card', BankCardViewSet, basename='user-bank_card')
router.register(r'province_change_bank_card', ProvinceChangeBankCardViewSet, basename='province_change_bank_card')
router.register(r'address', AddressViewSet, basename='address')
router.register(r'province', ProvinceViewSet, basename='province')
router.register(r'city', CityViewSet, basename='city')
router.register(r'city-product-pricing', CityForProducctPricingViewSet, basename='city-product-pricing')
router.register(r'province_cities', CityWithOutProvinceKeyViewSet, basename='province_cities')
router.register(r'cities', CitysViewSet, basename='cities')
router.register(r'city-unit', CityUnitViewSet, basename='city-unit')
router.register(r'system_address', SystemAddressViewSet, basename='system_address')
router.register(r'user_message', UserMessageViewSet, basename="user_message")
router.register(r'show_users', ShowSystemUserProfileViewSet, basename='show_users')
router.register(r'diageram', ForceDiagramViewSet, basename='diageram')
router.register(r'total_system_user_profile_dashboard', TotalSystemUserProfileStatisticsDashboardViewSet,
                basename='total_system_user_profile_dashboard')
router.register(r'total_pricing_dashboard', TotalPricingStatisticsDashboardViewSet,
                basename='total_pricing_dashboard')
router.register(r'sending_message_method', SendingMessageMethodViewSet, basename="sending_message_method")
router.register(r'send_sms', SendSMSViewSet, basename="send_sms")
router.register(r'quantity', CheckChickenQuntityViewSet, basename="quantity")
router.register(r'management-send-sms', ManagementSendSmsViewSet, basename="management-send-sms")

oauth2_endpoint_views = [
    path('login/', new_login, name="login"),
    path('pos-login/', pos_login, name="pos-login"),
    path('new-pos-login/', new_pos_login, name="new-pos-login"),
    path('newregister/', new_register, name="new_register"),
    path('new_send/', new_send_otp, name='new_send'),
    path('send/', new_send_otp, name="send_otp"),
    path('check/', check_otp, name="check_otp"),
    # path('login/', login, name="login"),
    path('register/', register, name="register"),
    path('forget/', forget_password, name="forget_password"),
    path('change_password/', change_password, name="change_password"),
    path('token/', oauth2_views.TokenView.as_view(), name="token"),

]

if settings.DEBUG:
    # OAuth2 Application Management endpoints
    oauth2_endpoint_views += [
        path('applications/', oauth2_views.ApplicationList.as_view(), name="list"),
        path('applications/register/', oauth2_views.ApplicationRegistration.as_view(), name="register"),
        path('applications/<pk>/', oauth2_views.ApplicationDetail.as_view(), name="detail"),
        path('applications/<pk>/delete/', oauth2_views.ApplicationDelete.as_view(), name="delete"),
        path('applications/<pk>/update/', oauth2_views.ApplicationUpdate.as_view(), name="update"),
    ]

    # OAuth2 Token Management endpoints
    oauth2_endpoint_views += [
        path('authorized-tokens/', oauth2_views.AuthorizedTokensListView.as_view(), name="authorized-token-list"),
        path('authorized-tokens/<pk>/delete/', oauth2_views.AuthorizedTokenDeleteView.as_view(),
             name="authorized-token-delete"),
    ]

urlpatterns = [
    path('', include(router.urls)),
    path('api/', include((oauth2_endpoint_views, 'oauth2_provider.urls'), namespace="oauth2_provider")),
    # path('sms/', user_sms_wrapper),
    path('sms/', user_sms),
    path("health/", health_check),
    path('driver_excel/', get_driver_excel),
    path('driver_excel_template/', create_driver_excel_template),
    path('upload_driver_excel/', upload_driver_excel),
    path('hatching_excel/', get_poultry_hatching_excel),
    path('check_hatching_excel/', check_poultry_hatching_excel),
    path('vet_check_sms/', kill_house_vet_check_receive_sms),
    path('reset_hatching_excel/', reset_hatching_excel),
    path('enter_driver_hamedan/', enter_driver_hamedan),
    path('integration_of_hatching/', integration_of_hatching),
    path('check_poultry_in_db/', check_poultry_in_db),
    path('show_transaction_info/', show_transaction_info),
    path('update_chicken_age_from_login/', update_chicken_age_from_login),
    path('violation_archive_true/', violation_archive_true),
    path('update_chicken_breed_from_excel/', update_chicken_breed_from_excel),
    path('token-verification/', TokenVerification),
    path('ye_chee_bani/', ye_chee_bani),
    path('get_server_time/', get_server_time),
    path('transaction_fix/', transaction_fix),
    path('internal_transaction_fix/', internal_transaction_fix),
    path('convert_utm_to_location/', convert_utm_to_location),
    path('change_last_digit_to_six/', change_last_digit_to_six),
    path('send_again_sms_for_final_approval_out_province/', send_again_sms_for_final_approval_out_province),
    path('fix_guild_steward/', fix_guild_steward),
    path('check_product/', check_product),
    path('register_tenant/', register_tenant),
    path('kill_house_requests_product_warehousing/', kill_house_requests_product_warehousing),
    path('kill_house_free_buying_product_warehousing/', kill_house_free_buying_product_warehousing),
    path('kill_house_allocations_product_warehousing/', kill_house_allocations_product_warehousing),
    path('kill_house_free_sale_product_warehousing/', kill_house_free_sale_product_warehousing),
    path('kill_house_cold_house_allocations_product_warehousing/',
         kill_house_cold_house_allocations_product_warehousing),
    path('check_kill_house_request_calculate/', check_kill_house_request_calculate),
    path('check_kill_house_free_bar_information_calculate/', check_kill_house_free_bar_information_calculate),
    path('check_kill_house_free_sale_bar_information_calculate/', check_kill_house_free_sale_bar_information_calculate),
    path('check_steward_allocations_calculate/', check_steward_allocations_calculate),
    path('temporary_trash_true/', temporary_trash_true),
    path('archive_hatching_temporary_true/', archive_hatching_temporary_true),
    path('PoultryRequest_temporary_trash_true/', PoultryRequest_temporary_trash_true),
    path('CityOperatorCheckRequest_temporary_trash_true/', CityOperatorCheckRequest_temporary_trash_true),
    path('KillRequest_temporary_trash_true/', KillRequest_temporary_trash_true),
    path('ProvinceKillRequest_temporary_trash_true/', ProvinceKillRequest_temporary_trash_true),
    path('KillHouseRequest_temporary_trash_true/', KillHouseRequest_temporary_trash_true),
    path('KillHouseAssignmentInformation_temporary_trash_true/', KillHouseAssignmentInformation_temporary_trash_true),
    path('KillHouseFreeBarInformation_temporary_trash_true/', KillHouseFreeBarInformation_temporary_trash_true),
    path('StewardAllocation_temporary_trash_true/', StewardAllocation_temporary_trash_true),
    path('ColdHouseAllocations_temporary_trash_true/', ColdHouseAllocations_temporary_trash_true),
    path('StewardFreeBarInformation_temporary_trash_true/', StewardFreeBarInformation_temporary_trash_true),
    path('StewardFreeSaleBarInformation_temporary_trash_true/', StewardFreeSaleBarInformation_temporary_trash_true),
    path('InternalTransaction_temporary_trash_true/', InternalTransaction_temporary_trash_true),
    path('ExternalTransaction_temporary_trash_true/', ExternalTransaction_temporary_trash_true),
    path('ChainAllocation_temporary_trash_true/', ChainAllocation_temporary_trash_true),
    path('duplicate_order_code/', duplicate_order_code),
    path('fix_duplicate_order_code/', fix_duplicate_order_code),
    path('fix_duplicate_order_code_new/', fix_duplicate_order_code_new),
    path('add_vet_farm_to_poultry_request/', add_vet_farm_to_poultry_request),
    path('create_city_guild/', create_city_guild),
    path('add_killing_age_to_poultry_request/', add_killing_age_to_poultry_request),
    path('add_poultry_prediction/', add_poultry_prediction),
    path('fix_out_quantity_hatching/', fix_out_quantity_hatching),
    path('live_chicken_transportation/', live_chicken_transportation),
    path('heards_meat_flow/', heards_meat_flow),
    path('detail_heards_meat_flow/', detail_heards_meat_flow),
    path('breed/', breed),
    path('chat_bot_info/', chat_bot_info),
    path('fix_kill_req_njsndb/', fix_kill_req_njsndb),
    path('add_to_warehouse_manual/', add_to_warehouse_manual),
    path('add_free_bar_to_warehouse_manual/', add_free_bar_to_warehouse_manual),
    path('send_gate_way_sms_manual/', send_gate_way_sms_manual),
    path('fix_warehouse_for_limitation/', fix_warehouse_for_limitation),
    path('fix_warehouse_input_province_bars_for_limitation/', fix_warehouse_input_province_bars_for_limitation),
    path('fix_warehouse_out_buying_bars_for_limitation/', fix_warehouse_out_buying_bars_for_limitation),
    path('fix_warehouse_in_province_allocations_for_limitation/', fix_warehouse_in_province_allocations_for_limitation),
    path('fix_warehouse_free_sale_for_limitation/', fix_warehouse_free_sale_for_limitation),
    path('fix_warehouse_cold_house_for_limitation/', fix_warehouse_cold_house_for_limitation),
    path('fix_warehouse_segmentation_for_limitation/', fix_warehouse_segmentation_for_limitation),
    path('fix_kill_house_archive_warehousing/', fix_kill_house_archive_warehousing),
    path('fix_time_error/', fix_time_error),
    path('fix_pos_owner/', fix_pos_owner),
    path('send_deactivate_panel_debt_sms_manual/', send_deactivate_panel_debt_sms_manual),
    path('test_sms/', test_sms_endpoint),
    path('warning_free_bar_to_warehouse_manual/', warning_free_bar_to_warehouse_manual),
    path('warning_to_warehouse_manual/', warning_to_warehouse_manual),
    path('warning_province_kill_request_without_bar_manual/', warning_province_kill_request_without_bar_manual),
    path('update_chicken_age_from_login_manual/', update_chicken_age_from_login_manual),
    path('add_free_bar_to_warehouse_automatic_type_manual/', add_free_bar_to_warehouse_automatic_type_manual),

    path('fix_steward_free_buying_product_warehousing_for_limitation/', fix_steward_free_buying_product_warehousing_for_limitation),
    path('fix_steward_guild_steward_allocations_warehousing_for_limitation/', fix_steward_guild_steward_allocations_warehousing_for_limitation),
    path('fix_guild_steward_free_sale_warehousing_for_limitation/', fix_guild_steward_free_sale_warehousing_for_limitation),
    path('fix_guild_steward_product_segmentation_warehousing_for_limitation/', fix_guild_steward_product_segmentation_warehousing_for_limitation),
    path('fix_steward_guild_pos_allocations_warehousing_for_limitation/', fix_steward_guild_pos_allocations_warehousing_for_limitation),
    path('fix_steward_warehouse_for_limitation/', fix_steward_warehouse_for_limitation),
    path('fix_guild_steward_archive_warehousing/', fix_guild_steward_archive_warehousing),
    path('fix_guild_steward_pos_allocation_weight_for_product/', fix_guild_steward_pos_allocation_weight_for_product),

    path("killhouse-stress/", KillHouseStressTestView.as_view(), name="killhouse-stress"),

]
