Created
March 5, 2018 20:09
-
-
Save colonelrascals/8bc5bbe0feeca7af8861acf1c9e0fbde to your computer and use it in GitHub Desktop.
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
class BookmarkMetaSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Bookmark | |
fields = '__all__' | |
class BookmarkGroupSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = BookmarkGroup | |
fields = '__all__' | |
class ResourceSerializer(serializers.ModelSerializer): | |
bookmark = BookmarkMetaSerializer(read_only=True) | |
notes = PrivateNoteSerializer(read_only=True, many=True) | |
categories = CategorySerializer(read_only=True, many=True) | |
neighborhoods = NeighborhoodSerializer(read_only=True, many=True) | |
class Meta: | |
model = Resource | |
fields = '__all__' | |
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
class BookmarkGroupView(View): | |
def get(self, request, *args, **kwargs): | |
resources = Resource.objects.filter(bookmarks__user=request.user) | |
resources = get_enriched_resources(request.user, resources) | |
serialized = ResourceSerializer(resources, many=True) | |
context = { | |
"component": "groups.js", | |
"props": { | |
"resources": JSONRenderer().render(serialized.data) | |
} | |
} | |
return render(request, "groups.html", context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment