-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle resource url according to new standard #35312
Conversation
corehq/apps/api/resources/v0_5.py
Outdated
@@ -1423,5 +1423,5 @@ def prepend_urls(self): | |||
# We're overriding the default "list" view to redirect to "detail" view since | |||
# we already know the user through OAuth. | |||
return [ | |||
url(r"^(?P<resource_name>%s)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail')), | |||
url(r"^$", self.wrap_view('dispatch_detail'), name='api_dispatch_detail'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to understand the impact of the linked PR on to this one, but could not really figure it out.
The resource name now comes before the version?
Or may be the question is,
What was the URL earlier and what is it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the resource_name
out of this portion of the URL and up a level higher.
The conflict between my PR and Charl's meant that (?P<resource_name>%s)
would've appeared in the URL twice.
>>> resolve('/a/esoergel/api/v0.5/analytics-roles/analytics-roles/')
ResolverMatch(func=tastypie.resources.wrapper, args=(), kwargs={'domain': 'esoergel', 'api_name': 'v0.5', 'resource_name': 'analytics-roles'},
url_name=None, app_names=[], namespaces=[], route='^a/(?P<domain>[\\w\\.:-]+)/api/(?P<api_name>v0.5)/(?P<resource_name>analytics-roles)/(?P<r
esource_name>analytics-roles)/$', captured_kwargs={'resource_name': 'analytics-roles'})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thsnks @esoergel
Do users need to update any of the urls they might be using like we do here https://github.com/dimagi/commcare-analytics/blob/master/hq_superset/hq_url.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, all the existing URLs should continue to function as before. Though if you guys like, you could make this the first API only available at the new URL (assuming you can be confident that that's the only place referencing this API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid, thank you @Charl1996 @esoergel
Oh yeah thank you - I forgot to follow up with this PR. Can you make the resource also available at v1 by putting this at the bottom of
|
4bafa29
to
1e3c1ca
Compare
1e3c1ca
to
749ad0a
Compare
Reverted #35315 here and made the URL available also in the v1 format |
FYI |
…nto update-resource-url
@@ -182,6 +181,7 @@ def versioned_apis(api_list): | |||
fixtures.v0_1.LookupTableItemResource.get_urlpattern('v1'), | |||
fixtures.v0_6.LookupTableItemResource.get_urlpattern('v2'), | |||
v0_5.NavigationEventAuditResource.get_urlpattern('v1'), | |||
v1_0.CommCareAnalyticsUserResource.get_urlpattern('v1'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, very nice! Another thing you may consider if it makes resonates with you is to put the resource in the app containing the model it serves. So the users resources in the users
app, the groups resource in the groups
app, etc. We have a few that operate this way already, and I've been thinking about pushing us to that model eventually, though I certainly haven't established a consensus around it yet.
My thinking is that it's more in line with how Django apps are generally used - one app per "thing", with models, views, tests, forms, fixtures, migrations, etc all in that folder, so related code is close together. Though in this case I'm not certain there's a very natural home for CommCareAnalyticsUserResource
- maybe users
? Also fine to punt on that question
Technical Summary
With the merge of this PR it's necessary to update the resource URL to remove the resource name as it's not necessary to specify the resource name manually anymore (@esoergel can expound in more detail if necessary)
Feature flag
Although this change is technically global, only users with the SUPERSET_ANALYTICS feature flag will be directly impacted after this PR has been deployed.
Safety Assurance
Tested locally
Automated test coverage
No QA. Local testing if fine
Rollback instructions
Labels & Review