From 13bbc4705a76c75364935f6ecbdc1998d074d1c8 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Mon, 18 Sep 2023 14:01:34 -0400 Subject: [PATCH] PDF fixes, and working on models andstlying django side --- BenchtopPDF/BenchtopPDF/SheetDocument.cs | 2 +- benchtopdevices/sheets/admin.py | 8 +- benchtopdevices/sheets/forms.py | 47 ++- .../sheets/migrations/0001_initial.py | 42 ++- ...lter_sheet_calibration_cert_id_and_more.py | 58 ++++ .../sheets/migrations/0002_sheet.py | 56 ---- ...t_as_found_alter_sheet_as_left_and_more.py | 36 --- ...omer_address_sheet_control_doc_and_more.py | 34 ++ benchtopdevices/sheets/models.py | 38 +-- benchtopdevices/sheets/parsers/transducer.py | 1 + .../sheets/templates/sheets/upload.html | 302 ++++++++++++------ benchtopdevices/sheets/views.py | 8 +- benchtopdevices/transducer_verify.txt | 85 +++++ 13 files changed, 471 insertions(+), 246 deletions(-) create mode 100644 benchtopdevices/sheets/migrations/0002_alter_sheet_calibration_cert_id_and_more.py delete mode 100644 benchtopdevices/sheets/migrations/0002_sheet.py delete mode 100644 benchtopdevices/sheets/migrations/0003_alter_sheet_as_found_alter_sheet_as_left_and_more.py create mode 100644 benchtopdevices/sheets/migrations/0003_remove_sheet_customer_address_sheet_control_doc_and_more.py create mode 100644 benchtopdevices/transducer_verify.txt diff --git a/BenchtopPDF/BenchtopPDF/SheetDocument.cs b/BenchtopPDF/BenchtopPDF/SheetDocument.cs index 36d91c0..da61929 100644 --- a/BenchtopPDF/BenchtopPDF/SheetDocument.cs +++ b/BenchtopPDF/BenchtopPDF/SheetDocument.cs @@ -279,7 +279,7 @@ namespace BenchtopPDF table.Cell().Element(CellStyle).AlignRight().Text($"{masterValue.LowLimit / 1000.0:F3}"); table.Cell().Element(CellStyle).AlignRight().Text($"{masterValue.HighLimit / 1000.0:F3}"); table.Cell().Element(CellStyle).AlignRight().Text($"{value / 1000.0:F3}"); - table.Cell().Element(CellStyle).AlignRight().Text($"{delta / 1000.0:F3}"); + table.Cell().Element(CellStyle).AlignRight().Text($"---"); } diff --git a/benchtopdevices/sheets/admin.py b/benchtopdevices/sheets/admin.py index 3084a27..a570445 100644 --- a/benchtopdevices/sheets/admin.py +++ b/benchtopdevices/sheets/admin.py @@ -1,14 +1,8 @@ from django.contrib import admin -from sheets.models import ( - Configuration, +from .models import ( Sheet ) -class ConfigurationAdmin(admin.ModelAdmin): - pass - -admin.site.register(Configuration, ConfigurationAdmin) - class SheetAdmin(admin.ModelAdmin): pass diff --git a/benchtopdevices/sheets/forms.py b/benchtopdevices/sheets/forms.py index 313f841..23b273f 100644 --- a/benchtopdevices/sheets/forms.py +++ b/benchtopdevices/sheets/forms.py @@ -3,31 +3,60 @@ from django.forms.widgets import ClearableFileInput from django.db import models from django.utils.translation import gettext_lazy as _ -from sheets.models import Configuration, Sheet +from .models import Sheet class SheetForm(forms.ModelForm): class Meta: model = Sheet - fields = ["instrument", "customer_name", "customer_address", "control_number", "serial_number", "accuracy", "barometric_pressure", "temperature", "humidity", "report_type", "as_found", "as_left", "both", "configuration",] - widgets = { + fields = [ + "customer_name", + "onsite_cal", + "control_doc", + "technician", + + "instrument_model", + "serial_number", + "channel", + "transducer_model", + "transducer_span", + + "calibration_serial", + "calibration_model", + "calibration_date", + "calibration_due_date", + "calibration_cert_id", + + "accuracy", + "barometric_pressure", + "temperature", + "humidity", + "report_type", + "as_found", + "as_left", + "both", + ] + + widgets = { "accuracy": forms.NumberInput(attrs={'step': 0.01}), "barometric_pressure": forms.NumberInput(attrs={'step': 0.01, 'max': 1100, 'min': 800}), "temperature": forms.NumberInput(attrs={'step': 0.01, 'max': 1000.0, 'min': -459.67}), "humidity": forms.NumberInput(attrs={'step': 0.01, 'max': 100.0, 'min': 0.0}), - } - + "calibration_date": forms.SelectDateWidget(), + "calibration_due_date": forms.SelectDateWidget(), + + } + def __init__(self, *args, **kwargs): super(SheetForm, self).__init__(*args, **kwargs) - + for name, field in self.fields.items(): # add v-model to each model field if isinstance(field, forms.fields.FileField): field.widget.attrs.update( { - 'v-on:change': f"change_{name}", - 'v-if': f"show_{name}" + 'v-on:change': f"change_{name}", + 'v-if': f"show_{name}" }) else: field.widget.attrs.update({'v-model': name}) - diff --git a/benchtopdevices/sheets/migrations/0001_initial.py b/benchtopdevices/sheets/migrations/0001_initial.py index 7decb71..b4d50bf 100644 --- a/benchtopdevices/sheets/migrations/0001_initial.py +++ b/benchtopdevices/sheets/migrations/0001_initial.py @@ -1,30 +1,38 @@ -# Generated by Django 4.2.3 on 2023-07-26 18:12 +# Generated by Django 4.2.5 on 2023-09-18 17:03 from django.db import migrations, models class Migration(migrations.Migration): - initial = True - dependencies = [] + dependencies = [ + ] operations = [ migrations.CreateModel( - name="Configuration", + name='Sheet', fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("serial", models.CharField(max_length=100)), - ("device", models.CharField(max_length=100)), - ("calibration_date", models.DateField()), - ("calibration_due_date", models.DateField()), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('customer_name', models.CharField(max_length=256)), + ('customer_address', models.CharField(max_length=256)), + ('serial_number', models.CharField(max_length=256)), + ('accuracy', models.FloatField()), + ('barometric_pressure', models.FloatField()), + ('temperature', models.FloatField()), + ('humidity', models.FloatField()), + ('report_type', models.CharField(choices=[('TV', 'Transducer Verify'), ('HC', 'Hardware Calibration')], max_length=256)), + ('as_found', models.FileField(blank=True, upload_to='')), + ('as_left', models.FileField(blank=True, upload_to='')), + ('both', models.FileField(blank=True, upload_to='')), + ('calibration_cert_id', models.CharField(default=0, max_length=100)), + ('calibration_date', models.DateField(default=0)), + ('calibration_due_date', models.DateField(default=0)), + ('calibration_model', models.CharField(default=0, max_length=100)), + ('calibration_serial', models.CharField(default=0, max_length=100)), + ('channel', models.CharField(default=0, max_length=256)), + ('instrument_model', models.CharField(default=0, max_length=256)), + ('transducer_model', models.CharField(default=0, max_length=256)), + ('transducer_span', models.CharField(default=0, max_length=256)), ], ), ] diff --git a/benchtopdevices/sheets/migrations/0002_alter_sheet_calibration_cert_id_and_more.py b/benchtopdevices/sheets/migrations/0002_alter_sheet_calibration_cert_id_and_more.py new file mode 100644 index 0000000..1d12b43 --- /dev/null +++ b/benchtopdevices/sheets/migrations/0002_alter_sheet_calibration_cert_id_and_more.py @@ -0,0 +1,58 @@ +# Generated by Django 4.2.5 on 2023-09-18 17:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sheets', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='sheet', + name='calibration_cert_id', + field=models.CharField(max_length=100), + ), + migrations.AlterField( + model_name='sheet', + name='calibration_date', + field=models.DateField(), + ), + migrations.AlterField( + model_name='sheet', + name='calibration_due_date', + field=models.DateField(), + ), + migrations.AlterField( + model_name='sheet', + name='calibration_model', + field=models.CharField(max_length=100), + ), + migrations.AlterField( + model_name='sheet', + name='calibration_serial', + field=models.CharField(max_length=100), + ), + migrations.AlterField( + model_name='sheet', + name='channel', + field=models.CharField(max_length=256), + ), + migrations.AlterField( + model_name='sheet', + name='instrument_model', + field=models.CharField(max_length=256), + ), + migrations.AlterField( + model_name='sheet', + name='transducer_model', + field=models.CharField(max_length=256), + ), + migrations.AlterField( + model_name='sheet', + name='transducer_span', + field=models.CharField(max_length=256), + ), + ] diff --git a/benchtopdevices/sheets/migrations/0002_sheet.py b/benchtopdevices/sheets/migrations/0002_sheet.py deleted file mode 100644 index 623bdf4..0000000 --- a/benchtopdevices/sheets/migrations/0002_sheet.py +++ /dev/null @@ -1,56 +0,0 @@ -# Generated by Django 4.2.3 on 2023-07-26 19:33 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - dependencies = [ - ("sheets", "0001_initial"), - ] - - operations = [ - migrations.CreateModel( - name="Sheet", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("instrument", models.CharField(max_length=256)), - ("customer_name", models.CharField(max_length=256)), - ("customer_address", models.CharField(max_length=256)), - ("control_number", models.CharField(max_length=256)), - ("serial_number", models.CharField(max_length=256)), - ("accuracy", models.FloatField()), - ("barometric_pressure", models.FloatField()), - ("temperature", models.FloatField()), - ("humidity", models.FloatField()), - ( - "report_type", - models.CharField( - choices=[ - ("TV", "Transducer Verify"), - ("HC", "Hardware Calibration"), - ], - max_length=256, - ), - ), - ("as_found", models.FileField(upload_to="")), - ("as_left", models.FileField(upload_to="")), - ("both", models.FileField(upload_to="")), - ( - "configuration", - models.ForeignKey( - on_delete=django.db.models.deletion.PROTECT, - to="sheets.configuration", - ), - ), - ], - ), - ] diff --git a/benchtopdevices/sheets/migrations/0003_alter_sheet_as_found_alter_sheet_as_left_and_more.py b/benchtopdevices/sheets/migrations/0003_alter_sheet_as_found_alter_sheet_as_left_and_more.py deleted file mode 100644 index bb57e67..0000000 --- a/benchtopdevices/sheets/migrations/0003_alter_sheet_as_found_alter_sheet_as_left_and_more.py +++ /dev/null @@ -1,36 +0,0 @@ -# Generated by Django 4.2.3 on 2023-07-26 20:34 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("sheets", "0002_sheet"), - ] - - operations = [ - migrations.AlterField( - model_name="sheet", - name="as_found", - field=models.FileField(blank=True, upload_to=""), - ), - migrations.AlterField( - model_name="sheet", - name="as_left", - field=models.FileField(blank=True, upload_to=""), - ), - migrations.AlterField( - model_name="sheet", - name="both", - field=models.FileField(blank=True, upload_to=""), - ), - migrations.RemoveField( - model_name="sheet", - name="configuration", - ), - migrations.AddField( - model_name="sheet", - name="configuration", - field=models.ManyToManyField(to="sheets.configuration"), - ), - ] diff --git a/benchtopdevices/sheets/migrations/0003_remove_sheet_customer_address_sheet_control_doc_and_more.py b/benchtopdevices/sheets/migrations/0003_remove_sheet_customer_address_sheet_control_doc_and_more.py new file mode 100644 index 0000000..968ea78 --- /dev/null +++ b/benchtopdevices/sheets/migrations/0003_remove_sheet_customer_address_sheet_control_doc_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.5 on 2023-09-18 17:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sheets', '0002_alter_sheet_calibration_cert_id_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='sheet', + name='customer_address', + ), + migrations.AddField( + model_name='sheet', + name='control_doc', + field=models.CharField(default=0, max_length=256), + preserve_default=False, + ), + migrations.AddField( + model_name='sheet', + name='onsite_cal', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='sheet', + name='technician', + field=models.CharField(default=0, max_length=256), + preserve_default=False, + ), + ] diff --git a/benchtopdevices/sheets/models.py b/benchtopdevices/sheets/models.py index 7e89537..15de166 100644 --- a/benchtopdevices/sheets/models.py +++ b/benchtopdevices/sheets/models.py @@ -1,41 +1,41 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -# Create your models here. - -class Configuration(models.Model): - serial = models.CharField(max_length=100) - device = models.CharField(max_length=100) - calibration_date = models.DateField() - calibration_due_date = models.DateField() - - def __str__(self): - return f"{self.serial} {self.device} [{self.calibration_date} to {self.calibration_due_date}]" - class Sheet(models.Model): - instrument = models.CharField(max_length=256) - customer_name = models.CharField(max_length=256) - customer_address = models.CharField(max_length=256) - control_number = models.CharField(max_length=256) + instrument_model = models.CharField(max_length=256) serial_number = models.CharField(max_length=256) + channel = models.CharField(max_length=256) + transducer_model = models.CharField(max_length=256) + transducer_span = models.CharField(max_length=256) + + customer_name = models.CharField(max_length=256) + onsite_cal = models.BooleanField(default=False) + control_doc = models.CharField(max_length=256) + technician = models.CharField(max_length=256) + accuracy = models.FloatField() + barometric_pressure = models.FloatField() temperature = models.FloatField() humidity = models.FloatField() + calibration_serial = models.CharField(max_length=100) + calibration_model = models.CharField(max_length=100) + calibration_date = models.DateField() + calibration_due_date = models.DateField() + calibration_cert_id = models.CharField(max_length=100) CHOICES = [ ('TV', _('Transducer Verify')), ('HC', _('Hardware Calibration')) ] - report_type = models.CharField(max_length=256, + report_type = models.CharField( + max_length=256, choices=CHOICES, ) as_found = models.FileField(blank=True) as_left = models.FileField(blank=True) - both = models.FileField(blank=True) - - configuration = models.ManyToManyField("Configuration") \ No newline at end of file + both = models.FileField(blank=True) \ No newline at end of file diff --git a/benchtopdevices/sheets/parsers/transducer.py b/benchtopdevices/sheets/parsers/transducer.py index 777df72..eeb5e65 100644 --- a/benchtopdevices/sheets/parsers/transducer.py +++ b/benchtopdevices/sheets/parsers/transducer.py @@ -2,6 +2,7 @@ import re import json from pprint import pprint + def in_range(index, value, master_values): return ( master_values[index]["Low Limit"] <= value <= master_values[index]["High Limit"] diff --git a/benchtopdevices/sheets/templates/sheets/upload.html b/benchtopdevices/sheets/templates/sheets/upload.html index d50c917..86ca0f6 100644 --- a/benchtopdevices/sheets/templates/sheets/upload.html +++ b/benchtopdevices/sheets/templates/sheets/upload.html @@ -1,121 +1,227 @@ - - + + + + + + - + + + + + + + +
{% csrf_token %} - - - - - +
Customer Name{{ form.customer_name }}
Customer Address{{ form.customer_address }}

+ + + + + + - - - - + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + +

Customer

Instrument{{ form.instrument }}
Control Number{{ form.control_number }}
Serial Number{{ form.serial_number }}

Customer Name{{ form.customer_name }}
On Site Calibration{{ form.onsite_cal }}
Control Doc#{{ form.control_doc }}
Technician{{ form.technician }}
Accuracy{{ form.accuracy }}
Barometric Pressure (mbar){{ form.barometric_pressure }}
Temperature (°F){{ form.temperature }}
Humidity{{ form.humidity }}

Instrument

Model:{{ form.instrument_model }}
Serial Number{{ form.serial_number }}
Channel{{ form.channel }}
Transducer Model:{{ form.transducer_model }}
Transducer Span:{{ form.transducer_span }}
Report Type{{ form.report_type }}
Configuration(s){{ form.configuration }}

Primary Calibration Device

Model{{ form.calibration_model }}
Serial #{{ form.calibration_serial }}
Cal Date{{ form.calibration_date }}
Cal Due Date{{ form.calibration_due_date }}
Cert ID{{ form.calibration_cert_id }}

Environment

As Found: {{ form.as_found }}As Left:{{ form.as_left }}
One File: {{ form.both }}

 
Accuracy{{ form.accuracy }}
Barometric Pressure (mbar){{ form.barometric_pressure }}
Temperature (°F){{ form.temperature }}
Humidity{{ form.humidity }}

Report Uploads

Report Type{{ form.report_type }}
One File: {{ form.both }}
As Found: {{ form.as_found }}As Left:{{ form.as_left }}
 
- +
{% verbatim %} {% endverbatim %} diff --git a/benchtopdevices/sheets/views.py b/benchtopdevices/sheets/views.py index 456473d..54c74af 100644 --- a/benchtopdevices/sheets/views.py +++ b/benchtopdevices/sheets/views.py @@ -1,9 +1,9 @@ from django.http import HttpResponseRedirect from django.shortcuts import render -from .forms import SheetForm, SheetForm from django.core.exceptions import ValidationError -from .parsers import parse_transducer, parse_hardware_calibration +from .forms import SheetForm, SheetForm +from .parsers import parse_transducer, parse_hardware_calibration def upload_file(request): @@ -23,7 +23,9 @@ def upload_file(request): pass else: raise ValidationError("Please provide proper files") - return HttpResponseRedirect("/success/url/") + f.save() + breakpoint() + return HttpResponseRedirect("/") else: form = SheetForm() return render(request, "sheets/upload.html", {"form": form}) \ No newline at end of file diff --git a/benchtopdevices/transducer_verify.txt b/benchtopdevices/transducer_verify.txt new file mode 100644 index 0000000..596e282 --- /dev/null +++ b/benchtopdevices/transducer_verify.txt @@ -0,0 +1,85 @@ +|| Transducer Verify Report || +TRANSDUCER1 +=============================================================== +Transducer 1 CTS D34-442 115PSIA +Setpoint Pressure 1 0.000 psig +Setpoint Pressure 2 20.000 psig +Setpoint Pressure 3 40.000 psig +Setpoint Pressure 4 60.000 psig +Setpoint Pressure 5 80.000 psig +Setpoint Pressure 6 100.000 psig +Instrument Pressure 1 0.000 psig +Instrument Pressure 2 20.002 psig +Instrument Pressure 3 39.997 psig +Instrument Pressure 4 60.010 psig +Instrument Pressure 5 80.001 psig +Instrument Pressure 6 100.002 psig +Master Value 1 0.000 psig +Master Value 2 20.000 psig +Master Value 3 40.000 psig +Master Value 4 60.000 psig +Master Value 5 80.000 psig +Master Value 6 100.000 psig +Verify Date 07/20/22 +Verify Time 11:20:26 + +TRANSDUCER2 +=============================================================== +Transducer 2 CTS A12-221 250SCCM +Setpoint Pressure 1 20.000 psig +Setpoint Pressure 2 20.000 psig +Setpoint Pressure 3 20.000 psig +Setpoint Pressure 4 20.000 psig +Setpoint Pressure 5 20.000 psig +Setpoint Pressure 6 20.000 psig +Setpoint Pressure 7 20.000 psig +Setpoint Pressure 8 20.000 psig +Setpoint Pressure 9 20.000 psig +Setpoint Pressure 10 20.000 psig +Setpoint Pressure 11 20.000 psig +Instrument Pressure 1 20.154 psig +Instrument Pressure 2 20.153 psig +Instrument Pressure 3 20.152 psig +Instrument Pressure 4 20.150 psig +Instrument Pressure 5 20.148 psig +Instrument Pressure 6 20.145 psig +Instrument Pressure 7 20.144 psig +Instrument Pressure 8 20.141 psig +Instrument Pressure 9 20.139 psig +Instrument Pressure 10 20.138 psig +Instrument Pressure 11 20.136 psig +Instrument Flow 1 -0.082 sccm +Instrument Flow 2 24.802 sccm +Instrument Flow 3 49.664 sccm +Instrument Flow 4 74.836 sccm +Instrument Flow 5 99.416 sccm +Instrument Flow 6 125.289 sccm +Instrument Flow 7 150.205 sccm +Instrument Flow 8 175.290 sccm +Instrument Flow 9 200.165 sccm +Instrument Flow 10 224.748 sccm +Instrument Flow 11 249.825 sccm +Master Reading 1 0.000 sccm +Master Reading 2 25.000 sccm +Master Reading 3 50.000 sccm +Master Reading 4 75.000 sccm +Master Reading 5 100.000 sccm +Master Reading 6 125.000 sccm +Master Reading 7 150.000 sccm +Master Reading 8 175.000 sccm +Master Reading 9 200.000 sccm +Master Reading 10 225.000 sccm +Master Reading 11 250.000 sccm +Master Value 1 0.000 sccm +Master Value 2 25.000 sccm +Master Value 3 50.000 sccm +Master Value 4 75.000 sccm +Master Value 5 100.000 sccm +Master Value 6 125.000 sccm +Master Value 7 150.000 sccm +Master Value 8 175.000 sccm +Master Value 9 200.000 sccm +Master Value 10 225.000 sccm +Master Value 11 250.000 sccm +Verify Date 07/15/21 +Verify Time 14:55:10