Skip to content

Commit

Permalink
Use consistent v1 URL pattern for odata
Browse files Browse the repository at this point in the history
the "resource names" are `odata/cases` and `odata/forms`, so ensure that
that is consistent between tastypie and non-tastypie views
  • Loading branch information
esoergel committed Oct 21, 2024
1 parent 75b74af commit 41aa9c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 11 additions & 9 deletions corehq/apps/api/odata/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
ODataFormServiceView,
)

urlpatterns = [
url(r'cases/(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/$',
odata_case_urlpatterns = [
url(r'(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/$',
ODataCaseServiceView.as_view(), name=ODataCaseServiceView.table_urlname),
url(r'cases/(?P<config_id>[\w\-:]+)/$',
url(r'(?P<config_id>[\w\-:]+)/$',
ODataCaseServiceView.as_view(), name=ODataCaseServiceView.urlname),
url(r'cases/(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/\$metadata$',
url(r'(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/\$metadata$',
ODataCaseMetadataView.as_view(), name=ODataCaseMetadataView.table_urlname),
url(r'cases/(?P<config_id>[\w\-:]+)/\$metadata$',
url(r'(?P<config_id>[\w\-:]+)/\$metadata$',
ODataCaseMetadataView.as_view(), name=ODataCaseMetadataView.urlname),
]

url(r'forms/(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/$',
odata_form_urlpatterns = [
url(r'(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/$',
ODataFormServiceView.as_view(), name=ODataFormServiceView.table_urlname),
url(r'forms/(?P<config_id>[\w\-:]+)/$',
url(r'(?P<config_id>[\w\-:]+)/$',
ODataFormServiceView.as_view(), name=ODataFormServiceView.urlname),
url(r'forms/(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/\$metadata$',
url(r'(?P<config_id>[\w\-:]+)/(?P<table_id>[\d]+)/\$metadata$',
ODataFormMetadataView.as_view(), name=ODataFormMetadataView.table_urlname),
url(r'forms/(?P<config_id>[\w\-:]+)/\$metadata$',
url(r'(?P<config_id>[\w\-:]+)/\$metadata$',
ODataFormMetadataView.as_view(), name=ODataFormMetadataView.urlname),
]
12 changes: 9 additions & 3 deletions corehq/apps/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
CaseAttachmentAPI,
view_form_attachment,
)
from corehq.apps.api.odata.urls import urlpatterns as odata_urlpatterns
from corehq.apps.api.odata.urls import (
odata_case_urlpatterns,
odata_form_urlpatterns,
)
from corehq.apps.api.resources import v0_1, v0_3, v0_4, v0_5
from corehq.apps.api.resources.messaging_event.view import messaging_events
from corehq.apps.api.resources.v0_5 import (
Expand Down Expand Up @@ -122,8 +125,11 @@ def versioned_apis(api_list):


urlpatterns = [
url(r'(?P<api_version>v0.5)/odata/', include(odata_urlpatterns)),
url(r'odata/(?P<api_version>v1)/', include(odata_urlpatterns)),
url(r'(?P<api_version>v0.5)/odata/cases/', include(odata_case_urlpatterns)),
url(r'(?P<api_version>v0.5)/odata/forms/', include(odata_form_urlpatterns)),
url(r'odata/cases/(?P<api_version>v1)/', include(odata_case_urlpatterns)),
url(r'odata/forms/(?P<api_version>v1)/', include(odata_form_urlpatterns)),

url(r'(?P<api_version>v0.5)/messaging-event/$',
messaging_events, name="api_messaging_event_list"),
url(r'(?P<api_version>v0.5)/messaging-event/(?P<event_id>\d+)/$',
Expand Down

0 comments on commit 41aa9c2

Please sign in to comment.