Delete CompanyCreate AJAX view

This commit is contained in:
Oliver 2021-06-29 21:20:53 +10:00
parent c25967eff6
commit 170ed37d03
9 changed files with 8 additions and 69 deletions

View File

@ -71,7 +71,7 @@
field: 'manufacturer',
label: '{% trans "New Manufacturer" %}',
title: '{% trans "Create new Manufacturer" %}',
url: "{% url 'manufacturer-create' %}",
//url: "{% url 'manufacturer-create' %}",
},
]
});

View File

@ -71,7 +71,7 @@
field: 'supplier',
label: "{% trans 'New Supplier' %}",
title: "{% trans 'Create new Supplier' %}",
url: "{% url 'supplier-create' %}",
// url: "{% url 'supplier-create' %}",
},
]
});

View File

@ -81,7 +81,7 @@ $('#supplier-create').click(function () {
field: 'supplier',
label: '{% trans "New Supplier" %}',
title: '{% trans "Create new supplier" %}',
url: "{% url 'supplier-create' %}"
// url: "{% url 'supplier-create' %}"
},
]
});

View File

@ -8,7 +8,6 @@ from . import views
company_detail_urls = [
url(r'edit/?', views.CompanyEdit.as_view(), name='company-edit'),
url(r'delete/?', views.CompanyDelete.as_view(), name='company-delete'),
# url(r'orders/?', views.CompanyDetail.as_view(template_name='company/orders.html'), name='company-detail-orders'),
@ -31,11 +30,6 @@ company_detail_urls = [
company_urls = [
url(r'new/supplier/', views.CompanyCreate.as_view(), name='supplier-create'),
url(r'new/manufacturer/', views.CompanyCreate.as_view(), name='manufacturer-create'),
url(r'new/customer/', views.CompanyCreate.as_view(), name='customer-create'),
url(r'new/?', views.CompanyCreate.as_view(), name='company-create'),
url(r'^(?P<pk>\d+)/', include(company_detail_urls)),
url(r'suppliers/', views.CompanyIndex.as_view(), name='supplier-index'),

View File

@ -246,61 +246,6 @@ class CompanyImage(AjaxUpdateView):
}
class CompanyCreate(AjaxCreateView):
"""
View for creating a new Company object
"""
model = Company
context_object_name = 'company'
form_class = EditCompanyForm
ajax_template_name = 'modal_form.html'
permission_required = 'company.add_company'
def get_form_title(self):
url = self.request.path
if url == reverse('supplier-create'):
return _("Create new Supplier")
if url == reverse('manufacturer-create'):
return _('Create new Manufacturer')
if url == reverse('customer-create'):
return _('Create new Customer')
return _('Create new Company')
def get_initial(self):
""" Initial values for the form data """
initials = super().get_initial().copy()
url = self.request.path
if url == reverse('supplier-create'):
initials['is_supplier'] = True
initials['is_customer'] = False
initials['is_manufacturer'] = False
elif url == reverse('manufacturer-create'):
initials['is_manufacturer'] = True
initials['is_supplier'] = True
initials['is_customer'] = False
elif url == reverse('customer-create'):
initials['is_customer'] = True
initials['is_manufacturer'] = False
initials['is_supplier'] = False
return initials
def get_data(self):
return {
'success': _("Created new company"),
}
class CompanyDelete(AjaxDeleteView):
""" View for deleting a Company object """

View File

@ -184,7 +184,7 @@ $("#po-create").click(function() {
field: 'supplier',
label: '{% trans "New Supplier" %}',
title: '{% trans "Create new Supplier" %}',
url: '{% url "supplier-create" %}',
// url: '{% url "supplier-create" %}',
}
]
}

View File

@ -186,7 +186,7 @@ $("#so-create").click(function() {
field: 'customer',
label: '{% trans "New Customer" %}',
title: '{% trans "Create new Customer" %}',
url: '{% url "customer-create" %}',
// url: '{% url "customer-create" %}',
}
]
}

View File

@ -51,7 +51,7 @@
field: 'manufacturer',
label: '{% trans "New Manufacturer" %}',
title: '{% trans "Create new manufacturer" %}',
url: "{% url 'manufacturer-create' %}",
// url: "{% url 'manufacturer-create' %}",
}
]
});

View File

@ -49,13 +49,13 @@
field: 'supplier',
label: '{% trans "New Supplier" %}',
title: '{% trans "Create new supplier" %}',
url: "{% url 'supplier-create' %}"
// url: "{% url 'supplier-create' %}"
},
{
field: 'manufacturer',
label: '{% trans "New Manufacturer" %}',
title: '{% trans "Create new manufacturer" %}',
url: "{% url 'manufacturer-create' %}",
// url: "{% url 'manufacturer-create' %}",
}
]
});