Skip to content

[Fixed #872] Filter Builds according to commit #3544

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

Merged
merged 6 commits into from
Oct 31, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions readthedocs/restapi/views/model_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ class BuildViewSetBase(UserSelectViewSet):
admin_serializer_class = BuildAdminSerializer
model = Build

def get_queryset(self):
Copy link
Member

@safwanrahman safwanrahman Feb 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call super instead of making the queryset?
Something like

queryset = super(BuildViewSetBase, self).get_queryset()
commit = self.request.query_params.get('commit', None)
if commit is not None:
    query = query.filter(commit=commit)
    return query

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand and I have looked into it as to why you asked me to do so as well. Your assistance was very well appreciated and I have made the requested changes. You can review it if you wish @safwanrahman.

query = self.model.objects.api(self.request.user)
commit = self.request.query_params.get('commit', None)
if commit is not None:
query = query.filter(commit=commit)
return query


class BuildViewSet(SettingsOverrideObject):

Expand Down