mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
Allow file and image fields
- Use FormData class - Replace existing Company image upload form
This commit is contained in:
@ -157,10 +157,22 @@
|
||||
{% endif %}
|
||||
|
||||
$("#company-image-upload").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'company-image' company.id %}",
|
||||
|
||||
constructForm(
|
||||
'{% url "api-company-detail" company.pk %}',
|
||||
{
|
||||
reload: true
|
||||
method: 'PATCH',
|
||||
fields: {
|
||||
image: {},
|
||||
},
|
||||
title: '{% trans "Upload Image" %}',
|
||||
onSuccess: function(data) {
|
||||
if (data.image) {
|
||||
$('#company-image').attr('src', data.image);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -20,7 +20,6 @@ company_detail_urls = [
|
||||
url(r'^sales-orders/', views.CompanyDetail.as_view(template_name='company/sales_orders.html'), name='company-detail-sales-orders'),
|
||||
url(r'^notes/', views.CompanyNotes.as_view(), name='company-notes'),
|
||||
|
||||
url(r'^thumbnail/', views.CompanyImage.as_view(), name='company-image'),
|
||||
url(r'^thumb-download/', views.CompanyImageDownloadFromURL.as_view(), name='company-image-download'),
|
||||
|
||||
# Any other URL
|
||||
|
@ -232,20 +232,6 @@ class CompanyImageDownloadFromURL(AjaxUpdateView):
|
||||
)
|
||||
|
||||
|
||||
class CompanyImage(AjaxUpdateView):
|
||||
""" View for uploading an image for the Company """
|
||||
model = Company
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = _('Update Company Image')
|
||||
form_class = CompanyImageForm
|
||||
permission_required = 'company.change_company'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': _('Updated company image'),
|
||||
}
|
||||
|
||||
|
||||
class CompanyDelete(AjaxDeleteView):
|
||||
""" View for deleting a Company object """
|
||||
|
||||
|
Reference in New Issue
Block a user