more fields
This commit is contained in:
parent
13bbc4705a
commit
4df6c209f4
@ -38,7 +38,8 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'sheets'
|
'sheets',
|
||||||
|
'rest_framework',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
django
|
django
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
django-debug-toolbar
|
django-debug-toolbar
|
||||||
|
django-rest-framework
|
@ -16,6 +16,8 @@ class SheetForm(forms.ModelForm):
|
|||||||
"technician",
|
"technician",
|
||||||
|
|
||||||
"instrument_model",
|
"instrument_model",
|
||||||
|
"instrument_calibration_date",
|
||||||
|
"instrument_calibration_due_date",
|
||||||
"serial_number",
|
"serial_number",
|
||||||
"channel",
|
"channel",
|
||||||
"transducer_model",
|
"transducer_model",
|
||||||
@ -32,6 +34,8 @@ class SheetForm(forms.ModelForm):
|
|||||||
"temperature",
|
"temperature",
|
||||||
"humidity",
|
"humidity",
|
||||||
"report_type",
|
"report_type",
|
||||||
|
"transducer_type",
|
||||||
|
|
||||||
"as_found",
|
"as_found",
|
||||||
"as_left",
|
"as_left",
|
||||||
"both",
|
"both",
|
||||||
@ -42,9 +46,10 @@ class SheetForm(forms.ModelForm):
|
|||||||
"barometric_pressure": forms.NumberInput(attrs={'step': 0.01, 'max': 1100, 'min': 800}),
|
"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}),
|
"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}),
|
"humidity": forms.NumberInput(attrs={'step': 0.01, 'max': 100.0, 'min': 0.0}),
|
||||||
"calibration_date": forms.SelectDateWidget(),
|
"calibration_date": forms.SelectDateWidget(years=range(2020, 2030)),
|
||||||
"calibration_due_date": forms.SelectDateWidget(),
|
"calibration_due_date": forms.SelectDateWidget(years=range(2020, 2030)),
|
||||||
|
"instrument_calibration_date": forms.SelectDateWidget(years=range(2020, 2030)),
|
||||||
|
"instrument_calibration_due_date": forms.SelectDateWidget(years=range(2020, 2030)),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
18
benchtopdevices/sheets/migrations/0004_sheet_kind.py
Normal file
18
benchtopdevices/sheets/migrations/0004_sheet_kind.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-10-05 03:11
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('sheets', '0003_remove_sheet_customer_address_sheet_control_doc_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sheet',
|
||||||
|
name='kind',
|
||||||
|
field=models.CharField(blank=True, choices=[('p', 'Pressure Transducer'), ('f', 'Flow Transducer')], max_length=256),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-10-05 03:15
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('sheets', '0004_sheet_kind'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='sheet',
|
||||||
|
name='kind',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sheet',
|
||||||
|
name='transducer_type',
|
||||||
|
field=models.CharField(blank=True, choices=[('Pressure', 'Pressure Transducer'), ('Flow', 'Flow Transducer')], max_length=256),
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 4.2.5 on 2023-10-05 03:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('sheets', '0005_remove_sheet_kind_sheet_transducer_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sheet',
|
||||||
|
name='instrument_calibration_date',
|
||||||
|
field=models.DateField(default=django.utils.timezone.now),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sheet',
|
||||||
|
name='instrument_calibration_due_date',
|
||||||
|
field=models.DateField(default=django.utils.timezone.now),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
@ -4,6 +4,8 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
class Sheet(models.Model):
|
class Sheet(models.Model):
|
||||||
instrument_model = models.CharField(max_length=256)
|
instrument_model = models.CharField(max_length=256)
|
||||||
|
instrument_calibration_date = models.DateField()
|
||||||
|
instrument_calibration_due_date = models.DateField()
|
||||||
serial_number = models.CharField(max_length=256)
|
serial_number = models.CharField(max_length=256)
|
||||||
channel = models.CharField(max_length=256)
|
channel = models.CharField(max_length=256)
|
||||||
transducer_model = models.CharField(max_length=256)
|
transducer_model = models.CharField(max_length=256)
|
||||||
@ -36,6 +38,17 @@ class Sheet(models.Model):
|
|||||||
choices=CHOICES,
|
choices=CHOICES,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TRANSDUCER_TYPES = [
|
||||||
|
('Pressure', _('Pressure Transducer')),
|
||||||
|
('Flow', _('Flow Transducer'))
|
||||||
|
]
|
||||||
|
|
||||||
|
transducer_type = models.CharField(
|
||||||
|
max_length=256,
|
||||||
|
choices=TRANSDUCER_TYPES,
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
|
||||||
as_found = models.FileField(blank=True)
|
as_found = models.FileField(blank=True)
|
||||||
as_left = models.FileField(blank=True)
|
as_left = models.FileField(blank=True)
|
||||||
both = models.FileField(blank=True)
|
both = models.FileField(blank=True)
|
@ -1,20 +1,16 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<!--? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/css/foundation.min.css"-->
|
<!--? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/css/foundation.min.css"-->
|
||||||
<!--? crossorigin="anonymous">-->
|
<!--? crossorigin="anonymous">-->
|
||||||
<!--? <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/js/foundation.min.js"-->
|
<!--? <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/js/foundation.min.js"-->
|
||||||
<!--? crossorigin="anonymous"></script>-->
|
<!--? crossorigin="anonymous"></script>-->
|
||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||||
<script type="importmap">
|
<script type="importmap">
|
||||||
{
|
{ "imports": { "vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.41/vue.esm-browser.js" } }
|
||||||
"imports": {
|
|
||||||
"vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.41/vue.esm-browser.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.app {
|
.app {
|
||||||
@ -32,136 +28,59 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr><th colspan="2"><h2>Customer</h2></th></tr>
|
||||||
<th colspan="2"><h2>Customer</h2></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr><td>Customer Name</td><td>{{ form.customer_name }}</td></tr>
|
||||||
<tr>
|
<tr><td>On Site Calibration</td><td>{{ form.onsite_cal }}</td></tr>
|
||||||
<td>Customer Name</td>
|
<tr><td>Control Doc#</td><td>{{ form.control_doc }}</td></tr>
|
||||||
<td>{{ form.customer_name }}</td>
|
<tr><td>Technician</td><td>{{ form.technician }}</td></tr>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>On Site Calibration</td>
|
|
||||||
<td>{{ form.onsite_cal }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Control Doc#</td>
|
|
||||||
<td>{{ form.control_doc }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Technician</td>
|
|
||||||
<td>{{ form.technician }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr><th colspan="2"><h2>Instrument</h2></th></tr>
|
||||||
<th colspan="2"><h2>Instrument</h2></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr><td>Model:</td><td>{{ form.instrument_model }}</td></tr>
|
||||||
<td>Model:</td>
|
<tr><td>Calibration Date:</td><td>{{ form.instrument_calibration_date }}</td></tr>
|
||||||
<td>{{ form.instrument_model }}</td>
|
<tr><td>Calibration Due Date:</td><td>{{ form.instrument_calibration_due_date }}</td></tr>
|
||||||
</tr>
|
<tr><td>Serial Number</td><td>{{ form.serial_number }}</td></tr>
|
||||||
<tr>
|
<tr><td>Channel</td><td>{{ form.channel }}</td></tr>
|
||||||
<td>Serial Number</td>
|
<tr><td>Transducer Model:</td><td>{{ form.transducer_model }}</td></tr>
|
||||||
<td>{{ form.serial_number }}</td>
|
<tr><td>Transducer Span:</td><td>{{ form.transducer_span }}</td></tr>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Channel</td>
|
|
||||||
<td>{{ form.channel }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Transducer Model:</td>
|
|
||||||
<td>{{ form.transducer_model }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Transducer Span:</td>
|
|
||||||
<td>{{ form.transducer_span }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr><th colspan="2"><h2>Primary Calibration Device</h2></th></tr>
|
||||||
<th colspan="2"><h2>Primary Calibration Device</h2></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr><td>Model</td><td>{{ form.calibration_model }}</td></tr>
|
||||||
<td>Model</td>
|
<tr><td>Serial #</td><td>{{ form.calibration_serial }}</td></tr>
|
||||||
<td>{{ form.calibration_model }}</td>
|
<tr><td>Cal Date</td><td>{{ form.calibration_date }}</td></tr>
|
||||||
</tr>
|
<tr><td>Cal Due Date</td><td>{{ form.calibration_due_date }}</td></tr>
|
||||||
<tr>
|
<tr><td>Cert ID</td><td>{{ form.calibration_cert_id }}</td></tr>
|
||||||
<td>Serial #</td>
|
|
||||||
<td>{{ form.calibration_serial }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Cal Date</td>
|
|
||||||
<td>{{ form.calibration_date }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Cal Due Date</td>
|
|
||||||
<td>{{ form.calibration_due_date }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Cert ID</td>
|
|
||||||
<td>{{ form.calibration_cert_id }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr><th colspan="2"><h2>Environment</h2></th></tr>
|
||||||
<th colspan="2"><h2>Environment</h2></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr><td>Accuracy</td><td>{{ form.accuracy }}</td></tr>
|
||||||
<tr>
|
<tr><td>Barometric Pressure (mbar)</td><td>{{ form.barometric_pressure }}</td></tr>
|
||||||
<td>Accuracy</td>
|
<tr><td>Temperature (°F)</td><td>{{ form.temperature }}</td></tr>
|
||||||
<td>{{ form.accuracy }}</td>
|
<tr><td>Humidity</td><td>{{ form.humidity }}</td></tr>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Barometric Pressure (mbar)</td>
|
|
||||||
<td>{{ form.barometric_pressure }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Temperature (°F)</td>
|
|
||||||
<td>{{ form.temperature }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Humidity</td>
|
|
||||||
<td>{{ form.humidity }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr><th colspan="2"><h2>Report Uploads</h2></th></tr>
|
||||||
<th colspan="2"><h2>Report Uploads</h2></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr><td>Report Type</td><td>{{ form.report_type }}</td></tr>
|
||||||
<td>Report Type</td>
|
<tr><td colspan=2>One File: {{ form.both }}</td></tr>
|
||||||
<td>{{ form.report_type }}</td>
|
<tr><td>As Found: {{ form.as_found }}</td><td>As Left:{{ form.as_left }}</td></tr>
|
||||||
</tr>
|
<tr><td> </td><td align="right"><input type="submit" value="Generate PDF and Label"></td></tr>
|
||||||
<tr>
|
|
||||||
<td colspan=2>One File: {{ form.both }}</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>As Found: {{ form.as_found }}</td>
|
|
||||||
<td>As Left:{{ form.as_left }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td> </td>
|
|
||||||
<td align="right"><input type="submit" value="Generate PDF and Label"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -171,11 +90,11 @@
|
|||||||
|
|
||||||
// Vue.config.delimiters = ['${', '}'];
|
// Vue.config.delimiters = ['${', '}'];
|
||||||
const vm = createApp({
|
const vm = createApp({
|
||||||
el: "#app",
|
|
||||||
data() {
|
data() {
|
||||||
const as_found = ""
|
const as_found = ""
|
||||||
const as_left = ""
|
const as_left = ""
|
||||||
const both = ""
|
const both = ""
|
||||||
|
const report_type = ""
|
||||||
const accuracy = ref("0.5")
|
const accuracy = ref("0.5")
|
||||||
const barometric_pressure = ref(1013.25)
|
const barometric_pressure = ref(1013.25)
|
||||||
const temperature = ref("50")
|
const temperature = ref("50")
|
||||||
@ -183,6 +102,7 @@
|
|||||||
const show_as_found = reactive(true)
|
const show_as_found = reactive(true)
|
||||||
const show_as_left = reactive(true)
|
const show_as_left = reactive(true)
|
||||||
const show_both = reactive(true)
|
const show_both = reactive(true)
|
||||||
|
const show_report_type = reactive(true)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accuracy,
|
accuracy,
|
||||||
@ -192,34 +112,33 @@
|
|||||||
as_found,
|
as_found,
|
||||||
as_left,
|
as_left,
|
||||||
both,
|
both,
|
||||||
|
report_type,
|
||||||
show_as_found,
|
show_as_found,
|
||||||
show_as_left,
|
show_as_left,
|
||||||
show_both
|
show_both,
|
||||||
|
show_report_type,
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ready: () => {
|
el: "#app",
|
||||||
this.watchFileInput();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
change_as_found: function (event) {
|
change_as_found: function () {
|
||||||
this.show_both = false
|
this.show_both = false
|
||||||
},
|
},
|
||||||
change_as_left: function (event) {
|
change_as_left: function () {
|
||||||
this.show_both = false
|
this.show_both = false
|
||||||
},
|
},
|
||||||
change_both: function (event) {
|
change_both: function () {
|
||||||
this.show_as_found = false
|
this.show_as_found = false
|
||||||
this.show_as_left = false
|
this.show_as_left = false
|
||||||
},
|
},
|
||||||
watchFileInput: function () {
|
|
||||||
// will notify a file input
|
|
||||||
$('input[type="file"]').change(this.notifyFileInput.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
notifyFileInput: function (event) {
|
notifyFileInput: function (event) {
|
||||||
// update file name value
|
// update file name value
|
||||||
this.file = event.target.files[0].name;
|
this.file = event.target.files[0].name;
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
ready: () => {
|
||||||
|
$('input[type="file"]').change(this.notifyFileInput.bind(this));
|
||||||
}
|
}
|
||||||
}).mount("#app")
|
}).mount("#app")
|
||||||
</script>
|
</script>
|
||||||
|
@ -2,5 +2,5 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.upload_file, name = 'upload')
|
path('', views.upload_file, name = 'upload'),
|
||||||
]
|
]
|
@ -17,9 +17,11 @@ def upload_file(request):
|
|||||||
if both:
|
if both:
|
||||||
if data['report_type'] == "TV":
|
if data['report_type'] == "TV":
|
||||||
tv = parse_transducer(both.read().decode(), data['accuracy'])
|
tv = parse_transducer(both.read().decode(), data['accuracy'])
|
||||||
|
f.transducer_type = tv["Transducer Type"]
|
||||||
else:
|
else:
|
||||||
hc = parse_hardware_calibration(both.read().decode(), data['accuracy'])
|
hc = parse_hardware_calibration(both.read().decode(), data['accuracy'])
|
||||||
elif as_found and as_left:
|
elif as_found and as_left:
|
||||||
|
# TODO: DO THIS
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise ValidationError("Please provide proper files")
|
raise ValidationError("Please provide proper files")
|
||||||
|
Loading…
Reference in New Issue
Block a user