Skip to content

Commit

Permalink
Remove questionable show_save_button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jan 23, 2025
1 parent b264eb6 commit af0e421
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
8 changes: 3 additions & 5 deletions course/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,11 +1711,9 @@ def add_buttons_to_form(
flow_session: FlowSession,
permissions: frozenset[str]) -> StyledForm:
from crispy_forms.layout import Submit
show_save_button = getattr(form, "show_save_button", True)
if show_save_button:
form.helper.add_input(
Submit("save", _("Save answer"),
css_class="relate-save-button"))
form.helper.add_input(
Submit("save", _("Save answer"),
css_class="relate-save-button"))

if will_receive_feedback(permissions):
if flow_permission.change_answer in permissions:
Expand Down
3 changes: 0 additions & 3 deletions course/page/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,6 @@ def get_validators(self):
# {{{ rich text

class RichTextAnswerForm(StyledForm):
# FIXME: ugh, this should be a PageBase thing
show_save_button = False

def __init__(self, read_only: bool, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

Expand Down
1 change: 0 additions & 1 deletion course/page/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
# {{{ upload question

class FileUploadForm(StyledForm):
show_save_button = False
uploaded_file = forms.FileField(required=True,
label=gettext_lazy("Uploaded file"))

Expand Down
14 changes: 0 additions & 14 deletions tests/test_flow/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3992,20 +3992,6 @@ def get_form_submit_inputs(self, form):
values = list(dict(inputs).values())
return names, values

def test_not_add_save_button(self):
class MyForm(StyledForm):
show_save_button = False

form = MyForm()

self.mock_will_receive_feedback.return_value = True
flow.add_buttons_to_form(form, self.fpctx, self.flow_session, frozenset())

names, values = self.get_form_submit_inputs(form)
self.assertNotIn("save", names)
self.assertIn("submit", names)
self.assertIn("Submit final answer", values)

def test_add_save_button_by_default(self):
class MyForm(StyledForm):
pass
Expand Down

0 comments on commit af0e421

Please sign in to comment.