-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(smart_fields): don't compute smart field on null relations (#147)
- Loading branch information
Showing
5 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django_forest.tests.forest.choice import ChoiceForest | ||
from django_forest.tests.forest.question import QuestionForest | ||
from django_forest.tests.forest.place import PlaceForest | ||
|
||
__all__ = ['QuestionForest', 'ChoiceForest'] | ||
__all__ = ['QuestionForest', 'ChoiceForest', 'PlaceForest'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django_forest.tests.models import Place | ||
from django_forest.utils.collection import Collection | ||
|
||
from django_forest.resources.utils.resource import ResourceView | ||
from django_forest.resources.views import ListView, DetailView | ||
|
||
class PlaceForest(Collection): | ||
def load(self): | ||
self.fields = [ | ||
{ | ||
'field': 'restaurant', | ||
"reference": "tests_restaurant.id", | ||
'type': 'String', | ||
"filter": self.filter_restaurant, | ||
"is_filterable": True, | ||
|
||
} | ||
] | ||
|
||
def filter_restaurant(self, obj): | ||
if obj.restaurant: | ||
return obj.restaurant | ||
return None | ||
|
||
Collection.register(PlaceForest, Place) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters