Skip to content

Commit

Permalink
bump version, fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asifpy committed Feb 28, 2016
1 parent 216ce5b commit 5a0e3ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crudbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
registry
)

VERSION = '0.1.6'
VERSION = '0.1.7'
2 changes: 1 addition & 1 deletion crudbuilder/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ def test_separate_createupdateform(self):
def test_custom_queryset(self):
def custom_queryset(self, request, **kwargs):
return self.model.objects.all()
setattr(TestModelCrud, 'custom_queryset', custom_queryset)
setattr(TestModelCrud, 'custom_queryset', classmethod(custom_queryset))
self.get_list_view()
5 changes: 3 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ Then create the CRUD class for ``Person`` model::
login_required=True
permission_required=True

def custom_queryset(self, request, **kwargs):
@classmethod
def custom_queryset(cls, request, **kwargs):
"""Define your own custom queryset for list view"""
qset = self.model.objects.filter(created_by=request.user)
qset = cls.model.objects.filter(created_by=request.user)
return qset

# permissions = {
Expand Down
10 changes: 6 additions & 4 deletions example/example/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class PersonCrud(BaseCrudBuilder):
# 'create': 'example.person_create'
# }

def custom_queryset(self, request, **kwargs):
return self.model.objects.all()
@classmethod
def custom_queryset(cls, request, **kwargs):
return cls.model.objects.filter(created_by=request.user)


class PersonEmploymentCrud(BaseCrudBuilder):
Expand All @@ -41,5 +42,6 @@ class PersonEmploymentCrud(BaseCrudBuilder):
'update': PersonEmployementUpdateForm
}

def custom_queryset(self, request, **kwargs):
return self.model.objects.filter(medical_allowance=False)
@classmethod
def custom_queryset(cls, request, **kwargs):
return cls.model.objects.filter(medical_allowance=False)

0 comments on commit 5a0e3ad

Please sign in to comment.