|
|
@@ -1,10 +1,11 @@
|
|
1
|
1
|
from django.shortcuts import render, redirect, get_object_or_404
|
|
2
|
2
|
from django.core.paginator import Paginator
|
|
3
|
3
|
from django.contrib import messages
|
|
4
|
|
-from core.models import Report, AllProductDimensionForInsProcess
|
|
5
|
|
-from core.forms import ReportForm
|
|
6
|
|
-from core.utils import ConfigurableCRUDView, queryFromMaster
|
|
7
|
|
-from .filters import ReportFilter
|
|
|
4
|
+from core.models import Report, AllProductDimensionForInsProcess, CustomerTemplateMapping, \
|
|
|
5
|
+ ProductDrawing
|
|
|
6
|
+from core.forms import ReportForm, CustomerTemplateMappingForm, ProductDrawingForm
|
|
|
7
|
+from core.utils import ConfigurableCRUDView, queryFromMaster, SHEET_NAMES
|
|
|
8
|
+from .filters import ReportFilter, CustomerTemplateFilter, ProductDrawingFilter
|
|
8
|
9
|
from .forms import ExportOptionsForm
|
|
9
|
10
|
from pprint import pprint
|
|
10
|
11
|
|
|
|
@@ -24,6 +25,10 @@ from django.conf import settings
|
|
24
|
25
|
|
|
25
|
26
|
from itertools import chain
|
|
26
|
27
|
|
|
|
28
|
+from django_filters.views import FilterView
|
|
|
29
|
+
|
|
|
30
|
+from django.views.generic import (
|
|
|
31
|
+ ListView,)
|
|
27
|
32
|
|
|
28
|
33
|
def index(request):
|
|
29
|
34
|
reports = Report.objects.all()
|
|
|
@@ -886,18 +891,6 @@ def create_coi_file(lot_no, sheets, user, md):
|
|
886
|
891
|
pprint(f"outputfile = {output_file}")
|
|
887
|
892
|
return report
|
|
888
|
893
|
|
|
889
|
|
-SHEET_NAMES = {
|
|
890
|
|
- 'hardness_out': 'Hardness Out',
|
|
891
|
|
- 'hardness_out_in': 'Hardness Out/In',
|
|
892
|
|
- 'hardness_both_size': 'Hardness Both Size',
|
|
893
|
|
- 'dimension': 'Dimension',
|
|
894
|
|
- 'dimension_app': 'Dimension Appearance',
|
|
895
|
|
- 'dimension_bal_weight': 'Dimension Balance/Weight',
|
|
896
|
|
- 'dim_bal_app_hard': 'Dimension Balance/Appearance/Hardness',
|
|
897
|
|
- 'dim_bal_app_rot_hard': 'Dimension Balance/Appearance/Rotation/Hardness',
|
|
898
|
|
- 'thickness_8_point': 'Thickness 8 Points',
|
|
899
|
|
- 'centering': 'Centering',
|
|
900
|
|
-}
|
|
901
|
894
|
def get_fields(model):
|
|
902
|
895
|
# model_fields = {f.name: f for f in model._meta.get_fields()}
|
|
903
|
896
|
# fields = list(model_fields.values())
|
|
|
@@ -1051,3 +1044,78 @@ def gen_report_view(request):
|
|
1051
|
1044
|
|
|
1052
|
1045
|
|
|
1053
|
1046
|
|
|
|
1047
|
+class CustomerTemplateCRUDView(ConfigurableCRUDView):
|
|
|
1048
|
+ model = CustomerTemplateMapping
|
|
|
1049
|
+ list_template_name = 'report/customer_template_list.html'
|
|
|
1050
|
+ detail_template_name = 'legacy/datacrud_detail.html'
|
|
|
1051
|
+ form_template_name = 'report/customer_template_form.html'
|
|
|
1052
|
+ confirm_delete_template_name = 'legacy/datacrud_confirm_delete.html'
|
|
|
1053
|
+ filterset_class = CustomerTemplateFilter
|
|
|
1054
|
+
|
|
|
1055
|
+ page_title = "Customer Template Mapping"
|
|
|
1056
|
+
|
|
|
1057
|
+ # URL name mappings
|
|
|
1058
|
+ list_url_name = 'report:customer_templates-list'
|
|
|
1059
|
+ create_url_name = 'report:customer_templates-create'
|
|
|
1060
|
+ update_url_name = 'report:customer_templates-update'
|
|
|
1061
|
+ delete_url_name = 'report:customer_templates-delete'
|
|
|
1062
|
+ config_fields = ["id", "customer_name", "template_names", "created_at"]
|
|
|
1063
|
+ config_field_orders = ["id", "customer_name", "template_names", "created_at", "created_by"]
|
|
|
1064
|
+ # config_readonly_fields = ["lot_no"]
|
|
|
1065
|
+ config_edit_fields = None
|
|
|
1066
|
+ ordering = ["-created_at", "-id",]
|
|
|
1067
|
+ form_class = CustomerTemplateMappingForm
|
|
|
1068
|
+
|
|
|
1069
|
+
|
|
|
1070
|
+ def get_list_view(self):
|
|
|
1071
|
+ class ListViewClass(FilterView, ListView):
|
|
|
1072
|
+ model = self.model
|
|
|
1073
|
+ template_name = self.list_template_name
|
|
|
1074
|
+ paginate_by = self.paginate_by
|
|
|
1075
|
+ filterset_class = self.filterset_class
|
|
|
1076
|
+ ordering = self.ordering
|
|
|
1077
|
+
|
|
|
1078
|
+ def get_context_data(inner_self, **kwargs):
|
|
|
1079
|
+ context = super().get_context_data(**kwargs)
|
|
|
1080
|
+ fields = self.get_fields()
|
|
|
1081
|
+ context.update({
|
|
|
1082
|
+ 'fields': [f for f in fields],
|
|
|
1083
|
+ 'sheet_names': SHEET_NAMES,
|
|
|
1084
|
+
|
|
|
1085
|
+ # 'fields': [field for field in self.model._meta.get_fields()],
|
|
|
1086
|
+ 'page_title': self.page_title,
|
|
|
1087
|
+ 'list_url': self.list_url_name,
|
|
|
1088
|
+ 'create_url': self.create_url_name,
|
|
|
1089
|
+ 'update_url': self.update_url_name,
|
|
|
1090
|
+ 'delete_url': self.delete_url_name,
|
|
|
1091
|
+ 'bs': self.get_breadcrumbs('list'),
|
|
|
1092
|
+ })
|
|
|
1093
|
+ return context
|
|
|
1094
|
+
|
|
|
1095
|
+ return ListViewClass
|
|
|
1096
|
+
|
|
|
1097
|
+
|
|
|
1098
|
+
|
|
|
1099
|
+class ProductDrawingCRUDView(ConfigurableCRUDView):
|
|
|
1100
|
+ model = ProductDrawing
|
|
|
1101
|
+ list_template_name = 'legacy/datacrud_list.html'
|
|
|
1102
|
+ detail_template_name = 'legacy/datacrud_detail.html'
|
|
|
1103
|
+ form_template_name = 'legacy/datacrud_form.html'
|
|
|
1104
|
+ confirm_delete_template_name = 'legacy/datacrud_confirm_delete.html'
|
|
|
1105
|
+ filterset_class = ProductDrawingFilter
|
|
|
1106
|
+
|
|
|
1107
|
+ page_title = "Product Drawing"
|
|
|
1108
|
+
|
|
|
1109
|
+ # URL name mappings
|
|
|
1110
|
+ list_url_name = 'report:product_drawings-list'
|
|
|
1111
|
+ create_url_name = 'report:product_drawings-create'
|
|
|
1112
|
+ update_url_name = 'report:product_drawings-update'
|
|
|
1113
|
+ delete_url_name = 'report:product_drawings-delete'
|
|
|
1114
|
+ config_fields = ["id", "code_no", "code_no_mks", "lot_no", "drawing", "description", "created_at"]
|
|
|
1115
|
+ #config_field_orders = ["id", "customer_name", "template_names", "created_at", "created_by"]
|
|
|
1116
|
+ # config_readonly_fields = ["lot_no"]
|
|
|
1117
|
+ config_edit_fields = None
|
|
|
1118
|
+ ordering = ["-created_at", "-id",]
|
|
|
1119
|
+ form_class = ProductDrawingForm
|
|
|
1120
|
+
|
|
|
1121
|
+
|