Skip to content

Commit

Permalink
Fix unique title mixins name and test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvanrun committed May 14, 2024
1 parent 4ac8520 commit 0e146cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/grandchallenge/archives/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
)
from grandchallenge.components.models import ComponentInterface, InterfaceKind
from grandchallenge.core.forms import (
CreateUniqueTitleFormMixin,
PermissionRequestUpdateForm,
SaveFormInitMixin,
UpdateUniqueTitleFormMixin,
UniqueTitleCreateFormMixin,
UniqueTitleUpdateFormMixin,
WorkstationUserFilterMixin,
)
from grandchallenge.core.guardian import get_objects_for_user
Expand Down Expand Up @@ -252,7 +252,7 @@ def unique_title_query(self, *args, **kwargs):

class ArchiveItemCreateForm(
ArchiveItemFormMixin,
CreateUniqueTitleFormMixin,
UniqueTitleCreateFormMixin,
CIVSetCreateFormMixin,
MultipleCIVForm,
):
Expand All @@ -261,7 +261,7 @@ class ArchiveItemCreateForm(

class ArchiveItemUpdateForm(
ArchiveItemFormMixin,
UpdateUniqueTitleFormMixin,
UniqueTitleUpdateFormMixin,
CIVSetUpdateFormMixin,
MultipleCIVForm,
):
Expand Down
4 changes: 2 additions & 2 deletions app/grandchallenge/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Meta:
fields = ("status", "rejection_text")


class CreateUniqueTitleFormMixin:
class UniqueTitleCreateFormMixin:
"""
Form mixing creating an item with a unique title.
Expand Down Expand Up @@ -84,7 +84,7 @@ def unique_title_query(self, title):
return self.model.objects.filter(title=title)


class UpdateUniqueTitleFormMixin(CreateUniqueTitleFormMixin):
class UniqueTitleUpdateFormMixin(UniqueTitleCreateFormMixin):
def unique_title_query(self, *args, **kwargs):
return (
super()
Expand Down
8 changes: 4 additions & 4 deletions app/grandchallenge/reader_studies/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
)
from grandchallenge.components.models import ComponentInterface
from grandchallenge.core.forms import (
CreateUniqueTitleFormMixin,
PermissionRequestUpdateForm,
SaveFormInitMixin,
UpdateUniqueTitleFormMixin,
UniqueTitleCreateFormMixin,
UniqueTitleUpdateFormMixin,
WorkstationUserFilterMixin,
)
from grandchallenge.core.layout import Formset
Expand Down Expand Up @@ -693,7 +693,7 @@ def unique_title_query(self, *args, **kwargs):

class DisplaySetCreateForm(
DisplaySetFormMixin,
CreateUniqueTitleFormMixin,
UniqueTitleCreateFormMixin,
CIVSetCreateFormMixin,
MultipleCIVForm,
):
Expand All @@ -702,7 +702,7 @@ class DisplaySetCreateForm(

class DisplaySetUpdateForm(
DisplaySetFormMixin,
UpdateUniqueTitleFormMixin,
UniqueTitleUpdateFormMixin,
CIVSetUpdateFormMixin,
MultipleCIVForm,
):
Expand Down
12 changes: 6 additions & 6 deletions app/tests/core_tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from django.forms import Form

from grandchallenge.core.forms import (
CreateUniqueTitleFormMixin,
UpdateUniqueTitleFormMixin,
UniqueTitleCreateFormMixin,
UniqueTitleUpdateFormMixin,
)
from grandchallenge.reader_studies.models import DisplaySet
from tests.reader_studies_tests.factories import DisplaySetFactory
Expand All @@ -12,7 +12,7 @@
@pytest.mark.django_db
@pytest.mark.parametrize(
"form_class",
(CreateUniqueTitleFormMixin, UpdateUniqueTitleFormMixin),
(UniqueTitleCreateFormMixin, UniqueTitleUpdateFormMixin),
)
@pytest.mark.parametrize(
"existing_title,new_title,expected_validity",
Expand All @@ -29,8 +29,8 @@ def test_unique_title_mixin(
):

class TestForm(form_class, Form):
class Meta:
model = DisplaySet # For ease, use an existing model with a title

model = DisplaySet # For ease, use an existing model with a title

def __init__(self, *args, instance, **kwargs):
self.instance = instance
Expand All @@ -42,7 +42,7 @@ def __init__(self, *args, instance, **kwargs):

# Adapt for updating
instance = None
if form_class == UpdateUniqueTitleFormMixin:
if form_class == UniqueTitleUpdateFormMixin:
instance = DisplaySetFactory()

form = TestForm(
Expand Down

0 comments on commit 0e146cf

Please sign in to comment.