Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled validation of determination draft saving #3707

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions hypha/apply/determinations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,11 @@ def __init__(
self.fields[field].disabled = True

if self.draft_button_name in self.data:
for field in self.fields.values():
field.required = False
# A determination must be set for saving a draft,
# this forces outcome to be validated.
unreq_fields = [name for name in self.fields if name != "outcome"]
for name in unreq_fields:
self.fields[name].required = False

if edit:
self.fields.pop("outcome")
Expand All @@ -548,8 +551,8 @@ def save(self, commit=True):
self.instance.outcome = int(
self.cleaned_data[self.instance.determination_field.id]
)
# Need to catch KeyError as outcome field would not exist in case of edit.
except KeyError:
# Need to catch KeyError as outcome field would not exist in case of edit.
pass
self.instance.is_draft = self.draft_button_name in self.data
self.instance.form_data = self.cleaned_data["form_data"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2>{{ value }}</h2>
{% block form_buttons %}
<div class="form__group">
{% if form.draft_button_name %}
<button class="button button--submit button--white" type="submit" name="{{ form.draft_button_name }}" formnovalidate>{% trans "Save draft" %}</button>
<button class="button button--submit button--white" type="submit" name="{{ form.draft_button_name }}">{% trans "Save draft" %}</button>
{% endif %}
<button class="button button--submit button--primary" :disabled="isFormSubmitting" type="submit" name="submit">{% trans "Submit" %}</button>
</div>
Expand Down