lib.itmens/catalog/urls.py

65 lines
1.6 KiB
Python
Raw Normal View History

2022-12-15 17:29:35 -05:00
from django.urls import path, re_path
from .api import api
2022-12-15 17:29:35 -05:00
from .views import *
2022-12-16 01:08:10 -05:00
from .models import *
2022-12-29 23:57:02 -05:00
app_name = "catalog"
2022-12-24 01:28:24 -05:00
2022-12-16 01:08:10 -05:00
def _get_all_url_paths():
2022-12-29 23:57:02 -05:00
paths = ["item"]
2022-12-16 01:08:10 -05:00
for cls in Item.__subclasses__():
2022-12-29 23:57:02 -05:00
p = getattr(cls, "url_path", None)
2022-12-16 01:08:10 -05:00
if p:
paths.append(p)
res = "|".join(paths)
return res
2022-12-15 17:29:35 -05:00
urlpatterns = [
2022-12-29 23:57:02 -05:00
re_path(
r"^item/(?P<item_uid>[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})?$",
retrieve_by_uuid,
name="retrieve_by_uuid",
),
re_path(
r"^(?P<item_path>"
+ _get_all_url_paths()
+ ")/(?P<item_uuid>[A-Za-z0-9]{21,22})$",
retrieve,
name="retrieve",
),
re_path(
r"^(?P<item_path>"
+ _get_all_url_paths()
+ ")/(?P<item_uuid>[A-Za-z0-9]{21,22})/edit$",
edit,
name="edit",
),
re_path(
r"^(?P<item_path>"
+ _get_all_url_paths()
+ ")/(?P<item_uuid>[A-Za-z0-9]{21,22})/delete$",
delete,
name="delete",
),
2022-12-29 23:57:02 -05:00
re_path(
r"^(?P<item_path>"
+ _get_all_url_paths()
+ ")/(?P<item_uuid>[A-Za-z0-9]{21,22})/reviews",
review_list,
name="review_list",
),
re_path(
r"^(?P<item_path>"
+ _get_all_url_paths()
+ ")/(?P<item_uuid>[A-Za-z0-9]{21,22})/marks(?:/(?P<following_only>\\w+))?",
mark_list,
name="mark_list",
),
path("search/", search, name="search"),
path("search/external/", external_search, name="external_search"),
2022-12-31 11:06:23 -05:00
path("fetch_refresh/<str:job_id>", fetch_refresh, name="fetch_refresh"),
2022-12-16 01:08:10 -05:00
path("api/", api.urls),
]