mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fix form rendering; enable toggling of redirect to imported object
This commit is contained in:
parent
5049c6c0a1
commit
15b2a7eab0
@ -941,7 +941,7 @@ class RearPortTemplateImportForm(ComponentTemplateImportForm):
|
||||
]
|
||||
|
||||
|
||||
class DeviceTypeImportForm(forms.ModelForm):
|
||||
class DeviceTypeImportForm(BootstrapMixin, forms.ModelForm):
|
||||
manufacturer = forms.ModelChoiceField(
|
||||
queryset=Manufacturer.objects.all(),
|
||||
to_field_name='name'
|
||||
|
@ -15,12 +15,13 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form action="" method="post" class="form">
|
||||
<form action="" method="post" class="form form-horizontal">
|
||||
{% csrf_token %}
|
||||
{% render_form form %}
|
||||
<div class="form-group">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" name="_create" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" name="_addanother" class="btn btn-primary">Submit and Import Another</button>
|
||||
{% if return_url %}
|
||||
<a href="{{ return_url }}" class="btn btn-default">Cancel</a>
|
||||
{% endif %}
|
||||
|
@ -440,7 +440,15 @@ class ObjectImportView(GetReturnURLMixin, View):
|
||||
messages.success(request, mark_safe('Imported object: <a href="{}">{}</a>'.format(
|
||||
obj.get_absolute_url(), obj
|
||||
)))
|
||||
return redirect(self.get_return_url(request))
|
||||
|
||||
if '_addanother' in request.POST:
|
||||
return redirect(request.get_full_path())
|
||||
|
||||
return_url = form.cleaned_data.get('return_url')
|
||||
if return_url is not None and is_safe_url(url=return_url, allowed_hosts=request.get_host()):
|
||||
return redirect(return_url)
|
||||
else:
|
||||
return redirect(self.get_return_url(request, obj))
|
||||
|
||||
else:
|
||||
# Replicate model form errors for display
|
||||
|
Loading…
Reference in New Issue
Block a user