__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"


from django.urls import path, re_path, include

from production import views as production_views

app_name = "production"

urlpatterns = [
    # refactoring 2023-05  htmx-driven production page
    path(
        "new",
        production_views.production_new,
        name="production_new",
    ),
    path(
        "team",
        include(
            [
                path(
                    "",
                    production_views.production_team,
                    name="production_team",
                ),
                path(
                    "list",
                    production_views.production_team_list,
                    name="production_team_list",
                ),
                path(
                    "_hx_delete_officer/<int:officer_id>/",
                    production_views._hx_team_delete_officer,
                    name="_hx_team_delete_officer",
                ),
                path(
                    "_hx_promote_user",
                    production_views._hx_team_promote_user,
                    name="_hx_team_promote_user",
                ),
            ]
        ),
    ),
    path(
        "_hx_productionstream_list",
        production_views._hx_productionstream_list,
        name="_hx_productionstream_list",
    ),
    path(
        "_hx_productionstream_search_form/<str:filter_set>",
        production_views._hx_productionstream_search_form,
        name="_hx_productionstream_search_form",
    ),
    path(
        "_hx_productionstream_actions_bulk_assign_officers",
        production_views._hx_productionstream_actions_bulk_assign_officers,
        name="_hx_productionstream_actions_bulk_assign_officers",
    ),
    path(
        "productionstreams/<int:productionstream_id>/",
        include(
            [
                path(
                    "details_contents",
                    production_views._hx_productionstream_details_contents,
                    name="_hx_productionstream_details_contents",
                ),
                path(
                    "actions_change_properties",
                    production_views._hx_productionstream_actions_change_properties,
                    name="_hx_productionstream_actions_change_properties",
                ),
                path(
                    "actions_work_log",
                    production_views._hx_productionstream_actions_work_log,
                    name="_hx_productionstream_actions_work_log",
                ),
                path(
                    "_hx_productionstream_change_action_buttons/<str:key>",
                    production_views._hx_productionstream_change_action_buttons,
                    name="_hx_productionstream_change_action_buttons",
                ),
                path(
                    "_hx_productionstream_summary_assignees_status",
                    production_views._hx_productionstream_summary_assignees_status,
                    name="_hx_productionstream_summary_assignees_status",
                ),
                path(
                    "events/",
                    include(
                        [
                            path(
                                "form",
                                production_views._hx_event_form,
                                name="_hx_event_form",
                            ),
                            path(
                                "list",
                                production_views._hx_event_list,
                                name="_hx_event_list",
                            ),
                            path(
                                "<int:event_id>/",
                                include(
                                    [
                                        path(
                                            "update",
                                            production_views._hx_event_form,
                                            name="_hx_event_form",
                                        ),
                                        path(
                                            "delete",
                                            production_views._hx_event_delete,
                                            name="_hx_event_delete",
                                        ),
                                    ]
                                ),
                            ),
                        ]
                    ),
                ),
            ]
        ),
    ),
    # end refactoring 2023-05
    path("", production_views.production, name="production"),
    path("<int:stream_id>", production_views.production, name="production"),
    path("completed", production_views.completed, name="completed"),
    path("officers/new", production_views.user_to_officer, name="user_to_officer"),
    path(
        "officers/<int:officer_id>/delete",
        production_views.delete_officer,
        name="delete_officer",
    ),
    path(
        "streams/<int:stream_id>/",
        include(
            [
                path("", production_views.stream, name="stream"),
                path("status", production_views.update_status, name="update_status"),
                path(
                    "_hx_status",
                    production_views._hx_update_status,
                    name="_hx_update_status",
                ),
                path(
                    "proofs/",
                    include(
                        [
                            path(
                                "upload",
                                production_views.upload_proofs,
                                name="upload_proofs",
                            ),
                            path(
                                "_hx_upload",
                                production_views._hx_upload_proofs,
                                name="_hx_upload_proofs",
                            ),
                            path(
                                "<int:version>/",
                                include(
                                    [
                                        path(
                                            "", production_views.proofs, name="proofs"
                                        ),
                                        re_path(
                                            "decision/(?P<decision>accept|decline)$",
                                            production_views.decision,
                                            name="decision",
                                        ),
                                        re_path(
                                            "_hx_proofs_decision/(?P<decision>accept|decline)$",
                                            production_views._hx_proofs_decision,
                                            name="_hx_proofs_decision",
                                        ),
                                        path(
                                            "send_to_authors",
                                            production_views.send_proofs,
                                            name="send_proofs",
                                        ),
                                        path(
                                            "_hx_send_to_authors",
                                            production_views._hx_send_proofs,
                                            name="_hx_send_proofs",
                                        ),
                                        path(
                                            "toggle_access",
                                            production_views.toggle_accessibility,
                                            name="toggle_accessibility",
                                        ),
                                        path(
                                            "_hx_toggle_access",
                                            production_views._hx_toggle_accessibility,
                                            name="_hx_toggle_accessibility",
                                        ),
                                    ]
                                ),
                            ),
                            path(
                                "<int:attachment_id>/reply/pdf",
                                production_views.production_event_attachment_pdf,
                                name="production_event_attachment_pdf",
                            ),
                        ]
                    ),
                ),
                path("events/add", production_views.add_event, name="add_event"),
                path("logs/add", production_views.add_work_log, name="add_work_log"),
                path(
                    "officer",
                    include(
                        [
                            path(
                                "add",
                                production_views.add_officer,
                                name="add_officer",
                            ),
                            path(
                                "<int:officer_id>/remove",
                                production_views.remove_officer,
                                name="remove_officer",
                            ),
                            path(
                                "update",
                                production_views._hx_update_officer,
                                name="_hx_update_officer",
                            ),
                        ]
                    ),
                ),
                path(
                    "invitations_officer",
                    include(
                        [
                            path(
                                "add",
                                production_views.add_invitations_officer,
                                name="add_invitations_officer",
                            ),
                            path(
                                "<int:officer_id>/remove",
                                production_views.remove_invitations_officer,
                                name="remove_invitations_officer",
                            ),
                            path(
                                "update",
                                production_views._hx_update_invitations_officer,
                                name="_hx_update_invitations_officer",
                            ),
                        ]
                    ),
                ),
                path(
                    "supervisor",
                    include(
                        [
                            path(
                                "add",
                                production_views.add_supervisor,
                                name="add_supervisor",
                            ),
                            path(
                                "<int:officer_id>/remove",
                                production_views.remove_supervisor,
                                name="remove_supervisor",
                            ),
                            path(
                                "update",
                                production_views._hx_update_supervisor,
                                name="_hx_update_supervisor",
                            ),
                        ]
                    ),
                ),
                path(
                    "_hx_mark_completed",
                    production_views._hx_mark_as_completed,
                    name="_hx_mark_as_completed",
                ),
                path(
                    "_hx_toggle_on_hold",
                    production_views._hx_toggle_on_hold,
                    name="_hx_toggle_on_hold",
                ),
                path(
                    "mark_completed",
                    production_views.mark_as_completed,
                    name="mark_as_completed",
                ),
            ]
        ),
    ),
    # events
    path(
        "events/<int:event_id>/",
        include(
            [
                path(
                    "edit",
                    production_views.UpdateEventView.as_view(),
                    name="update_event",
                ),
                path(
                    "delete",
                    production_views.DeleteEventView.as_view(),
                    name="delete_event",
                ),
            ]
        ),
    ),
    # proofs
    path("proofs/<int:slug>", production_views.proofs_pdf, name="proofs_pdf"),
    path(
        "proofs/<int:slug>/decision",
        production_views.author_decision,
        name="author_decision",
    ),
]