- tags = read_tags(tags, allowed=self.categories)
- return Fragment.tagged.with_all(tags).select_related('book')
-
- @classmethod
- def href(cls, fragment):
- """ Returns URI in the API for the fragment. """
-
- return API_BASE + reverse("api_fragment", args=[fragment.book.slug, fragment.anchor])
-
- @classmethod
- def url(cls, fragment):
- """ Returns URL on the site for the fragment. """
-
- return WL_BASE + fragment.get_absolute_url()
-
- @classmethod
- def themes(cls, fragment):
- """ Returns a list of theme tags for the fragment. """
-
- return fragment.tags.filter(category='theme')
-
+ try:
+ tags = read_tags(tags, allowed=self.categories)
+ except ValueError:
+ return rc.NOT_FOUND
+ fragments = Fragment.tagged.with_all(tags).select_related('book')
+ if fragments.exists():
+ return fragments
+ else:
+ return rc.NOT_FOUND