td class="lines-num lines-num-old"> 113
+<style>
114
+/* Remove fixed layout and allow columns to grow dynamically */
115
+table {
116
+    table-layout: auto; /* Default is auto, can be explicitly set */
117
+    width: 100%; /* Ensures table spans available space */
118
+}
119
+
120
+th, td {
121
+    white-space: nowrap; /* Prevents text wrapping */
122
+    text-overflow: ellipsis; /* Adds ellipsis for overflowed content if combined with max-width */
123
+    vertical-align: top; /* Aligns content to the top */
124
+}
125
+</style>
126
+{% endblock %}

+ 12 - 1
app/report/urls.py

@@ -1,8 +1,10 @@
1 1
 from django.urls import path
2 2
 from . import views
3
-from .views import ReportCRUDView
3
+from .views import ReportCRUDView, CustomerTemplateCRUDView, ProductDrawingCRUDView
4 4
 
5 5
 report_crud = ReportCRUDView()
6
+customer_templates_crud = CustomerTemplateCRUDView()
7
+product_drawings_crud = ProductDrawingCRUDView()
6 8
 
7 9
 app_name = "report"  # Use this namespace for reverse URL lookups
8 10
 
@@ -16,6 +18,15 @@ urlpatterns = [
16 18
     path('coi/', views.coi_view, name='coi-view'),
17 19
     path('report/generate/', views.gen_report_view, name='gen_report'),
18 20
 
21
+    path('customer_templates/', customer_templates_crud.get_list_view().as_view(), name='customer_templates-list'),
22
+    path('customer_templates/create/', customer_templates_crud.get_create_view().as_view(), name='customer_templates-create'),
23
+    path('customer_templates/<str:pk>/update/', customer_templates_crud.get_update_view().as_view(), name='customer_templates-update'),
24
+    path('customer_templates/<str:pk>/delete/', customer_templates_crud.get_delete_view().as_view(), name='customer_templates-delete'),
25
+    
26
+    path('product_drawings/', product_drawings_crud.get_list_view().as_view(), name='product_drawings-list'),
27
+    path('product_drawings/create/', product_drawings_crud.get_create_view().as_view(), name='product_drawings-create'),
28
+    path('product_drawings/<str:pk>/update/', product_drawings_crud.get_update_view().as_view(), name='product_drawings-update'),
29
+    path('product_drawings/<str:pk>/delete/', product_drawings_crud.get_delete_view().as_view(), name='product_drawings-delete'),
19 30
     # path('create/', views.create_report, name='create'),  # Create a new report
20 31
     # path('<int:pk>/', views.detail_report, name='detail'),  # View details of a specific report
21 32
     # path('<int:pk>/update/', views.update_report, name='update'),  # Update a specific report

+ 84 - 16
app/report/views.py

@@ -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
+

BIN
app/src.zip


+ 18 - 0
app/sysadmin/migrations/0002_alter_userprofile_position.py

@@ -0,0 +1,18 @@
1
+# Generated by Django 4.2 on 2025-05-06 04:36
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('sysadmin', '0001_initial'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AlterField(
14
+            model_name='userprofile',
15
+            name='position',
16
+            field=models.CharField(blank=True, choices=[('QA_STAFF', 'QA Staff'), ('QA_MANAGER', 'QA. MG.'), ('QA_AST_MANAGER', 'QA. Asst. MG.'), ('QA_ENGINEER', 'QA. Engineer')], max_length=20, null=True),
17
+        ),
18
+    ]

+ 2 - 0
app/templates/base.html

@@ -66,6 +66,8 @@
66 66
                 <li><a href="/dashboard/" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Dashboard</span></a></li>
67 67
                 <li><a href="{% url "report:coi-view" %}" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">COI</span></a></li>
68 68
                 <li><a href="{% url "report:report-list" %}" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Reports</span></a></li>
69
+                <li><a href="{% url "report:customer_templates-list" %}" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Customer Templates</span></a></li>
70
+                <li><a href="{% url "report:product_drawings-list" %}" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Drawing</span></a></li>
69 71
                  <li>
70 72
                     <button type="button" class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700" aria-controls="dropdown-example" data-collapse-toggle="dropdown-example">
71 73
                           <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">

tum/tmt_learning - Gogs: Simplico Git Service

暫無描述

LICENSE 1.0KB

12345678
  1. Copyright 2015 Tobias Koppers
  2. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  3. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  4. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.