'List an Organization\'s Releases
Return a list of releases for a given organization.
:pparam string organization_slug: the organization short name
:qparam string query: this parameter can be used to create a
"starts with" filter for the version.'

@attach_scenarios([list_org_releases_scenario])
def get(self, request, organization):

    query = request.GET.get('query')
    queryset = Release.objects.filter(organization=organization, projects__in=self.get_allowed_projects(request, organization)).select_related('owner')
    if query:
        queryset = queryset.filter(version__istartswith=query)
    queryset = queryset.extra(select={'sort': 'COALESCE(date_released,    date_added)'})
    return self.paginate(request=request, queryset=queryset, order_by='-sort', paginator_cls=OffsetPaginator, on_results=(lambda x: serialize(x, request.user)))
