Merge branch 'master' into production
commit
350a2a0ba2
|
@ -21,6 +21,7 @@ logger = logging.getLogger(__name__)
|
|||
class EditionResource(ModelResource):
|
||||
work = fields.ForeignKey('regluit.api.resources.WorkResource', 'work')
|
||||
identifiers = fields.ToManyField('regluit.api.resources.IdentifierResource', 'identifiers')
|
||||
ebooks = fields.ToManyField('regluit.api.resources.EbookResource', 'ebooks')
|
||||
class Meta:
|
||||
authentication = ApiKeyAuthentication()
|
||||
queryset = models.Edition.objects.all()
|
||||
|
@ -123,6 +124,21 @@ class SubjectResource(ModelResource):
|
|||
queryset = models.Subject.objects.all()
|
||||
resource_name = 'subject'
|
||||
|
||||
class EbookResource(ModelResource):
|
||||
edition = fields.ToOneField(EditionResource, 'edition')
|
||||
class Meta:
|
||||
authentication = ApiKeyAuthentication()
|
||||
queryset = models.Ebook.objects.all()
|
||||
resource_name = 'ebook'
|
||||
excludes = ['url']
|
||||
|
||||
class PublisherResource(ModelResource):
|
||||
ebooks = fields.ToManyField(EbookResource, attribute=lambda bundle: models.Ebook.objects.filter(edition__publisher_name=bundle.obj.name))
|
||||
class Meta:
|
||||
authentication = ApiKeyAuthentication()
|
||||
queryset = models.Publisher.objects.all()
|
||||
resource_name = 'publisher'
|
||||
|
||||
class FreeResource(ModelResource):
|
||||
def alter_list_data_to_serialize(self, request, data):
|
||||
del data["meta"]["limit"]
|
||||
|
|
|
@ -25,6 +25,8 @@ v1_api.register(resources.CampaignResource())
|
|||
v1_api.register(resources.AuthorResource())
|
||||
v1_api.register(resources.SubjectResource())
|
||||
v1_api.register(resources.FreeResource())
|
||||
v1_api.register(resources.PublisherResource())
|
||||
v1_api.register(resources.EbookResource())
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^help$', ApiHelpView.as_view(), name="api_help"),
|
||||
|
|
Loading…
Reference in New Issue