Skip to content

Commit

Permalink
Return all version of processess on process endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Nov 21, 2024
1 parent 8b64bbf commit 475b64b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable changes to this project are documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.


==========
Unreleased
==========

Changed
-------
- **BACKWARD INCOMPATIBLE:** Return all version of processess on process
endpoint


===================
41.0.0 - 2024-11-18
===================
Expand Down
20 changes: 20 additions & 0 deletions resolwe/flow/migrations/0032_alter_process_managers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-11-21 16:23

import django.db.models.manager
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("flow", "0031_remove_annotationvalue_uniquetogether_entity_field_and_more"),
]

operations = [
migrations.AlterModelManagers(
name="process",
managers=[
("unversioned_objects", django.db.models.manager.Manager()),
],
),
]
5 changes: 4 additions & 1 deletion resolwe/flow/models/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from resolwe.permissions.models import PermissionObject

from .base import BaseModel
from .base import BaseManagerWithoutVersion, BaseModel
from .data import Data


Expand Down Expand Up @@ -56,6 +56,9 @@ class Meta(BaseModel.Meta):
(SCHEDULING_CLASS_BATCH, "Batch"),
)

#: unversioned object manager
unversioned_objects = BaseManagerWithoutVersion()

#: data type
type = models.CharField(
max_length=100,
Expand Down
10 changes: 10 additions & 0 deletions resolwe/flow/tests/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,16 @@ def test_type(self):
self._check_filter({"type": "data:alignment:bam"}, [self.proc_1])
self._check_filter({"type": "data:expression"}, [self.proc_2])

def test_return_all_versions(self):
new_version = Process.objects.create(
contributor=self.contributor,
type="data:expression:",
category="analyses:",
scheduling_class="IN",
version="3.0.0",
)
self._check_filter({"type": "data:expression"}, [self.proc_2, new_version])

def test_scheduling_class(self):
self._check_filter({"scheduling_class": "BA"}, [self.proc_1])
self._check_filter({"scheduling_class": "IN"}, [self.proc_2])
Expand Down
2 changes: 1 addition & 1 deletion resolwe/flow/views/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProcessViewSet(
"""API view for :class:`Process` objects."""

qs_permission_model = PermissionModel.objects.select_related("user", "group")
queryset = Process.objects.all().select_related("contributor")
queryset = Process.unversioned_objects.all().select_related("contributor")
serializer_class = ProcessSerializer
permission_classes = (get_permissions_class(),)
filterset_class = ProcessFilter
Expand Down

0 comments on commit 475b64b

Please sign in to comment.