mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve form management when possible part matches are found
- Display the checkbox always - Display a warning message above the form
This commit is contained in:
parent
7b4584ba2f
commit
b3cca1d851
@ -5,7 +5,8 @@
|
||||
{{ block.super }}
|
||||
|
||||
{% if matches %}
|
||||
<b>Matching Parts</b>
|
||||
<b>Possible Matching Parts</b>
|
||||
<p>The new part may be a duplicate of these existing parts:</p>
|
||||
<ul class='list-group'>
|
||||
{% for match in matches %}
|
||||
<li class='list-group-item list-group-item-condensed'>
|
||||
|
@ -191,13 +191,16 @@ class PartCreate(AjaxCreateView):
|
||||
if len(matches) > 0:
|
||||
context['matches'] = matches
|
||||
|
||||
# Enforce display of the checkbox
|
||||
form.fields['confirm_creation'].widget = CheckboxInput()
|
||||
|
||||
# Check if the user has checked the 'confirm_creation' input
|
||||
confirmed = str2bool(request.POST.get('confirm_creation', False))
|
||||
|
||||
if not confirmed:
|
||||
form.fields['confirm_creation'].widget = CheckboxInput()
|
||||
form.errors['confirm_creation'] = ['Possible matches exist - confirm creation of new part']
|
||||
form.non_field_errors = 'Possible matches exist - confirm creation of new part'
|
||||
|
||||
form.pre_form_warning = 'Possible matches exist - confirm creation of new part'
|
||||
valid = False
|
||||
|
||||
data = {
|
||||
|
Loading…
Reference in New Issue
Block a user