"""File containing Member application URLs."""

from django.urls import re_path
from django.conf import settings
from django.contrib.auth.decorators import login_required, permission_required

# members
from members.views import member_list, payment_add, payment_submit
from members.views import application_delete_confirm, application_delete
from members.views import application_accept, import_csv
from members.views import settings_page, payment_edit
from members.views import payment_delete_confirm
from members.views import payment_delete, payment_update
from members.views import member_add
from members.views import member_add_many
from members.views import member_edit
from members.views import member_submit
from members.views import member_update
from members.views import member_delete_confirm
from members.views import member_delete
from members.views import payment_list
from members.views import add_many_confirm
from members.views import export_members_excel
from members.views import export_payments_excel
from members.views import export_applications_excel

# autocomplete view
from members.views import MemberAutoComplete

# rest api
from members.views import MemberDetail, CheckByEmail
from rest_framework.authtoken import views

# application
from members.views import application_form
from members.views import application_list
from members.views import application_edit
from members.views import application_submit

# email validation
# from members.views import validateEmail, validate_success, validate_fail

urlpatterns = [
    # landing page
    re_path(r"^$", member_list),
    re_path(r"^list$", member_list),
    # add member form view
    re_path(r"^add$", member_add),
    # add many members view
    re_path(r"^add_many$", member_add_many),
    # edit member information view
    re_path(r"^edit/(?P<index>\d+)$", member_edit),
    # delete confirmation view
    re_path(r"^delete_member_confirm/(?P<index>\d+)$", member_delete_confirm),
    # list all member applications
    re_path(r"^applications$", application_list),
    # edit member application
    re_path(r"^edit_application/(?P<index>\d+)$", application_edit),
    # post request targets
    re_path(r"^submit_member$", member_submit),
    re_path(r"^update_member$", member_update),
    re_path(r"^delete_member$", member_delete),
    re_path(r"^submit_payment$", payment_submit),
    re_path(r"^update_payment$", payment_update),
    re_path(r"^delete_payment$", payment_delete),
    re_path(r"^submit_application$", application_submit),
    re_path(r"^accept_application$", application_accept),
    re_path(r"^delete_application$", application_delete),
    # the actual member application form
    re_path(r"^application/$", application_form),
    # delete confirmation view for applications
    re_path(r"^delete_application_confirm/(?P<index>\d+)$", application_delete_confirm),
    # list all payment events
    re_path(r"^payments$", payment_list),
    # add payment event
    re_path(r"^add_payment$", payment_add),
    # edit payment event
    re_path(r"^edit_payment/(?P<index>\d+)$", payment_edit),
    # delete confirmation view
    re_path(r"^delete_payment_confirm/(?P<index>\d+)$", payment_delete_confirm),
    # post endpoint for confirming multiple entries
    re_path(r"^add_many_confirm$", add_many_confirm),
    # settings page
    re_path(r"^settings$", settings_page),
    # send CSV member data by POST
    re_path(r"^import_csv", import_csv),
    # export members as excel file
    re_path(r"export_members", export_members_excel),
    re_path(r"export_payments", export_payments_excel),
    re_path(r"export_applications", export_applications_excel),
    # rest api url
    re_path(r"^api/members/(?P<pk>\d+)$", MemberDetail.as_view()),
    # member select autocomplete view
    re_path(
        r"^member-autocomplete/$",
        MemberAutoComplete.as_view(),
        name="member-autocomplete",
    ),
    re_path(r"^check", CheckByEmail.as_view()),
]

if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()
