more fields

This commit is contained in:
Tyrel Souza 2023-10-05 11:34:22 -04:00
parent 13bbc4705a
commit 4df6c209f4
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
10 changed files with 142 additions and 135 deletions

View File

@ -38,7 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'sheets'
'sheets',
'rest_framework',
]
MIDDLEWARE = [

View File

@ -1,3 +1,4 @@
django
psycopg2-binary
django-debug-toolbar
django-rest-framework

View File

@ -16,6 +16,8 @@ class SheetForm(forms.ModelForm):
"technician",
"instrument_model",
"instrument_calibration_date",
"instrument_calibration_due_date",
"serial_number",
"channel",
"transducer_model",
@ -32,6 +34,8 @@ class SheetForm(forms.ModelForm):
"temperature",
"humidity",
"report_type",
"transducer_type",
"as_found",
"as_left",
"both",
@ -42,9 +46,10 @@ class SheetForm(forms.ModelForm):
"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(),
"calibration_date": forms.SelectDateWidget(years=range(2020, 2030)),
"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):

View 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),
),
]

View File

@ -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),
),
]

View File

@ -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,
),
]

View File

@ -4,6 +4,8 @@ from django.utils.translation import gettext_lazy as _
class Sheet(models.Model):
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)
channel = models.CharField(max_length=256)
transducer_model = models.CharField(max_length=256)
@ -36,6 +38,17 @@ class Sheet(models.Model):
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_left = models.FileField(blank=True)
both = models.FileField(blank=True)
both = models.FileField(blank=True)

View File

@ -1,20 +1,16 @@
<html lang="en">
<head>
<!--? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/css/foundation.min.css"-->
<!--? crossorigin="anonymous">-->
<!--? <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/js/foundation.min.js"-->
<!--? crossorigin="anonymous"></script>-->
<!--? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/css/foundation.min.css"-->
<!--? crossorigin="anonymous">-->
<!--? <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.8.1/dist/js/foundation.min.js"-->
<!--? 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">
<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 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>
<style>
.app {
@ -32,136 +28,59 @@
{% csrf_token %}
<table class="table table-striped">
<thead>
<tr>
<th colspan="2"><h2>Customer</h2></th>
</tr>
<tr><th colspan="2"><h2>Customer</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Customer Name</td>
<td>{{ form.customer_name }}</td>
</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>
<tr><td>Customer Name</td><td>{{ form.customer_name }}</td></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>
<thead>
<tr>
<th colspan="2"><h2>Instrument</h2></th>
</tr>
<tr><th colspan="2"><h2>Instrument</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Model:</td>
<td>{{ form.instrument_model }}</td>
</tr>
<tr>
<td>Serial Number</td>
<td>{{ form.serial_number }}</td>
</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>
<tr><td>Model:</td><td>{{ form.instrument_model }}</td></tr>
<tr><td>Calibration Date:</td><td>{{ form.instrument_calibration_date }}</td></tr>
<tr><td>Calibration Due Date:</td><td>{{ form.instrument_calibration_due_date }}</td></tr>
<tr><td>Serial Number</td><td>{{ form.serial_number }}</td></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>
<thead>
<tr>
<th colspan="2"><h2>Primary Calibration Device</h2></th>
</tr>
<tr><th colspan="2"><h2>Primary Calibration Device</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Model</td>
<td>{{ form.calibration_model }}</td>
</tr>
<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>
<tr><td>Model</td><td>{{ form.calibration_model }}</td></tr>
<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>
<thead>
<tr>
<th colspan="2"><h2>Environment</h2></th>
</tr>
<tr><th colspan="2"><h2>Environment</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Accuracy</td>
<td>{{ form.accuracy }}</td>
</tr>
<tr>
<td>Barometric Pressure (mbar)</td>
<td>{{ form.barometric_pressure }}</td>
</tr>
<tr>
<td>Temperature (&deg;F)</td>
<td>{{ form.temperature }}</td>
</tr>
<tr>
<td>Humidity</td>
<td>{{ form.humidity }}</td>
</tr>
<tr><td>Accuracy</td><td>{{ form.accuracy }}</td></tr>
<tr><td>Barometric Pressure (mbar)</td><td>{{ form.barometric_pressure }}</td></tr>
<tr><td>Temperature (&deg;F)</td><td>{{ form.temperature }}</td></tr>
<tr><td>Humidity</td><td>{{ form.humidity }}</td></tr>
</tbody>
<thead>
<tr>
<th colspan="2"><h2>Report Uploads</h2></th>
</tr>
<tr><th colspan="2"><h2>Report Uploads</h2></th></tr>
</thead>
<tbody>
<tr>
<td>Report Type</td>
<td>{{ form.report_type }}</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>&nbsp;</td>
<td align="right"><input type="submit" value="Generate PDF and Label"></td>
</tr>
<tr><td>Report Type</td><td>{{ form.report_type }}</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>&nbsp;</td><td align="right"><input type="submit" value="Generate PDF and Label"></td></tr>
</tbody>
</table>
</form>
</div>
@ -171,11 +90,11 @@
// Vue.config.delimiters = ['${', '}'];
const vm = createApp({
el: "#app",
data() {
const as_found = ""
const as_left = ""
const both = ""
const report_type = ""
const accuracy = ref("0.5")
const barometric_pressure = ref(1013.25)
const temperature = ref("50")
@ -183,6 +102,7 @@
const show_as_found = reactive(true)
const show_as_left = reactive(true)
const show_both = reactive(true)
const show_report_type = reactive(true)
return {
accuracy,
@ -192,34 +112,33 @@
as_found,
as_left,
both,
report_type,
show_as_found,
show_as_left,
show_both
show_both,
show_report_type,
}
},
ready: () => {
this.watchFileInput();
},
el: "#app",
methods: {
change_as_found: function (event) {
change_as_found: function () {
this.show_both = false
},
change_as_left: function (event) {
change_as_left: function () {
this.show_both = false
},
change_both: function (event) {
change_both: function () {
this.show_as_found = false
this.show_as_left = false
},
watchFileInput: function () {
// will notify a file input
$('input[type="file"]').change(this.notifyFileInput.bind(this));
},
notifyFileInput: function (event) {
// update file name value
this.file = event.target.files[0].name;
}
},
},
ready: () => {
$('input[type="file"]').change(this.notifyFileInput.bind(this));
}
}).mount("#app")
</script>

View File

@ -2,5 +2,5 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.upload_file, name = 'upload')
path('', views.upload_file, name = 'upload'),
]

View File

@ -17,9 +17,11 @@ def upload_file(request):
if both:
if data['report_type'] == "TV":
tv = parse_transducer(both.read().decode(), data['accuracy'])
f.transducer_type = tv["Transducer Type"]
else:
hc = parse_hardware_calibration(both.read().decode(), data['accuracy'])
elif as_found and as_left:
# TODO: DO THIS
pass
else:
raise ValidationError("Please provide proper files")