diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 38b0a465b1..1fb7959b10 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -13,7 +13,7 @@ from supplier.urls import supplier_urls from build.urls import build_urls -from customer.urls import customer_orders_urls +from customer.urls import customer_urls from django.conf import settings from django.conf.urls.static import static @@ -73,7 +73,7 @@ urlpatterns = [ url(r'^stock/', include(stock_urls)), url(r'^supplier/', include(supplier_urls)), url(r'^build/', include(build_urls)), - url(r'^customer-orders/', include(customer_orders_urls)), + url(r'^customer/', include(customer_urls)), url(r'^admin/', admin.site.urls), url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')), diff --git a/InvenTree/customer/templates/customer/detail.html b/InvenTree/customer/templates/customer/detail.html new file mode 100644 index 0000000000..9cd5dfea90 --- /dev/null +++ b/InvenTree/customer/templates/customer/detail.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/customer/templates/customer_orders/index.html b/InvenTree/customer/templates/customer/index.html similarity index 100% rename from InvenTree/customer/templates/customer_orders/index.html rename to InvenTree/customer/templates/customer/index.html diff --git a/InvenTree/customer/templates/customer/order_detail.html b/InvenTree/customer/templates/customer/order_detail.html new file mode 100644 index 0000000000..9cd5dfea90 --- /dev/null +++ b/InvenTree/customer/templates/customer/order_detail.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/customer/templates/customer_orders/customer_orders_list.html b/InvenTree/customer/templates/customer/order_index.html similarity index 100% rename from InvenTree/customer/templates/customer_orders/customer_orders_list.html rename to InvenTree/customer/templates/customer/order_index.html diff --git a/InvenTree/customer/urls.py b/InvenTree/customer/urls.py index fd734eee51..20132d73e1 100644 --- a/InvenTree/customer/urls.py +++ b/InvenTree/customer/urls.py @@ -2,8 +2,45 @@ from django.conf.urls import url, include from . import views -# URL list for customer orders web interface +customer_detail_urls = [ + # url(r'^edit/?', views.CustomerEdit.as_view(), name='customer-edit'), + # url(r'^delete/?', views.CustomerDelete.as_view(), name='customer-delete'), + + # Everything else + url(r'^.*$', views.CustomerDetail.as_view(), name='customer-detail'), +] + +customer_order_detail_urls = [ + # url(r'^edit/?', views.CustomerOrderEdit.as_view(), name='customer-order-edit'), + # url(r'^delete/?', views.CustomerOrderDelete.as_view(), name='customer-order-delete'), + + # Everything else + url(r'^.*$', views.CustomerOrderDetail.as_view(), name='customer-order-detail'), +] + customer_orders_urls = [ - # Top level order list + # Details of a specific order + # Details of an individual customer + url(r'^(?P[0-9]+)/', include(customer_order_detail_urls)), + + # Create a new customer order + # url(r'new/?', views.CustomerOrderCreate.as_view(), name='customer-order-create'), + + # Everything else url(r'^.*$', views.CustomerOrderIndex.as_view(), name='customer-order-index'), -] \ No newline at end of file +] + +# URL list for customer orders web interface +customer_urls = [ + + # Customer orders (CSO) + url(r'^order/', include(customer_orders_urls)), + + # Details of an individual customer + url(r'^(?P[0-9]+)/', include(customer_detail_urls)), + + # url(r'new/?', views.CustomerCreate.as_view(), name='customer-create'), + + # Top level order list + url(r'^.*$', views.CustomerIndex.as_view(), name='customer-index'), +] diff --git a/InvenTree/customer/views.py b/InvenTree/customer/views.py index 16f9112c5c..aeaaa1d99c 100644 --- a/InvenTree/customer/views.py +++ b/InvenTree/customer/views.py @@ -1,8 +1,33 @@ -from django.views.generic import DetailView, ListView +from django.shortcuts import get_object_or_404 +from django.http import HttpResponseRedirect + +from django.views.generic import DetailView, ListView +from django.views.generic.edit import UpdateView, DeleteView, CreateView + +from .models import Customer, CustomerOrder + + +class CustomerIndex(ListView): + model = Customer + template_name = 'customer/index.html' + context_obect_name = 'customers' -from .models import CustomerOrder class CustomerOrderIndex(ListView): model = CustomerOrder - template_name = 'customer_orders/index.html' + template_name = 'customer/order_index.html' context_object_name = 'customer_orders' + + +class CustomerDetail(DetailView): + model = Customer + template_name = 'customer/detail.html' + queryset = Customer.objects.all() + context_object_name = 'customer' + + +class CustomerOrderDetail(DetailView): + model = CustomerOrder + template_name = 'customer/order_detail.html' + queryset = CustomerOrder.objects.all() + context_object_name = 'order' \ No newline at end of file diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index b98c9fca1a..5121e6c7e8 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -7,6 +7,7 @@ from crispy_forms.layout import Submit from .models import StockLocation, StockItem + class EditStockLocationForm(forms.ModelForm): def __init__(self, *args, **kwargs):