Skip to content

Commit e56afa2

Browse files
committed
Collection latest | concepts/mappings
1 parent 6b38725 commit e56afa2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

core/collections/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from core.collections.utils import is_version_specified
4040
from core.common.constants import (
4141
HEAD, RELEASED_PARAM, PROCESSING_PARAM, OK_MESSAGE,
42-
ACCESS_TYPE_NONE, INCLUDE_RETIRED_PARAM, INCLUDE_INVERSE_MAPPINGS_PARAM, ALL)
42+
ACCESS_TYPE_NONE, INCLUDE_RETIRED_PARAM, INCLUDE_INVERSE_MAPPINGS_PARAM, ALL, LATEST)
4343
from core.common.exceptions import Http409, Http405
4444
from core.common.mixins import (
4545
ConceptDictionaryCreateMixin, ListWithHeadersMixin, ConceptDictionaryUpdateMixin,
@@ -107,6 +107,13 @@ def get_filter_params(self, default_version_to_head=True):
107107
version = query_params.get('version', None) or self.kwargs.get('version', None)
108108
if not version and default_version_to_head:
109109
version = HEAD
110+
if version == LATEST:
111+
version = Collection.find_latest_released_version_by(
112+
{
113+
**{'user__username': self.kwargs.get('user'), 'organization__mnemonic': self.kwargs.get('org')},
114+
'mnemonic': self.kwargs['collection']
115+
})
116+
version = get(version, 'version')
110117

111118
kwargs = self.kwargs.copy()
112119
if self.user_is_self and self.request.user.is_authenticated:

core/common/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def get_kwargs_filters(self): # pylint: disable=too-many-branches
395395
filters['expansion'] = get(version, 'expansion.mnemonic', 'NO_EXPANSION')
396396
filters['collection_url'] = f"{filters['collection_owner_url']}collections/{self.kwargs['collection']}/"
397397
if is_version_specified and self.kwargs['version'] != HEAD:
398-
filters['collection_url'] += f"{self.kwargs['version']}/"
398+
filters['collection_url'] += f"{filters['collection_version'] or self.kwargs['version']}/"
399399
if is_source_specified and not is_version_specified and not self.should_search_latest_repo():
400400
filters['source_version'] = HEAD
401401
return filters

0 commit comments

Comments
 (0)