From 105b93a0e3a4d8373739fe9c0496aaa415a58e97 Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:30:31 +0200 Subject: [PATCH 01/23] added method allowing to remove token --- InvenTree/users/views.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index a4920b717e..207d8a98dc 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -27,15 +27,32 @@ class GetAuthToken(ObtainAuthToken): """ Return authentication token for an authenticated user. """ def post(self, request, *args, **kwargs): + return self.login(request) + + def delete(self, request): + return self.logout(request) + + def login(self, request): serializer = self.serializer_class(data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) - + return Response({ 'token': token.key, 'pk': user.pk, 'username': user.username, 'email': user.email }) + + def logout(self, request): + try: + request.user.auth_token.delete() + except (AttributeError, ObjectDoesNotExist): + pass + + self.logout(request) + + return Response({"success": _("Successfully logged out.")}, + status=status.HTTP_200_OK) From 381e58ab1c3a5f1ec9b6273d3323724b2c376b57 Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:35:00 +0200 Subject: [PATCH 02/23] added import --- InvenTree/users/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index 207d8a98dc..3f8347bf42 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -1,5 +1,6 @@ from rest_framework import generics, permissions from django.contrib.auth.models import User +from django.core.exceptions import ObjectDoesNotExist from .serializers import UserSerializer from rest_framework.authtoken.views import ObtainAuthToken From 5dcfc20d827b7b69f7e565980783d550b7aa156c Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:39:25 +0200 Subject: [PATCH 03/23] test --- InvenTree/users/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index 3f8347bf42..cfe6646115 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -53,7 +53,7 @@ class GetAuthToken(ObtainAuthToken): except (AttributeError, ObjectDoesNotExist): pass - self.logout(request) + logout(request) return Response({"success": _("Successfully logged out.")}, status=status.HTTP_200_OK) From 981884f3683685db3f0199988c16778d61dc385e Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:40:06 +0200 Subject: [PATCH 04/23] test --- InvenTree/users/views.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index cfe6646115..a7d1725ceb 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -53,7 +53,5 @@ class GetAuthToken(ObtainAuthToken): except (AttributeError, ObjectDoesNotExist): pass - logout(request) - return Response({"success": _("Successfully logged out.")}, status=status.HTTP_200_OK) From 3c70c3a29ccfd25365646db481afff1d3008c776 Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:41:46 +0200 Subject: [PATCH 05/23] clean --- InvenTree/users/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index a7d1725ceb..4c7ef295c1 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -53,5 +53,5 @@ class GetAuthToken(ObtainAuthToken): except (AttributeError, ObjectDoesNotExist): pass - return Response({"success": _("Successfully logged out.")}, + return Response({"success": "Successfully logged out."}, status=status.HTTP_200_OK) From 0a6abd21bed0af764d492e33fe69c058849e3daf Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:47:56 +0200 Subject: [PATCH 06/23] fixed responde text --- InvenTree/users/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index 4c7ef295c1..4b4e6259ae 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -6,6 +6,7 @@ from .serializers import UserSerializer from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.authtoken.models import Token from rest_framework.response import Response +from rest_framework import status class UserDetail(generics.RetrieveAPIView): @@ -54,4 +55,4 @@ class GetAuthToken(ObtainAuthToken): pass return Response({"success": "Successfully logged out."}, - status=status.HTTP_200_OK) + status=status.HTTP_202_ACCEPTED) From 8949542baff5e8cb45f798f7eb61bcbeb0452a89 Mon Sep 17 00:00:00 2001 From: Oskar Jaskolski Date: Wed, 28 Aug 2019 12:53:08 +0200 Subject: [PATCH 07/23] fixed response text --- InvenTree/users/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/InvenTree/users/views.py b/InvenTree/users/views.py index 4b4e6259ae..01d9834c69 100644 --- a/InvenTree/users/views.py +++ b/InvenTree/users/views.py @@ -51,8 +51,8 @@ class GetAuthToken(ObtainAuthToken): def logout(self, request): try: request.user.auth_token.delete() + return Response({"success": "Successfully logged out."}, + status=status.HTTP_202_ACCEPTED) except (AttributeError, ObjectDoesNotExist): - pass - - return Response({"success": "Successfully logged out."}, - status=status.HTTP_202_ACCEPTED) + return Response({"error": "Bad request"}, + status=status.HTTP_400_BAD_REQUEST) From 1b8fb4db44487ebcff43259da5740af195b471a4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 3 Sep 2019 23:26:17 +1000 Subject: [PATCH 08/23] Start skeleton for better settings page --- InvenTree/templates/InvenTree/settings.html | 59 ++++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings.html b/InvenTree/templates/InvenTree/settings.html index 2a2bbcc144..dd4e2212bf 100644 --- a/InvenTree/templates/InvenTree/settings.html +++ b/InvenTree/templates/InvenTree/settings.html @@ -8,6 +8,12 @@ InvenTree | Settings

InvenTree Settings


+
+ + + +
+

User Information

@@ -21,20 +27,45 @@ InvenTree | Settings
- - - - - - - - - - - - - -
First Name{{ user.first_name }}
Last Name{{ user.last_name }}
Email Address{{ user.email }}
+
+ + + + + + + + + + + + + +
First Name{{ user.first_name }}
Last Name{{ user.last_name }}
Email Address{{ user.email }}
+
+ +
+ + + + + + + + +
CurrencyValueDefault
+
+ +
+ + + + + + + +
NameUnits
+
{% endblock %} From 27878d2d8d636da22d7fce80f285dcbb046a1fb2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 18:02:03 +1000 Subject: [PATCH 09/23] Split settings into multiple pages - Tab style navigation --- InvenTree/InvenTree/static/css/inventree.css | 22 +++++ InvenTree/InvenTree/urls.py | 12 ++- InvenTree/templates/InvenTree/settings.html | 97 ------------------- .../InvenTree/settings/currency.html | 9 ++ .../templates/InvenTree/settings/part.html | 9 ++ .../InvenTree/settings/settings.html | 32 ++++++ .../templates/InvenTree/settings/tabs.html | 11 +++ .../templates/InvenTree/settings/user.html | 59 +++++++++++ 8 files changed, 153 insertions(+), 98 deletions(-) delete mode 100644 InvenTree/templates/InvenTree/settings.html create mode 100644 InvenTree/templates/InvenTree/settings/currency.html create mode 100644 InvenTree/templates/InvenTree/settings/part.html create mode 100644 InvenTree/templates/InvenTree/settings/settings.html create mode 100644 InvenTree/templates/InvenTree/settings/tabs.html create mode 100644 InvenTree/templates/InvenTree/settings/user.html diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 321d9e1cf4..1412b99bac 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -198,6 +198,28 @@ margin-bottom: 20px; } +.settings-container { + width: 80%; + padding: 15px; +} + +.settings-nav { + height: 100%; + width: 160px; + position: fixed; + z-index: 1; + //top: 0; + //left: 0; + overflow-x: hidden; + padding-top: 20px; + padding-right: 25px; +} + +.settings-content { + margin-left: 175px; + padding: 0px 10px; +} + .breadcrump { margin-bottom: 5px; } diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 11f4a4eda5..3c473a5189 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -53,6 +53,16 @@ apipatterns = [ url(r'^$', InfoView.as_view(), name='inventree-info'), ] +settings_urls = [ + + url(r'^user/?', SettingsView.as_view(template_name='InvenTree/settings/user.html'), name='settings-user'), + url(r'^currency/?', SettingsView.as_view(template_name='InvenTree/settings/currency.html'), name='settings-currency'), + url(r'^part/?', SettingsView.as_view(template_name='InvenTree/settings/part.html'), name='settings-part'), + + # Catch any other urls + url(r'^.*$', SettingsView.as_view(template_name='InvenTree/settings/settings.html'), name='settings'), +] + urlpatterns = [ url(r'^part/', include(part_urls)), url(r'^supplier-part/', include(supplier_part_urls)), @@ -70,7 +80,7 @@ urlpatterns = [ url(r'^login/', auth_views.LoginView.as_view(), name='login'), url(r'^logout/', auth_views.LogoutView.as_view(template_name='registration/logout.html'), name='logout'), - url(r'^settings/', SettingsView.as_view(), name='settings'), + url(r'^settings/', include(settings_urls)), url(r'^edit-user/', EditUserView.as_view(), name='edit-user'), url(r'^set-password/', SetPasswordView.as_view(), name='set-password'), diff --git a/InvenTree/templates/InvenTree/settings.html b/InvenTree/templates/InvenTree/settings.html deleted file mode 100644 index dd4e2212bf..0000000000 --- a/InvenTree/templates/InvenTree/settings.html +++ /dev/null @@ -1,97 +0,0 @@ -{% extends "base.html" %} - -{% block page_title %} -InvenTree | Settings -{% endblock %} - -{% block content %} -

InvenTree Settings

-
- -
- - - -
- -
-
-

User Information

-
-
-
-
Edit
-
Set Password
-
-
-
- - -
- - - - - - - - - - - - - -
First Name{{ user.first_name }}
Last Name{{ user.last_name }}
Email Address{{ user.email }}
-
- -
- - - - - - - - -
CurrencyValueDefault
-
- -
- - - - - - - -
NameUnits
-
- -{% endblock %} - -{% block js_load %} -{{ block.super }} -{% endblock %} - -{% block js_ready %} -{{ block.super }} - - $("#edit-user").on('click', function() { - launchModalForm( - "{% url 'edit-user' %}", - { - reload: true, - } - ); - }); - - $("#edit-password").on('click', function() { - launchModalForm( - "{% url 'set-password' %}", - { - reload: true, - } - ); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html new file mode 100644 index 0000000000..e895fd6dcd --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -0,0 +1,9 @@ +{% extends "InvenTree/settings/settings.html" %} + +{% block tabs %} +{% include "InvenTree/settings/tabs.html" with tab='currency' %} +{% endblock %} + +{% block settings %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html new file mode 100644 index 0000000000..c64ebb6194 --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -0,0 +1,9 @@ +{% extends "InvenTree/settings/settings.html" %} + +{% block tabs %} +{% include "InvenTree/settings/tabs.html" with tab='part' %} +{% endblock %} + +{% block settings %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html new file mode 100644 index 0000000000..c97e65573e --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% load static %} + +{% block page_title %} +InvenTree | Settings +{% endblock %} + +{% block content %} +

InvenTree Settings

+
+ +
+ +
+ {% block tabs %} + {% include "InvenTree/settings/tabs.html" %} + {% endblock %} +
+ +
+ {% block settings %} + {% endblock %} +
+ +
+ +{% endblock %} + +{% block js_load %} +{{ block.super }} +{% endblock %} diff --git a/InvenTree/templates/InvenTree/settings/tabs.html b/InvenTree/templates/InvenTree/settings/tabs.html new file mode 100644 index 0000000000..5e9b1503a2 --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/tabs.html @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html new file mode 100644 index 0000000000..cd50aad1d3 --- /dev/null +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -0,0 +1,59 @@ +{% extends "InvenTree/settings/settings.html" %} + +{% block tabs %} +{% include "InvenTree/settings/tabs.html" with tab='user' %} +{% endblock %} + +{% block settings %} + +
+
+

User Information

+
+
+
+
Edit
+
Set Password
+
+
+
+ + + + + + + + + + + + + + +
First Name{{ user.first_name }}
Last Name{{ user.last_name }}
Email Address{{ user.email }}
+ +{% endblock %} + +{% block js_ready %} +{{ block.super }} + + $("#edit-user").on('click', function() { + launchModalForm( + "{% url 'edit-user' %}", + { + reload: true, + } + ); + }); + + $("#edit-password").on('click', function() { + launchModalForm( + "{% url 'set-password' %}", + { + reload: true, + } + ); + }); + +{% endblock %} \ No newline at end of file From 89c3ab5e9960bd2177457d7c07b464638a5afcde Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 18:58:37 +1000 Subject: [PATCH 10/23] Formatting --- InvenTree/InvenTree/static/css/inventree.css | 2 +- InvenTree/InvenTree/urls.py | 2 +- InvenTree/templates/InvenTree/settings/settings.html | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 1412b99bac..d37c3550e5 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -199,7 +199,7 @@ } .settings-container { - width: 80%; + width: 90%; padding: 15px; } diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 3c473a5189..ea7b10504c 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -60,7 +60,7 @@ settings_urls = [ url(r'^part/?', SettingsView.as_view(template_name='InvenTree/settings/part.html'), name='settings-part'), # Catch any other urls - url(r'^.*$', SettingsView.as_view(template_name='InvenTree/settings/settings.html'), name='settings'), + url(r'^.*$', SettingsView.as_view(template_name='InvenTree/settings/user.html'), name='settings'), ] urlpatterns = [ diff --git a/InvenTree/templates/InvenTree/settings/settings.html b/InvenTree/templates/InvenTree/settings/settings.html index c97e65573e..dab7ec277b 100644 --- a/InvenTree/templates/InvenTree/settings/settings.html +++ b/InvenTree/templates/InvenTree/settings/settings.html @@ -7,11 +7,11 @@ InvenTree | Settings {% endblock %} {% block content %} -

InvenTree Settings

-
-
+

InvenTree Settings

+
+
{% block tabs %} {% include "InvenTree/settings/tabs.html" %} From 9726ea4f99185b329a768bcbad1a8c822e04dd18 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:18:18 +1000 Subject: [PATCH 11/23] Add serializer / API for currency objects --- InvenTree/InvenTree/urls.py | 2 ++ InvenTree/common/api.py | 35 +++++++++++++++++++++++++++++++++ InvenTree/common/serializers.py | 22 +++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 InvenTree/common/api.py create mode 100644 InvenTree/common/serializers.py diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index ea7b10504c..bb400af615 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -19,6 +19,7 @@ from stock.urls import stock_urls from build.urls import build_urls from order.urls import order_urls +from common.api import common_api_urls from part.api import part_api_urls, bom_api_urls from company.api import company_api_urls from stock.api import stock_api_urls @@ -39,6 +40,7 @@ from users.urls import user_urls admin.site.site_header = "InvenTree Admin" apipatterns = [ + url(r'^common/', include(common_api_urls)), url(r'^part/', include(part_api_urls)), url(r'^bom/', include(bom_api_urls)), url(r'^company/', include(company_api_urls)), diff --git a/InvenTree/common/api.py b/InvenTree/common/api.py new file mode 100644 index 0000000000..6da2f98472 --- /dev/null +++ b/InvenTree/common/api.py @@ -0,0 +1,35 @@ +""" +Provides a JSON API for common components. +""" + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from rest_framework import permissions, generics + +from django.conf.urls import url + +from .models import Currency +from .serializers import CurrencySerializer + + +class CurrencyList(generics.ListCreateAPIView): + """ API endpoint for accessing a list of Currency objects. + + - GET: Return a list of Currencies + - POST: Create a new currency + """ + + queryset = Currency.objects.all() + serializer_class = CurrencySerializer + + permission_classes = [ + permissions.IsAuthenticated, + ] + + ordering_fields = ['name', 'value'] + + +common_api_urls = [ + url(r'^currency/?$', CurrencyList.as_view(), name='api-currency-list'), +] diff --git a/InvenTree/common/serializers.py b/InvenTree/common/serializers.py new file mode 100644 index 0000000000..73b4da8adf --- /dev/null +++ b/InvenTree/common/serializers.py @@ -0,0 +1,22 @@ +""" +JSON serializers for common components +""" + +from .models import Currency + +from InvenTree.serializers import InvenTreeModelSerializer + + +class CurrencySerializer(InvenTreeModelSerializer): + """ Serializer for Currency object """ + + class Meta: + model = Currency + fields = [ + 'pk', + 'symbol', + 'suffix', + 'description', + 'value', + 'base' + ] From 873faee040237f491b3c015321920f7b995690a7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:23:58 +1000 Subject: [PATCH 12/23] Display currency list under currency settings page --- InvenTree/InvenTree/static/css/inventree.css | 6 +++ .../InvenTree/settings/currency.html | 45 +++++++++++++++++++ .../templates/InvenTree/settings/tabs.html | 6 +-- .../templates/InvenTree/settings/user.html | 18 ++++---- 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index d37c3550e5..2f54a50219 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -88,6 +88,12 @@ width: 100%; } +.basecurrency { + color: #050; + font-style: italic; + font-weight: bold; +} + .bomselect { max-width: 250px; } diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index e895fd6dcd..662df702aa 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -6,4 +6,49 @@ {% block settings %} + +
+{% endblock %} + +{% block js_ready %} +{{ block.super }} + + $("#currency-table").bootstrapTable({ + url: "{% url 'api-currency-list' %}", + sortable: true, + search: true, + formatNoMatches: function() { return "No currencies found"; }, + rowStyle: function(row, index) { + if (row.base) { + return {classes: 'basecurrency'}; + } else { + return {}; + } + }, + columns: [ + { + field: 'pk', + title: 'ID', + visible: false, + }, + { + field: 'symbol', + title: 'Symbol', + }, + { + field: 'suffix', + title: 'Currency', + }, + { + field: 'description', + title: 'Description', + }, + { + field: 'value', + title: 'Value', + } + ] + }); + + {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/tabs.html b/InvenTree/templates/InvenTree/settings/tabs.html index 5e9b1503a2..78d15dbcfe 100644 --- a/InvenTree/templates/InvenTree/settings/tabs.html +++ b/InvenTree/templates/InvenTree/settings/tabs.html @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index cd50aad1d3..cea588467b 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -7,16 +7,16 @@ {% block settings %}
-
-

User Information

+
+

User Information

+
+
+
+
Edit
+
Set Password
-
-
-
Edit
-
Set Password
-
-
-
+
+
From 6752bdc1c63b3ef09d4cebca34886de992590acb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:28:20 +1000 Subject: [PATCH 13/23] Sort currency API --- InvenTree/common/api.py | 8 ++++++-- InvenTree/templates/InvenTree/settings/currency.html | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/api.py b/InvenTree/common/api.py index 6da2f98472..e1a9a0e3f0 100644 --- a/InvenTree/common/api.py +++ b/InvenTree/common/api.py @@ -5,7 +5,7 @@ Provides a JSON API for common components. # -*- coding: utf-8 -*- from __future__ import unicode_literals -from rest_framework import permissions, generics +from rest_framework import permissions, generics, filters from django.conf.urls import url @@ -27,7 +27,11 @@ class CurrencyList(generics.ListCreateAPIView): permissions.IsAuthenticated, ] - ordering_fields = ['name', 'value'] + filter_backends = [ + filters.OrderingFilter, + ] + + ordering_fields = ['suffix', 'value'] common_api_urls = [ diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 662df702aa..1ca854e64b 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -15,6 +15,9 @@ $("#currency-table").bootstrapTable({ url: "{% url 'api-currency-list' %}", + queryParams: { + ordering: 'suffix' + }, sortable: true, search: true, formatNoMatches: function() { return "No currencies found"; }, @@ -38,14 +41,17 @@ { field: 'suffix', title: 'Currency', + sortable: true, }, { field: 'description', title: 'Description', + sortable: true, }, { field: 'value', title: 'Value', + sortable: true, } ] }); From 13270617b9b656dab07e3dfb57c3ce0ae781be72 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:43:41 +1000 Subject: [PATCH 14/23] Ensure PartParameterTemplate name is unique --- .gitignore | 2 ++ .../part/migrations/0018_auto_20190907_0941.py | 18 ++++++++++++++++++ InvenTree/part/models.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 InvenTree/part/migrations/0018_auto_20190907_0941.py diff --git a/.gitignore b/.gitignore index 3866c30c95..7b9522c3b7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,8 @@ docs/_build # Local static and media file storage (only when running in development mode) InvenTree/media InvenTree/static +media +static # Local config file config.yaml diff --git a/InvenTree/part/migrations/0018_auto_20190907_0941.py b/InvenTree/part/migrations/0018_auto_20190907_0941.py new file mode 100644 index 0000000000..539759146b --- /dev/null +++ b/InvenTree/part/migrations/0018_auto_20190907_0941.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2019-09-07 09:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0017_bomitem_checksum'), + ] + + operations = [ + migrations.AlterField( + model_name='partparametertemplate', + name='name', + field=models.CharField(help_text='Parameter Name', max_length=100, unique=True), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index b13b6632c1..4590a062a8 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1068,7 +1068,7 @@ class PartParameterTemplate(models.Model): """ Return the number of instances of this Parameter Template """ return self.instances.count() - name = models.CharField(max_length=100, help_text='Parameter Name') + name = models.CharField(max_length=100, help_text='Parameter Name', unique=True) units = models.CharField(max_length=25, help_text='Parameter Units', blank=True) From f415e2040e014736139db149a383df970d929df8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:44:10 +1000 Subject: [PATCH 15/23] API endpoint for PartParameter and PartParameterTemplate --- InvenTree/part/api.py | 55 +++++++++++++++++++ InvenTree/part/serializers.py | 26 +++++++++ .../InvenTree/settings/currency.html | 2 + 3 files changed, 83 insertions(+) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index e9c6d32f0d..644c5d32e2 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -21,10 +21,12 @@ from django.urls import reverse import os from .models import Part, PartCategory, BomItem, PartStar +from .models import PartParameter, PartParameterTemplate from .serializers import PartSerializer, BomItemSerializer from .serializers import CategorySerializer from .serializers import PartStarSerializer +from .serializers import PartParameterSerializer, PartParameterTemplateSerializer from InvenTree.views import TreeSerializer from InvenTree.helpers import str2bool @@ -261,6 +263,53 @@ class PartStarList(generics.ListCreateAPIView): ] +class PartParameterTemplateList(generics.ListCreateAPIView): + """ API endpoint for accessing a list of PartParameterTemplate objects. + + - GET: Return list of PartParameterTemplate objects + - POST: Create a new PartParameterTemplate object + """ + + queryset = PartParameterTemplate.objects.all() + serializer_class = PartParameterTemplateSerializer + + permission_classes = [ + permissions.IsAuthenticated, + ] + + filter_backends = [ + filters.OrderingFilter, + ] + + filter_fields = [ + 'name', + ] + + +class PartParameterList(generics.ListCreateAPIView): + """ API endpoint for accessing a list of PartParameter objects + + - GET: Return list of PartParameter objects + - POST: Create a new PartParameter object + """ + + queryset = PartParameter.objects.all() + serializer_class = PartParameterSerializer + + permission_classes = [ + permissions.IsAuthenticated, + ] + + filter_backends = [ + DjangoFilterBackend + ] + + filter_fields = [ + 'part', + 'template', + ] + + class BomList(generics.ListCreateAPIView): """ API endpoint for accessing a list of BomItem objects. @@ -362,12 +411,18 @@ part_star_api_urls = [ url(r'^.*$', PartStarList.as_view(), name='api-part-star-list'), ] +part_param_api_urls = [ + url(r'^template/?$', PartParameterTemplateList.as_view(), name='api-part-param-template-list'), + + url(r'^.*$', PartParameterList.as_view(), name='api-part-param-list'), +] part_api_urls = [ url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'), url(r'^category/', include(cat_api_urls)), url(r'^star/', include(part_star_api_urls)), + url(r'^parameter/', include(part_param_api_urls)), url(r'^(?P\d+)/?', PartDetail.as_view(), name='api-part-detail'), diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index a8d0df5954..bdeead670d 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -8,6 +8,7 @@ from .models import Part, PartStar from .models import PartCategory from .models import BomItem +from .models import PartParameter, PartParameterTemplate from InvenTree.serializers import InvenTreeModelSerializer @@ -174,3 +175,28 @@ class BomItemSerializer(InvenTreeModelSerializer): 'note', 'validated', ] + + +class PartParameterSerializer(InvenTreeModelSerializer): + """ JSON serializers for the PartParameter model """ + + class Meta: + model = PartParameter + fields = [ + 'pk', + 'part', + 'template', + 'data' + ] + + +class PartParameterTemplateSerializer(InvenTreeModelSerializer): + """ JSON serializer for the PartParameterTemplate model """ + + class Meta: + model = PartParameterTemplate + fields = [ + 'pk', + 'name', + 'units', + ] diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 1ca854e64b..0fde7c5c26 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -6,6 +6,8 @@ {% block settings %} +

Currencies

+
{% endblock %} From 94ab7c5b0e70e80a5b2d9926f120ca9962231683 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:45:36 +1000 Subject: [PATCH 16/23] Display list of part parameter templates in the part settings page --- .../templates/InvenTree/settings/part.html | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index c64ebb6194..7a125e8e70 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -5,5 +5,42 @@ {% endblock %} {% block settings %} +

Part Parameter Templates

+ + +
+ +{% endblock %} + +{% block js_ready %} +{{ block.super }} + + $("#param-table").bootstrapTable({ + url: "{% url 'api-part-param-template-list' %}", + queryParams: { + ordering: 'name', + }, + sortable: true, + search: true, + formatNoMatches: function() { return "No part parameter templates found"; }, + columns: [ + { + field: 'pk', + title: 'ID', + visible: false, + }, + { + field: 'name', + title: 'Name', + sortable: 'true', + }, + { + field: 'units', + title: 'Units', + sortable: 'true', + }, + + ] + }); {% endblock %} \ No newline at end of file From 67ea0fa8871b1afb3ac47d3e41718d009f2c1767 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 19:53:47 +1000 Subject: [PATCH 17/23] Create a new part parameter template --- InvenTree/part/api.py | 2 +- InvenTree/templates/InvenTree/settings/part.html | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 644c5d32e2..75c8f3a60f 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -412,7 +412,7 @@ part_star_api_urls = [ ] part_param_api_urls = [ - url(r'^template/?$', PartParameterTemplateList.as_view(), name='api-part-param-template-list'), + url(r'^template/$', PartParameterTemplateList.as_view(), name='api-part-param-template-list'), url(r'^.*$', PartParameterList.as_view(), name='api-part-param-list'), ] diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 7a125e8e70..48588d4809 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -7,7 +7,11 @@ {% block settings %}

Part Parameter Templates

- +
+ +
+ +
{% endblock %} @@ -43,4 +47,12 @@ ] }); + $("#new-param").click(function() { + launchModalForm("{% url 'part-param-template-create' %}", { + success: function() { + $("#param-table").bootstrapTable('refresh'); + }, + }); + }); + {% endblock %} \ No newline at end of file From 31562826f4c8959fc641f85326f831c8d199b3de Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:06:04 +1000 Subject: [PATCH 18/23] Add modal form for creating a new currency --- InvenTree/InvenTree/urls.py | 3 +++ InvenTree/common/forms.py | 24 +++++++++++++++++++ InvenTree/common/urls.py | 15 ++++++++++++ InvenTree/common/views.py | 20 +++++++++++++++- .../InvenTree/settings/currency.html | 13 +++++++++- 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 InvenTree/common/forms.py create mode 100644 InvenTree/common/urls.py diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index bb400af615..d811c0165e 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -14,6 +14,7 @@ from company.urls import company_urls from company.urls import supplier_part_urls from company.urls import price_break_urls +from common.urls import common_urls from part.urls import part_urls from stock.urls import stock_urls from build.urls import build_urls @@ -70,6 +71,8 @@ urlpatterns = [ url(r'^supplier-part/', include(supplier_part_urls)), url(r'^price-break/', include(price_break_urls)), + url(r'^common/', include(common_urls)), + url(r'^stock/', include(stock_urls)), url(r'^company/', include(company_urls)), diff --git a/InvenTree/common/forms.py b/InvenTree/common/forms.py new file mode 100644 index 0000000000..00e6c15c7f --- /dev/null +++ b/InvenTree/common/forms.py @@ -0,0 +1,24 @@ +""" +Django forms for interacting with common objects +""" + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from InvenTree.forms import HelperForm + +from .models import Currency + + +class CurrencyEditForm(HelperForm): + """ Form for creating / editing a currency object """ + + class Meta: + model = Currency + fields = [ + 'symbol', + 'suffix', + 'description', + 'value', + 'base' + ] diff --git a/InvenTree/common/urls.py b/InvenTree/common/urls.py new file mode 100644 index 0000000000..648e65b919 --- /dev/null +++ b/InvenTree/common/urls.py @@ -0,0 +1,15 @@ +""" +URL lookup for common views +""" + +from django.conf.urls import url, include + +from . import views + +currency_urls = [ + url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'), +] + +common_urls = [ + url(r'currency/', include(currency_urls)), +] diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index 60f00ef0ef..ee1164006e 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -1 +1,19 @@ -# Create your views here. +""" +Django views for interacting with common models +""" + +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from InvenTree.views import AjaxCreateView + +from .models import Currency +from .forms import CurrencyEditForm + + +class CurrencyCreate(AjaxCreateView): + """ View for creating a new Currency object """ + + model = Currency + form_class = CurrencyEditForm + ajax_form_title = 'Create new Currency' diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 0fde7c5c26..e91d8456ad 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -8,7 +8,11 @@

Currencies

- +
+ +
+ +
{% endblock %} @@ -58,5 +62,12 @@ ] }); + $("#new-currency").click(function() { + launchModalForm("{% url 'currency-create' %}", { + success: function() { + $("#currency-table").bootstrapTable('refresh'); + }, + }); + }); {% endblock %} \ No newline at end of file From 3188b0ab18a1b3a491b8ed9d38eba65036c9a6d2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:19:35 +1000 Subject: [PATCH 19/23] Edit currency from settings view --- InvenTree/common/urls.py | 3 ++ InvenTree/common/views.py | 18 ++++++++---- .../InvenTree/settings/currency.html | 28 +++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/InvenTree/common/urls.py b/InvenTree/common/urls.py index 648e65b919..6d19e32cf4 100644 --- a/InvenTree/common/urls.py +++ b/InvenTree/common/urls.py @@ -8,6 +8,9 @@ from . import views currency_urls = [ url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'), + + url(r'^(?P\d+)/edit/', views.CurrencyEdit.as_view(), name='currency-edit'), + #url(r'^(?P\d+)/delete/', views.CurrencyDelete.as_view(), name='currency-delete'), ] common_urls = [ diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index ee1164006e..8962965772 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -5,15 +5,23 @@ Django views for interacting with common models # -*- coding: utf-8 -*- from __future__ import unicode_literals -from InvenTree.views import AjaxCreateView +from InvenTree.views import AjaxCreateView, AjaxUpdateView -from .models import Currency -from .forms import CurrencyEditForm +from . import models +from . import forms class CurrencyCreate(AjaxCreateView): """ View for creating a new Currency object """ - model = Currency - form_class = CurrencyEditForm + model = models.Currency + form_class = forms.CurrencyEditForm ajax_form_title = 'Create new Currency' + + +class CurrencyEdit(AjaxUpdateView): + """ View for editing an existing Currency object """ + + model = models.Currency + form_class = forms.CurrencyEditForm + ajax_form_title = 'Edit Currency' diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index e91d8456ad..41c4ab9290 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -58,10 +58,38 @@ field: 'value', title: 'Value', sortable: true, + }, + { + formatter: function(value, row, index, field) { + + var bEdit = ""; + var bDel = ""; + + var html = "
" + bEdit + bDel + "
"; + + return html; + } } ] }); + $("#currency-table").on('click', '.cur-edit', function() { + var button = $(this); + var url = "/common/currency/" + button.attr('pk') + "/edit/"; + + launchModalForm(url, { + success: function() { + $("#currency-table").bootstrapTable('refresh'); + }, + }); + }); + + $("#currency-table").on('click', '.cur-delete', function() { + var button = $(this); + var url = "/common/currency/" + button.attr('pk') + "/delete/"; + + }); + $("#new-currency").click(function() { launchModalForm("{% url 'currency-create' %}", { success: function() { From 55669c79c20824a652c9ab870d0e563d70936ab4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:22:30 +1000 Subject: [PATCH 20/23] Delete a currency from the currency settings view --- InvenTree/common/templates/common/delete_currency.html | 7 +++++++ InvenTree/common/urls.py | 2 +- InvenTree/common/views.py | 10 +++++++++- InvenTree/templates/InvenTree/settings/currency.html | 5 +++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 InvenTree/common/templates/common/delete_currency.html diff --git a/InvenTree/common/templates/common/delete_currency.html b/InvenTree/common/templates/common/delete_currency.html new file mode 100644 index 0000000000..9dfa320668 --- /dev/null +++ b/InvenTree/common/templates/common/delete_currency.html @@ -0,0 +1,7 @@ +{% extends "modal_delete_form.html" %} + +{% block pre_form_content %} + +Are you sure you wish to delete this currency? + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/common/urls.py b/InvenTree/common/urls.py index 6d19e32cf4..b5d6deadde 100644 --- a/InvenTree/common/urls.py +++ b/InvenTree/common/urls.py @@ -10,7 +10,7 @@ currency_urls = [ url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'), url(r'^(?P\d+)/edit/', views.CurrencyEdit.as_view(), name='currency-edit'), - #url(r'^(?P\d+)/delete/', views.CurrencyDelete.as_view(), name='currency-delete'), + url(r'^(?P\d+)/delete/', views.CurrencyDelete.as_view(), name='currency-delete'), ] common_urls = [ diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index 8962965772..9e72818a36 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -5,7 +5,7 @@ Django views for interacting with common models # -*- coding: utf-8 -*- from __future__ import unicode_literals -from InvenTree.views import AjaxCreateView, AjaxUpdateView +from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView from . import models from . import forms @@ -25,3 +25,11 @@ class CurrencyEdit(AjaxUpdateView): model = models.Currency form_class = forms.CurrencyEditForm ajax_form_title = 'Edit Currency' + + +class CurrencyDelete(AjaxDeleteView): + """ View for deleting an existing Currency object """ + + model = models.Currency + ajax_form_title = 'Delete Currency' + ajax_template_name = "common/delete_currency.html" diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 41c4ab9290..460c303d34 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -88,6 +88,11 @@ var button = $(this); var url = "/common/currency/" + button.attr('pk') + "/delete/"; + launchModalForm(url, { + success: function() { + $("#currency-table").bootstrapTable('refresh'); + }, + }); }); $("#new-currency").click(function() { From 42ade0e0b7fa8ec4055ae101849ff6c00b579163 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:28:38 +1000 Subject: [PATCH 21/23] Edit part parameter template from settings view --- InvenTree/part/urls.py | 2 ++ InvenTree/part/views.py | 8 +++++++ .../templates/InvenTree/settings/part.html | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index d1fd1d59fc..7bef1030f0 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -21,6 +21,8 @@ part_attachment_urls = [ part_parameter_urls = [ url('^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'), + url('^template/(?P\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'), + #url('^template/(?P\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'), url('^new/', views.PartParameterCreate.as_view(), name='part-param-create'), url('^(?P\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'), diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 989e2c61f0..bfc44dfcac 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -1446,6 +1446,14 @@ class PartParameterTemplateCreate(AjaxCreateView): ajax_form_title = 'Create Part Parameter Template' +class PartParameterTemplateEdit(AjaxUpdateView): + """ View for editing a PartParameterTemplate """ + + model = PartParameterTemplate + form_class = part_forms.EditPartParameterTemplateForm + ajax_form_title = 'Edit Part Parameter Template' + + class PartParameterCreate(AjaxCreateView): """ View for creating a new PartParameter """ diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 48588d4809..04ae235991 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -43,7 +43,16 @@ title: 'Units', sortable: 'true', }, + { + formatter: function(value, row, index, field) { + var bEdit = ""; + var bDel = ""; + var html = "
" + bEdit + bDel + "
"; + + return html; + } + } ] }); @@ -55,4 +64,16 @@ }); }); + $("#param-table").on('click', '.template-edit', function() { + var button = $(this); + + var url = "/part/parameter/template/" + button.attr('pk') + "/edit/"; + + launchModalForm(url, { + success: function() { + $("#param-table").bootstrapTable('refresh'); + } + }); + }); + {% endblock %} \ No newline at end of file From c45fcb45cfbc9981b1552f4f7a3d5e430b8124a8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:30:51 +1000 Subject: [PATCH 22/23] Delete a part parameter template from the settings view --- InvenTree/part/urls.py | 2 +- InvenTree/part/views.py | 7 +++++++ InvenTree/templates/InvenTree/settings/part.html | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index 7bef1030f0..bbad7634c5 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -22,7 +22,7 @@ part_parameter_urls = [ url('^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'), url('^template/(?P\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'), - #url('^template/(?P\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'), + url('^template/(?P\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'), url('^new/', views.PartParameterCreate.as_view(), name='part-param-create'), url('^(?P\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'), diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index bfc44dfcac..dc2697ee39 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -1454,6 +1454,13 @@ class PartParameterTemplateEdit(AjaxUpdateView): ajax_form_title = 'Edit Part Parameter Template' +class PartParameterTemplateDelete(AjaxDeleteView): + """ View for deleting an existing PartParameterTemplate """ + + model = PartParameterTemplate + ajax_form_title = "Delete Part Parameter Template" + + class PartParameterCreate(AjaxCreateView): """ View for creating a new PartParameter """ diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 04ae235991..dd5ba06c17 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -76,4 +76,16 @@ }); }); + $("#param-table").on('click', '.template-delete', function() { + var button = $(this); + + var url = "/part/parameter/template/" + button.attr('pk') + "/delete/"; + + launchModalForm(url, { + success: function() { + $("#param-table").bootstrapTable('refresh'); + } + }); + }); + {% endblock %} \ No newline at end of file From 446b34248036e7c0578107c4251a92a3c87e4605 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 20:32:22 +1000 Subject: [PATCH 23/23] Add pagination to tables --- InvenTree/templates/InvenTree/settings/currency.html | 2 ++ InvenTree/templates/InvenTree/settings/part.html | 2 ++ 2 files changed, 4 insertions(+) diff --git a/InvenTree/templates/InvenTree/settings/currency.html b/InvenTree/templates/InvenTree/settings/currency.html index 460c303d34..2c7b3dbccb 100644 --- a/InvenTree/templates/InvenTree/settings/currency.html +++ b/InvenTree/templates/InvenTree/settings/currency.html @@ -26,6 +26,8 @@ }, sortable: true, search: true, + pagination: true, + pageSize: 25, formatNoMatches: function() { return "No currencies found"; }, rowStyle: function(row, index) { if (row.base) { diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index dd5ba06c17..87535c7db1 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -26,6 +26,8 @@ }, sortable: true, search: true, + pagination: true, + pageSize: 25, formatNoMatches: function() { return "No part parameter templates found"; }, columns: [ {