From ff0b53dea93946c172b117a89c5dc5a91c241fc2 Mon Sep 17 00:00:00 2001 From: August Johnson Date: Sat, 19 Oct 2024 10:16:20 -0500 Subject: [PATCH] Organizing urls a bit better. Should be non-functional change. --- api/urls.py | 20 +++++++++++ api_v2/urls.py | 37 +++++++++++++++++++++ server/urls.py | 90 ++++++-------------------------------------------- 3 files changed, 68 insertions(+), 79 deletions(-) create mode 100644 api/urls.py create mode 100644 api_v2/urls.py diff --git a/api/urls.py b/api/urls.py new file mode 100644 index 00000000..a1e67170 --- /dev/null +++ b/api/urls.py @@ -0,0 +1,20 @@ +from rest_framework import routers + +from api import views + +router = routers.DefaultRouter() +router.register(r'manifest', views.ManifestViewSet) +router.register(r'spells', views.SpellViewSet) +router.register(r'spelllist',views.SpellListViewSet) +router.register(r'monsters', views.MonsterViewSet) +router.register(r'documents', views.DocumentViewSet) +router.register(r'backgrounds', views.BackgroundViewSet) +router.register(r'planes', views.PlaneViewSet) +router.register(r'sections', views.SectionViewSet) +router.register(r'feats', views.FeatViewSet) +router.register(r'conditions', views.ConditionViewSet) +router.register(r'races',views.RaceViewSet) +router.register(r'classes',views.CharClassViewSet) +router.register(r'magicitems',views.MagicItemViewSet) +router.register(r'weapons',views.WeaponViewSet) +router.register(r'armor',views.ArmorViewSet) diff --git a/api_v2/urls.py b/api_v2/urls.py new file mode 100644 index 00000000..7c496d0f --- /dev/null +++ b/api_v2/urls.py @@ -0,0 +1,37 @@ + +from rest_framework import routers + +from api_v2 import views + +router = routers.DefaultRouter() +router.register(r'items',views.ItemViewSet) +router.register(r'itemsets',views.ItemSetViewSet) +router.register(r'itemcategories',views.ItemCategoryViewSet) +router.register(r'documents',views.DocumentViewSet) +router.register(r'licenses',views.LicenseViewSet) +router.register(r'publishers',views.PublisherViewSet) +router.register(r'weapons',views.WeaponViewSet) +router.register(r'armor',views.ArmorViewSet) +router.register(r'gamesystems',views.GameSystemViewSet) +router.register(r'backgrounds',views.BackgroundViewSet) +router.register(r'feats',views.FeatViewSet) +router.register(r'races',views.RaceViewSet) +router.register(r'creatures',views.CreatureViewSet) +router.register(r'creaturetypes',views.CreatureTypeViewSet) +router.register(r'creaturesets',views.CreatureSetViewSet) +router.register(r'damagetypes',views.DamageTypeViewSet) +router.register(r'languages',views.LanguageViewSet) +router.register(r'alignments',views.AlignmentViewSet) +router.register(r'conditions',views.ConditionViewSet) +router.register(r'spells',views.SpellViewSet) +router.register(r'classes',views.CharacterClassViewSet) +router.register(r'sizes',views.SizeViewSet) +router.register(r'itemrarities',views.ItemRarityViewSet) +router.register(r'environments',views.EnvironmentViewSet) +router.register(r'abilities',views.AbilityViewSet) +router.register(r'skills',views.SkillViewSet) +router.register(r'rules', views.RuleViewSet) +router.register(r'rulesets', views.RuleSetViewSet) + +search_router = routers.DefaultRouter() +search_router.register('',views.SearchResultViewSet, basename='search') diff --git a/server/urls.py b/server/urls.py index c9d89e4c..e35b88b4 100644 --- a/server/urls.py +++ b/server/urls.py @@ -15,92 +15,24 @@ """ from django.conf.urls import include -from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from django.urls import path from django.conf import settings -from rest_framework import routers +from api import urls as v1_urls +from api.views import get_version +from api_v2 import urls as v2_urls +from api_v2.views import get_enums -from api import views -from api_v2 import views as views_v2 - -router = routers.DefaultRouter() -#router.register(r'users', views.UserViewSet) -#router.register(r'groups', views.GroupViewSet) -router.register(r'manifest', views.ManifestViewSet) -router.register(r'spells', views.SpellViewSet) -router.register(r'spelllist',views.SpellListViewSet) -router.register(r'monsters', views.MonsterViewSet) -router.register(r'documents', views.DocumentViewSet) -router.register(r'backgrounds', views.BackgroundViewSet) -router.register(r'planes', views.PlaneViewSet) -router.register(r'sections', views.SectionViewSet) -router.register(r'feats', views.FeatViewSet) -router.register(r'conditions', views.ConditionViewSet) -router.register(r'races',views.RaceViewSet) -#router.register(r'subraces',views.SubraceViewSet) -router.register(r'classes',views.CharClassViewSet) -#router.register(r'archetypes',views.ArchetypeViewSet) -router.register(r'magicitems',views.MagicItemViewSet) -router.register(r'weapons',views.WeaponViewSet) -router.register(r'armor',views.ArmorViewSet) - -#router.register('search', views.SearchView, basename="global-search") - - -router_v2 = routers.DefaultRouter() - -router_v2.register(r'items',views_v2.ItemViewSet) -router_v2.register(r'itemsets',views_v2.ItemSetViewSet) -router_v2.register(r'itemcategories',views_v2.ItemCategoryViewSet) -router_v2.register(r'documents',views_v2.DocumentViewSet) -router_v2.register(r'licenses',views_v2.LicenseViewSet) -router_v2.register(r'publishers',views_v2.PublisherViewSet) -router_v2.register(r'weapons',views_v2.WeaponViewSet) -router_v2.register(r'armor',views_v2.ArmorViewSet) -router_v2.register(r'gamesystems',views_v2.GameSystemViewSet) -router_v2.register(r'backgrounds',views_v2.BackgroundViewSet) -router_v2.register(r'feats',views_v2.FeatViewSet) -router_v2.register(r'races',views_v2.RaceViewSet) -router_v2.register(r'creatures',views_v2.CreatureViewSet) -router_v2.register(r'creaturetypes',views_v2.CreatureTypeViewSet) -router_v2.register(r'creaturesets',views_v2.CreatureSetViewSet) -router_v2.register(r'damagetypes',views_v2.DamageTypeViewSet) -router_v2.register(r'languages',views_v2.LanguageViewSet) -router_v2.register(r'alignments',views_v2.AlignmentViewSet) -router_v2.register(r'conditions',views_v2.ConditionViewSet) -router_v2.register(r'spells',views_v2.SpellViewSet) -router_v2.register(r'classes',views_v2.CharacterClassViewSet) -router_v2.register(r'sizes',views_v2.SizeViewSet) -router_v2.register(r'itemrarities',views_v2.ItemRarityViewSet) -router_v2.register(r'environments',views_v2.EnvironmentViewSet) -router_v2.register(r'abilities',views_v2.AbilityViewSet) -router_v2.register(r'skills',views_v2.SkillViewSet) -router_v2.register(r'rules', views_v2.RuleViewSet) -router_v2.register(r'rulesets', views_v2.RuleSetViewSet) - -router_search = routers.DefaultRouter() - -router_search.register('',views_v2.SearchResultViewSet, basename='search') - - -# Wire up our API using automatic URL routing. -# Additionally, we include login URLs for the browsable API. urlpatterns = [ - path('', include(router.urls)), - #url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), - #path('search/', include('haystack.urls')), - path('version/', views.get_version, name="version"), - path('v2/enums/', views_v2.get_enums, name="enums"), - - - # Versioned API routes (above routes default to v1) - path('v1/', include(router.urls)), - #path('v1/search/', include('haystack.urls')), - path('v2/', include(router_v2.urls)), - path('v2/search/', include(router_search.urls)) + path('', include(v1_urls.router.urls)), + path('version/', get_version, name="version"), + path('v1/', include(v1_urls.router.urls)), + + path('v2/', include(v2_urls.router.urls)), + path('v2/search/', include(v2_urls.search_router.urls)), + path('v2/enums/', get_enums, name="enums") ] if settings.DEBUG is True: