Skip to content
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

Add convenience methods to EndpointSet #10

Closed
wants to merge 1 commit into from

Conversation

grahamu
Copy link
Contributor

@grahamu grahamu commented Jun 29, 2016

What does this PR do?

Adds commonly used code to EndpointSet.prepare() to retrieve a Resource object if the Resource object model is based on Django ModelBase, and if the request method is appropriate.

Where should the reviewer start?

Read the updated code.

How should this be manually tested?

Run tests.

Any background context you want to provide?

In another project requiring pinax-api I noticed 75% of EndpointSets use almost identical logic to obtain a Resource object via their individual prepare() and get_queryset() methods. This update aims to relieve that tedium.

get_pk() and get_resource_object_model() allow for customizing the object model and PK before object retrieval. This helps when an endpoint proxies for other models, or when a PK needs translation before object lookup.

What ticket or issue # does this fix?

N/A

Definition of Done (check if considered and/or addressed):

  • Is there appropriate test coverage?
  • Does this PR require a regression test? All fixes require a regression test.
  • Did you update internal documentation appropriately?
  • Did you update (or alert the appropriate person to update) user-facing documentation?

Also add convenience methods for obtaining PK, resource object model,
and resource object queryset.
@grahamu grahamu mentioned this pull request Jun 30, 2016
4 tasks
@grahamu grahamu closed this Jun 30, 2016
@grahamu grahamu deleted the prepare-convenience branch July 5, 2016 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant