Skip to content

Commit

Permalink
Merge branch 'release/0.118.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Aug 3, 2017
2 parents f814002 + 88d4371 commit 2cfd6fd
Show file tree
Hide file tree
Showing 40 changed files with 3,841 additions and 3,177 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
*********

0.118.0 (2017-08-03)
====================

- Support for custom taxonomies.

0.117.0 (2017-07-13)
====================
- Profile: long Personal Website URLs run over in cause problems in display #5270
Expand Down
1 change: 1 addition & 0 deletions api/base/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
'2.3',
'2.4',
'2.5',
'2.6',
),
'DEFAULT_FILTER_BACKENDS': ('api.base.filters.ODMOrderingFilter',),
'DEFAULT_PAGINATION_CLASS': 'api.base.pagination.JSONAPIPagination',
Expand Down
15 changes: 15 additions & 0 deletions api/base/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,18 @@ def reverse(self, viewname, args=None, kwargs=None, request=None, format=None, *
return utils.absolute_reverse(
viewname, query_kwargs=query_kwargs, args=args, kwargs=kwargs
)

class DeprecatedEndpointMixin(object):
@property
def min_version(self):
return '2.0'

@property
def max_version(self):
raise NotImplementedError('Deprecated endpoints must define `max_version`')

def determine_version(self, request, *args, **kwargs):
version, scheme = super(DeprecatedEndpointMixin, self).determine_version(request, *args, **kwargs)
if utils.is_deprecated(version, self.min_version, self.max_version):
raise drf_exceptions.NotFound()
return version, scheme
5 changes: 5 additions & 0 deletions api/preprint_providers/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class PreprintProviderSerializer(JSONAPISerializer):
related_view_kwargs={'provider_id': '<_id>'}
)

highlighted_taxonomies = RelationshipField(
related_view='preprint_providers:highlighted-taxonomy-list',
related_view_kwargs={'provider_id': '<_id>'}
)

licenses_acceptable = RelationshipField(
related_view='preprint_providers:license-list',
related_view_kwargs={'provider_id': '<_id>'}
Expand Down
5 changes: 3 additions & 2 deletions api/preprints/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def update(self, preprint, validated_data):

def set_field(self, func, val, auth, save=False):
try:
func(val, auth, save=save)
func(val, auth)
except PermissionsError as e:
raise exceptions.PermissionDenied(detail=e.message)
except ValueError as e:
Expand Down Expand Up @@ -246,7 +246,8 @@ def create(self, validated_data):
raise Conflict('Only one preprint per provider can be submitted for a node. Check `meta[existing_resource_id]`.', meta={'existing_resource_id': conflict._id})

preprint = PreprintService(node=node, provider=provider)
self.set_field(preprint.set_primary_file, primary_file, auth, save=True)
self.set_field(preprint.set_primary_file, primary_file, auth)
preprint.save()
preprint.node._has_abandoned_preprint = True
preprint.node.save()

Expand Down
2 changes: 2 additions & 0 deletions api/taxonomies/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class TaxonomySerializer(JSONAPISerializer):
)
parent = TaxonomyField()
child_count = ser.IntegerField()
share_title = ser.CharField(source='provider.share_title', read_only=True)
path = ser.CharField(read_only=True)

links = LinksField({
'parents': 'get_parent_urls',
Expand Down
4 changes: 3 additions & 1 deletion api/taxonomies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from api.base.filters import ODMFilterMixin
from api.base.pagination import NoMaxPageSizePagination
from api.base import permissions as base_permissions
from api.base.versioning import DeprecatedEndpointMixin
from api.taxonomies.serializers import TaxonomySerializer
from osf.models import Subject
from framework.auth.oauth_scopes import CoreScopes


class TaxonomyList(JSONAPIBaseView, generics.ListAPIView, ODMFilterMixin):
class TaxonomyList(DeprecatedEndpointMixin, JSONAPIBaseView, generics.ListAPIView, ODMFilterMixin):
'''[BePress taxonomy subject](https://www.bepress.com/wp-content/uploads/2016/12/Digital-Commons-Disciplines-taxonomy-2017-01.pdf) instance. *Read-only*
##Note
Expand Down Expand Up @@ -47,6 +48,7 @@ class TaxonomyList(JSONAPIBaseView, generics.ListAPIView, ODMFilterMixin):
pagination_class = NoMaxPageSizePagination
view_category = 'taxonomies'
view_name = 'taxonomy-list'
max_version = '2.5'

# overrides ListAPIView
def get_default_odm_query(self):
Expand Down
Loading

0 comments on commit 2cfd6fd

Please sign in to comment.