Unverified Commit 07727643 authored by Petrus Janse van Rensburg's avatar Petrus Janse van Rensburg Committed by GitHub

Merge pull request #1749 from lapseofreason/master

Improve documentation of contrib.sqla.ModelView.get_query.
parents 43567732 102f2c0d
......@@ -833,6 +833,17 @@ class ModelView(BaseModelView):
class MyView(ModelView):
def get_query(self):
return super(MyView, self).get_query().filter(User.username == current_user.username)
Individual elements that are filtered in the list view are still
accessible through the edit view by simply changing the URL, even
when they are filtered by `get_query`. To prohibit this, also
override `get_one`.
Example::
def get_one(self, id):
query = self.get_query()
return query.filter(self.model.id == id).first()
"""
return self.session.query(self.model)
......@@ -1073,6 +1084,8 @@ class ModelView(BaseModelView):
"""
Return a single model by its id.
Also see `get_query` for how to filter the list view.
:param id:
Model id
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment