Skip to content

Commit

Permalink
Merge pull request #1006 from fabiobatalha/tk1005
Browse files Browse the repository at this point in the history
Corrigindo bug de apresentação do subject_areas de uma revista na API v1
  • Loading branch information
jamilatta committed Sep 26, 2014
2 parents 7cbc439 + ba0ac42 commit 5e02370
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/dev/journals-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 11 additions & 1 deletion scielomanager/api/resources_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
PressReleaseTranslation,
PressReleaseArticle,
Article,
SubjectCategory,
)

from scielomanager.utils import usercontext
Expand Down Expand Up @@ -160,14 +161,18 @@ 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):
queryset = Sponsor.objects.all()
resource_name = 'sponsors'
allowed_methods = ['get', ]


class UseLicenseResource(ModelResource):
class Meta(ApiKeyAuthMeta):
queryset = UseLicense.objects.all()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions scielomanager/api/tests_resources_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5e02370

Please sign in to comment.