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