from django.urls import path

from portal.views import (
    RenderExtraJS,
    GetHome,
    GetRoster,
    GetObjectsFiltered,
    GetManufacturerItem,
    GetFlatpage,
    GetRollingStock,
    GetConsist,
    Consists,
    Companies,
    Manufacturers,
    Scales,
    Types,
    Books,
    Catalogs,
    Magazines,
    GetMagazine,
    GetMagazineIssue,
    GetBookCatalog,
    SearchObjects,
)

urlpatterns = [
    path("", GetHome.as_view(), name="index"),
    path("extra.js", RenderExtraJS.as_view(), name="extra_js"),
    path("roster", GetRoster.as_view(), name="roster"),
    path("roster/page/<int:page>", GetRoster.as_view(), name="roster"),
    path(
        "page/<str:flatpage>",
        GetFlatpage.as_view(),
        name="flatpage",
    ),
    path("consists", Consists.as_view(), name="consists"),
    path("consists/page/<int:page>", Consists.as_view(), name="consists"),
    path("consist/<uuid:uuid>", GetConsist.as_view(), name="consist"),
    path(
        "consist/<uuid:uuid>/page/<int:page>",
        GetConsist.as_view(),
        name="consist",
    ),
    path("companies", Companies.as_view(), name="companies"),
    path(
        "companies/page/<int:page>",
        Companies.as_view(),
        name="companies",
    ),
    path(
        "manufacturers/<str:category>",
        Manufacturers.as_view(template="pagination_manufacturers.html"),
        name="manufacturers",
    ),
    path(
        "manufacturers/<str:category>/page/<int:page>",
        Manufacturers.as_view(template="pagination_manufacturers.html"),
        name="manufacturers",
    ),
    path("scales", Scales.as_view(), name="scales"),
    path("scales/page/<int:page>", Scales.as_view(), name="scales"),
    path("types", Types.as_view(), name="rolling_stock_types"),
    path("types/page/<int:page>", Types.as_view(), name="rolling_stock_types"),
    path("bookshelf/books", Books.as_view(), name="books"),
    path("bookshelf/books/page/<int:page>", Books.as_view(), name="books"),
    path(
        "bookshelf/magazine/<uuid:uuid>",
        GetMagazine.as_view(),
        name="magazine",
    ),
    path(
        "bookshelf/magazine/<uuid:uuid>/page/<int:page>",
        GetMagazine.as_view(),
        name="magazine",
    ),
    path(
        "bookshelf/magazine/<uuid:magazine>/issue/<uuid:uuid>",
        GetMagazineIssue.as_view(),
        name="issue",
    ),
    path("bookshelf/magazines", Magazines.as_view(), name="magazines"),
    path(
        "bookshelf/magazines/page/<int:page>",
        Magazines.as_view(),
        name="magazines",
    ),
    path(
        "bookshelf/<str:selector>/<uuid:uuid>",
        GetBookCatalog.as_view(),
        name="bookshelf_item",
    ),
    path("bookshelf/catalogs", Catalogs.as_view(), name="catalogs"),
    path(
        "bookshelf/catalogs/page/<int:page>",
        Catalogs.as_view(),
        name="catalogs",
    ),
    path(
        "search",
        SearchObjects.as_view(http_method_names=["post"]),
        name="search",
    ),
    path(
        "search/<str:search>/page/<int:page>",
        SearchObjects.as_view(),
        name="search",
    ),
    path(
        "manufacturer/<str:manufacturer>",
        GetManufacturerItem.as_view(),
        name="manufacturer",
    ),
    path(
        "manufacturer/<str:manufacturer>/page/<int:page>",
        GetManufacturerItem.as_view(),
        name="manufacturer",
    ),
    path(
        "manufacturer/<str:manufacturer>/<str:search>",
        GetManufacturerItem.as_view(),
        name="manufacturer",
    ),
    path(
        "manufacturer/<str:manufacturer>/<str:search>/page/<int:page>",
        GetManufacturerItem.as_view(),
        name="manufacturer",
    ),
    path(
        "<str:_filter>/<str:search>",
        GetObjectsFiltered.as_view(),
        name="filtered",
    ),
    path(
        "<str:_filter>/<str:search>/page/<int:page>",
        GetObjectsFiltered.as_view(),
        name="filtered",
    ),
    path("<uuid:uuid>", GetRollingStock.as_view(), name="rolling_stock"),
]
