From ba0ac426530f50d9f67d8cb04e162df927cf955c Mon Sep 17 00:00:00 2001 From: fabiobatalha Date: Fri, 26 Sep 2014 16:23:24 -0300 Subject: [PATCH] =?UTF-8?q?Corrigindo=20bug=20de=20apresenta=C3=A7=C3=A3o?= =?UTF-8?q?=20do=20subject=5Fareas=20de=20uma=20revista=20na=20API=20v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/dev/journals-api.rst | 5 +++++ scielomanager/api/resources_v1.py | 12 +++++++++++- scielomanager/api/tests_resources_v1.py | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/dev/journals-api.rst b/docs/dev/journals-api.rst index d33551b1..46c19a80 100644 --- a/docs/dev/journals-api.rst +++ b/docs/dev/journals-api.rst @@ -187,6 +187,11 @@ Response: "study_areas": [ "Biological Sciences" ], + subject_categories: [ + "Humanities, Multidisciplinary", + "Social Sciences, Interdisciplinary", + "Sociology" + ], "subject_descriptors": "biologia\nbotanica", "succeeding_title": null, "title": "Acta bot\u00c3\u00a1nica mexicana", diff --git a/scielomanager/api/resources_v1.py b/scielomanager/api/resources_v1.py index f61c0c54..14fa633c 100644 --- a/scielomanager/api/resources_v1.py +++ b/scielomanager/api/resources_v1.py @@ -24,6 +24,7 @@ PressReleaseTranslation, PressReleaseArticle, Article, + SubjectCategory, ) from scielomanager.utils import usercontext @@ -160,6 +161,11 @@ class Meta(ApiKeyAuthMeta): resource_name = 'collections' allowed_methods = ['get', ] +class SubjectCategoryResource(ModelResource): + class Meta(ApiKeyAuthMeta): + queryset = SubjectCategory.objects.all() + resource_name = 'subjectcategory' + allowed_methods = ['get', ] class SponsorResource(ModelResource): class Meta(ApiKeyAuthMeta): @@ -167,7 +173,6 @@ class Meta(ApiKeyAuthMeta): resource_name = 'sponsors' allowed_methods = ['get', ] - class UseLicenseResource(ModelResource): class Meta(ApiKeyAuthMeta): queryset = UseLicense.objects.all() @@ -200,6 +205,7 @@ class JournalResource(ModelResource): collections = fields.ManyToManyField(CollectionResource, 'collections') issues = fields.OneToManyField(IssueResource, 'issue_set') sections = fields.OneToManyField(SectionResource, 'section_set') + subject_categories = fields.ManyToManyField(SubjectCategoryResource, 'subject_categories', readonly=True) pub_status_history = fields.ListField(readonly=True) contact = fields.DictField(readonly=True) study_areas = fields.ListField(readonly=True) @@ -275,6 +281,10 @@ def dehydrate_languages(self, bundle): return [language.iso_code for language in bundle.obj.languages.all()] + def dehydrate_subject_categories(self, bundle): + return [subject_category.term + for subject_category in bundle.obj.subject_categories.all()] + def dehydrate_pub_status_history(self, bundle): return [{'date': event.since, 'status': event.status} diff --git a/scielomanager/api/tests_resources_v1.py b/scielomanager/api/tests_resources_v1.py index 774973f3..25ede1ec 100644 --- a/scielomanager/api/tests_resources_v1.py +++ b/scielomanager/api/tests_resources_v1.py @@ -181,6 +181,7 @@ def test_api_v1_datamodel(self): u'editor_name', u'other_previous_title', u'study_areas', + u'subject_categories', u'medline_code', u'is_trashed', u'init_num',