lib.itmens/catalog/urls.py

22 lines
652 B
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 *
def _get_all_url_paths():
paths = ['item']
for cls in Item.__subclasses__():
p = getattr(cls, 'url_path', None)
if p:
paths.append(p)
res = "|".join(paths)
return res
2022-12-15 17:29:35 -05:00
urlpatterns = [
2022-12-17 23:03:19 -05:00
re_path(r'^item/(?P<item_uuid>[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_uid>[A-Za-z0-9]{21,22})/', retrieve, name='retrieve'),
2022-12-16 01:08:10 -05:00
path("api/", api.urls),
]