Skip to content

Commit dd102fe

Browse files
authored
Rename is_launchable to has_budget (#4739)
In preparation for the changes for DIAGNijmegen/rse-roadmap#469, this renames the `is_launchable` property on reader studies to `has_budget`. That describes the property better. With the changes in this pitch, reader studies will still be launchable for editors even when they are out of budget.
1 parent 7a0bf2f commit dd102fe

10 files changed

Lines changed: 30 additions & 25 deletions

File tree

app/grandchallenge/components/templates/components/civ_set_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ <h4>{{ object.pk }}</h4>
2828
<p>
2929
<button class="btn btn-primary"
3030
{% if object.base_object|model_name == base_model_options.READER_STUDY %}
31-
{% if object.base_object.is_launchable %}
31+
{% if object.base_object.has_budget %}
3232
{% workstation_session_control_data workstation=object.base_object.workstation context_object=object display_set=object config=object.base_object.workstation_config %}
3333
{% else %}
34-
disabled title="Reader study cannot be launched"
34+
disabled title="Reader study is out of budget and cannot be launched"
3535
{% endif %}
3636
{% elif object.base_object|model_name == base_model_options.ARCHIVE %}
3737
{% workstation_session_control_data workstation=object.base_object.workstation context_object=object archive_item=object config=object.base_object.workstation_config %}

app/grandchallenge/components/templates/components/civ_set_row.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
{% if object.base_object.workstation %}
5959
<button class="btn btn-primary btn-sm"
6060
{% if object.base_object|model_name == base_model_options.READER_STUDY %}
61-
{% if object.base_object.is_launchable %}
61+
{% if object.base_object.has_budget %}
6262
{% workstation_session_control_data workstation=object.base_object.workstation context_object=object display_set=object config=object.base_object.workstation_config %}
6363
{% else %}
64-
disabled title="Reader study cannot be launched"
64+
disabled title="Reader study is out of budget and cannot be launched"
6565
{% endif %}
6666
{% elif object.base_object|model_name == base_model_options.ARCHIVE %}
6767
{% workstation_session_control_data workstation=object.base_object.workstation context_object=object archive_item=object config=object.base_object.workstation_config %}

app/grandchallenge/reader_studies/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ def credits_consumed(self):
924924
return ceil(total)
925925

926926
@property
927-
def is_launchable(self):
927+
def has_budget(self):
928928
return (
929929
self.max_credits is None
930930
or self.credits_consumed < self.max_credits

app/grandchallenge/reader_studies/templates/reader_studies/readerstudy_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h2>{{ object.title }}</h2>
122122
{% endif %}
123123

124124
{% if "read_readerstudy" in readerstudy_perms %}
125-
{% if object.is_launchable %}
125+
{% if object.has_budget %}
126126
<p>
127127
<button class="btn btn-primary" {% workstation_session_control_data workstation=object.workstation context_object=object reader_study=object %}>
128128
<i class="fas fa-eye"></i> Launch this Reader Study

app/grandchallenge/reader_studies/templates/reader_studies/readerstudy_progress.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ <h2>Users Progress for {{ reader_study.title }}</h2>
5454
<div class="col-6 col-md-3 p-1">
5555
<div class="d-flex justify-content-md-end justify-content-start align-items-center">
5656
<button class="btn btn-primary"
57-
{% if reader_study.is_launchable %}
57+
{% if reader_study.has_budget %}
5858
{% workstation_session_control_data workstation=reader_study.workstation context_object=reader_study reader_study=reader_study user=user.obj %}
5959
{% else %}
60-
disabled title="Reader study cannot be launched"
60+
disabled title="Reader study is out of budget and cannot be launched"
6161
{% endif %}
6262
>
6363
<i class="fa fa-eye"></i> View User's Answers
@@ -81,7 +81,7 @@ <h2>Users Progress for {{ reader_study.title }}</h2>
8181
</div>
8282
</div>
8383
</li>
84-
{% empty %}
84+
{% empty %}
8585
<li class="list-group-item">
8686
No-one has answered any questions in this reader study.
8787
</li>
@@ -110,7 +110,8 @@ <h5 class="modal-title" id="warningModalLabel"></h5>
110110
data-dismiss="modal">Cancel
111111
</button>
112112
<button type="button" class="btn btn-danger"
113-
id="proceed" data-baseurl="{{ reader_study.get_absolute_url }}" data-csrf="{{ csrf_token }}">
113+
id="proceed" data-baseurl="{{ reader_study.get_absolute_url }}"
114+
data-csrf="{{ csrf_token }}">
114115
<i class="fa fa-trash"></i> <span class="modal-action"></span>
115116
</button>
116117
</div>

app/grandchallenge/reader_studies/templates/reader_studies/readerstudy_statistics.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ <h2>Statistics per case</h2>
5151
{% get_ground_truth object entry.id question as ground_truth %}
5252
<td>{{ ground_truth }}</td>
5353
{% endfor %}
54-
<td data-order="{{ object.is_launchable }}">
54+
<td data-order="{{ object.has_budget }}">
5555
<button class="btn btn-primary badge badge-primary"
56-
{% if object.is_launchable %}
56+
{% if object.has_budget %}
5757
{% workstation_session_control_data workstation=object.workstation context_object=object display_set=entry reader_study=object %} title="Open in viewer"
5858
{% else %}
59-
disabled title="Reader study cannot be launched"
59+
disabled title="Reader study is out of budget and cannot be launched"
6060
{% endif %}
6161
>
6262
<i class="fa fa-eye"></i>

app/grandchallenge/workstations/forms.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def __init__(self, *args, reader_study, **kwargs):
6868
self.fields["ping_times"].required = False
6969

7070
def clean(self):
71-
if self.__reader_study and not self.__reader_study.is_launchable:
72-
raise ValidationError("Reader study cannot be launched.")
71+
if self.__reader_study and not self.__reader_study.has_budget:
72+
raise ValidationError(
73+
"Reader study is out of budget and cannot be launched."
74+
)
7375
return super().clean()
7476

7577
class Meta:
@@ -98,8 +100,10 @@ def __init__(self, *args, reader_study, user, workstation, **kwargs):
98100
]
99101

100102
def clean(self):
101-
if self.__reader_study and not self.__reader_study.is_launchable:
102-
raise ValidationError("Reader study cannot be launched.")
103+
if self.__reader_study and not self.__reader_study.has_budget:
104+
raise ValidationError(
105+
"Reader study is out of budget and cannot be launched."
106+
)
103107

104108
cleaned_data = super().clean()
105109

app/tests/reader_studies_tests/test_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,10 +1249,10 @@ def test_answer_score_calculation():
12491249

12501250

12511251
@pytest.mark.django_db
1252-
def test_reader_study_not_launchable_when_max_credits_consumed():
1252+
def test_reader_study_out_of_budget_when_max_credits_consumed():
12531253
reader_study = ReaderStudyFactory(max_credits=100)
12541254

1255-
assert reader_study.is_launchable
1255+
assert reader_study.has_budget
12561256

12571257
session_utilization = SessionUtilizationFactory(
12581258
duration=timedelta(hours=1)
@@ -1262,7 +1262,7 @@ def test_reader_study_not_launchable_when_max_credits_consumed():
12621262
assert reader_study.session_utilizations.count() == 1
12631263
assert reader_study.session_utilizations.first().credits_consumed == 500
12641264
assert reader_study.credits_consumed == 500
1265-
assert not reader_study.is_launchable
1265+
assert not reader_study.has_budget
12661266

12671267

12681268
@pytest.mark.django_db

app/tests/reader_studies_tests/test_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,14 +1196,14 @@ def test_leaderboard_user_visibility(client):
11961196

11971197

11981198
@pytest.mark.django_db
1199-
def test_reader_study_launch_disabled_when_not_launchable(client):
1199+
def test_reader_study_launch_disabled_when_out_of_budget(client):
12001200
reader_study = ReaderStudyFactory()
12011201

12021202
editor, reader = UserFactory.create_batch(2)
12031203
reader_study.add_editor(editor)
12041204
reader_study.add_reader(reader)
12051205

1206-
assert reader_study.is_launchable
1206+
assert reader_study.has_budget
12071207

12081208
for usr in [reader, editor]:
12091209
response = get_view_for_user(
@@ -1219,7 +1219,7 @@ def test_reader_study_launch_disabled_when_not_launchable(client):
12191219
reader_study.max_credits = 0
12201220
reader_study.save()
12211221

1222-
assert not reader_study.is_launchable
1222+
assert not reader_study.has_budget
12231223

12241224
for usr in [reader, editor]:
12251225
response = get_view_for_user(

app/tests/workstations_tests/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def test_session_create_reader_study_with_algorithm_implementation_skip_active_e
616616

617617

618618
@pytest.mark.django_db
619-
def test_session_create_reader_study_not_launchable(client):
619+
def test_session_create_reader_study_out_of_budget(client):
620620
user = UserFactory()
621621
ws = WorkstationFactory()
622622
WorkstationImageFactory(
@@ -630,7 +630,7 @@ def test_session_create_reader_study_not_launchable(client):
630630
reader_study.readers_group.user_set.add(user)
631631
path, _ = get_workstation_path_and_query_string(reader_study=reader_study)
632632

633-
assert not reader_study.is_launchable
633+
assert not reader_study.has_budget
634634
assert Session.objects.count() == 0
635635

636636
response = get_view_for_user(

0 commit comments

Comments
 (0)