diff --git a/hypha/apply/determinations/templates/determinations/base_determination_form.html b/hypha/apply/determinations/templates/determinations/base_determination_form.html index 9356ae88cfadb8ce55598a33f7732c3b249b0123..fddfcb2d4d16fecb13c37b6f5c80ad366052a7a1 100644 --- a/hypha/apply/determinations/templates/determinations/base_determination_form.html +++ b/hypha/apply/determinations/templates/determinations/base_determination_form.html @@ -19,7 +19,7 @@ {% block determination_information %} {% endblock %} - <form class="form form--with-p-tags" action="" method="post" novalidate> + <form class="form form--with-p-tags" action="" method="post"> {{ form.media }} {% csrf_token %} @@ -45,7 +45,7 @@ {% endfor %} {% block form_buttons %} {% if form.draft_button_name %} - <input class="button button--submit button--top-space button--white" type="submit" value="Save Draft" name="{{ form.draft_button_name }}" /> + <input class="button button--submit button--top-space button--white" type="submit" value="Save Draft" name="{{ form.draft_button_name }}" formnovalidate/> {% endif %} <input class="button button--submit button--top-space button--primary" type="submit" value="Send/Save" name="submit" /> {% endblock %} diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py index b3d5ca4290767d345c2988c18e14b856edf2c625..a38bad9047d54c26e4453d6204df18e841912a16 100644 --- a/hypha/apply/funds/models/applications.py +++ b/hypha/apply/funds/models/applications.py @@ -342,14 +342,14 @@ class RoundBase(WorkflowStreamForm, SubmittableStreamForm): # type: ignore return form_parameters def get_form(self, *args, **kwargs): - form_class = self.get_form_class() + draft = kwargs.pop('draft', False) + form_class = self.get_form_class(draft) submission_id = kwargs.pop('submission_id', None) if submission_id: form_params = self.get_form_parameters(submission_id=submission_id) else: form_params = self.get_form_parameters() form_params.update(kwargs) - return form_class(*args, **form_params) def serve(self, request, *args, **kwargs): @@ -358,7 +358,7 @@ class RoundBase(WorkflowStreamForm, SubmittableStreamForm): # type: ignore copy_open_submission = request.GET.get('open_call_submission') if request.method == 'POST': draft = request.POST.get('draft', False) - form = self.get_form(request.POST, request.FILES, page=self, user=request.user) + form = self.get_form(request.POST, request.FILES, page=self, user=request.user, draft=draft) if form.is_valid(): form_submission = self.process_form_submission(form, draft=draft) diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html index c7060b015bb1e5816f9826179fad360572f03ede..d9d38d521b083d06ae6465c1bf4b6a4b22ff0656 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html @@ -24,7 +24,7 @@ {% endif %} {% endfor %} {% for button_name, button_type, button_value in buttons %} - <input class="button button--submit button--top-space button--{{ button_type }}" type="submit" name="{{ button_name }}" value="{{ button_value }}" /> + <input class="button button--submit button--top-space button--{{ button_type }}" type="submit" name="{{ button_name }}" value="{{ button_value }}"{% if button_value == 'Save Draft' %} formnovalidate{% endif %}/> {% endfor %} </form> </div> diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index a7fec42b8d8222f887ebb4f8d7c2752c83427748..70229bcc0965e633d6fd38912510943e6589db5c 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -887,7 +887,8 @@ class BaseSubmissionEditView(UpdateView): return super().get_context_data(buttons=self.buttons(), **kwargs) def get_form_class(self): - return self.object.get_form_class() + draft = self.request.POST.get('save', False) + return self.object.get_form_class(draft) @method_decorator(staff_required, name='dispatch') diff --git a/hypha/apply/review/templates/review/review_form.html b/hypha/apply/review/templates/review/review_form.html index d87628e529054e85f16838a6800b6eb3c2d450f9..8e81f160ebb13f72dd09315ebf80f35186ac8966 100644 --- a/hypha/apply/review/templates/review/review_form.html +++ b/hypha/apply/review/templates/review/review_form.html @@ -12,7 +12,7 @@ <div class="wrapper wrapper--medium wrapper--inner-space-medium"> {% if not has_submitted_review %} - <form class="form form--with-p-tags form--scoreable" action="" method="post" novalidate> + <form class="form form--with-p-tags form--scoreable" action="" method="post"> {{ form.media }} {% csrf_token %} @@ -37,7 +37,7 @@ {% endif %} {% endfor %} {% if not object.id or object.is_draft %} - <input class="button button--submit button--top-space button--white" type="submit" value="Save Draft" name="{{ form.draft_button_name }}" /> + <input class="button button--submit button--top-space button--white" type="submit" value="Save Draft" name="{{ form.draft_button_name }}" formnovalidate/> {% endif %} <input class="button button--submit button--top-space button--primary" type="submit" value="Submit" name="submit" /> </form> diff --git a/hypha/apply/stream_forms/models.py b/hypha/apply/stream_forms/models.py index 890b150bb9ff22fd24310771adad36d4d7717e32..ad222f3ea21bba66e802dab6f584f1730abf9773 100644 --- a/hypha/apply/stream_forms/models.py +++ b/hypha/apply/stream_forms/models.py @@ -3,6 +3,8 @@ from collections import OrderedDict from wagtail.contrib.forms.models import AbstractForm +from hypha.apply.funds.blocks import ApplicationMustIncludeFieldBlock + from .blocks import ( FormFieldBlock, GroupToggleBlock, @@ -42,7 +44,7 @@ class BaseStreamForm: def get_defined_fields(self): return self.form_fields - def get_form_fields(self): + def get_form_fields(self, draft=False): form_fields = OrderedDict() field_blocks = self.get_defined_fields() group_counter = 1 @@ -50,9 +52,10 @@ class BaseStreamForm: for struct_child in field_blocks: block = struct_child.block struct_value = struct_child.value - if isinstance(block, FormFieldBlock): field_from_block = block.get_field(struct_value) + if draft and not issubclass(block.__class__, ApplicationMustIncludeFieldBlock): + field_from_block.required = False field_from_block.help_link = struct_value.get('help_link') field_from_block.group_number = group_counter if is_in_group else 1 if isinstance(block, GroupToggleBlock) and not is_in_group: @@ -74,8 +77,8 @@ class BaseStreamForm: return form_fields - def get_form_class(self): - return type('WagtailStreamForm', (self.submission_form_class,), self.get_form_fields()) + def get_form_class(self, draft=False): + return type('WagtailStreamForm', (self.submission_form_class,), self.get_form_fields(draft)) class AbstractStreamForm(BaseStreamForm, AbstractForm):