mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Compare commits
1 Commits
django5
...
data-inges
| Author | SHA1 | Date | |
|---|---|---|---|
| 16d845ad3a |
@@ -3,7 +3,6 @@ from django.db.models import Q
|
|||||||
|
|
||||||
from assets import models
|
from assets import models
|
||||||
|
|
||||||
|
|
||||||
class AssetForm(forms.ModelForm):
|
class AssetForm(forms.ModelForm):
|
||||||
related_models = {
|
related_models = {
|
||||||
'asset': models.Asset,
|
'asset': models.Asset,
|
||||||
|
|||||||
28
assets/templates/cable_test_form.html
Normal file
28
assets/templates/cable_test_form.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'base_assets.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
{% load button from filters %}
|
||||||
|
{% load cache %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if create %}
|
||||||
|
<form method="POST" action="{% url 'cable_test'%}">
|
||||||
|
{% elif edit %}
|
||||||
|
<form method="POST" action="{% url 'cable_test' object.id %}">
|
||||||
|
{% endif %}
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="id" value="{{ object.id|default:0 }}" hidden="">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
{% for field in form %}
|
||||||
|
<div class="form-group">
|
||||||
|
{% include 'partials/form_field.html' with field=field %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<div class="text-right">
|
||||||
|
{% button 'submit' %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
42
assets/testing.py
Normal file
42
assets/testing.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from . import models as am
|
||||||
|
|
||||||
|
|
||||||
|
class Test(models.Model):
|
||||||
|
item = models.ForeignKey(to=am.Asset, on_delete=models.CASCADE)
|
||||||
|
date = models.DateField()
|
||||||
|
tested_by = models.ForeignKey(to='RIGS.Profile', on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
||||||
|
class ElectricalTest(Test):
|
||||||
|
visual = models.BooleanField()
|
||||||
|
remarks = models.TextField()
|
||||||
|
|
||||||
|
|
||||||
|
class CableTest(ElectricalTest):
|
||||||
|
# Should contain X circuit tests, where X is determined by circuits as per cable type
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CircuitTest(models.Model):
|
||||||
|
test = models.ForeignKey(to=CableTest, on_delete=models.CASCADE)
|
||||||
|
continuity = models.DecimalField(help_text='Ω')
|
||||||
|
insulation_resistance = models.DecimalField(help_text='MΩ')
|
||||||
|
|
||||||
|
|
||||||
|
class TestRequirement(models.Model):
|
||||||
|
item = models.ForeignKey(to=am.Asset, on_delete=models.CASCADE)
|
||||||
|
test_type = models.ForeignKey(to=Test, on_delete=models.CASCADE)
|
||||||
|
period = models.IntegerField() # X months
|
||||||
|
|
||||||
|
|
||||||
|
class CableTestForm(forms.ModelForm):
|
||||||
|
class Meta
|
||||||
|
model = CableTest
|
||||||
|
|
||||||
|
|
||||||
|
class CircuitTest(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Choice
|
||||||
|
exclude = ('test',)
|
||||||
@@ -43,4 +43,6 @@ urlpatterns = [
|
|||||||
(views.SupplierCreate.as_view()), name='supplier_create'),
|
(views.SupplierCreate.as_view()), name='supplier_create'),
|
||||||
path('supplier/<int:pk>/edit/', permission_required_with_403('assets.change_supplier')
|
path('supplier/<int:pk>/edit/', permission_required_with_403('assets.change_supplier')
|
||||||
(views.SupplierUpdate.as_view()), name='supplier_update'),
|
(views.SupplierUpdate.as_view()), name='supplier_update'),
|
||||||
|
|
||||||
|
path('testing/<int:pk>/cable_test/' views.AddCableTest.as_view(), name='cable_test'),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from z3c.rml import rml2pdf
|
|||||||
|
|
||||||
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin, \
|
||||||
is_ajax, OEmbedView
|
is_ajax, OEmbedView
|
||||||
from assets import forms, models
|
from assets import forms, models, testing
|
||||||
|
|
||||||
|
|
||||||
class AssetList(LoginRequiredMixin, generic.ListView):
|
class AssetList(LoginRequiredMixin, generic.ListView):
|
||||||
@@ -430,3 +430,8 @@ class GenerateLabels(generic.View):
|
|||||||
response['Content-Disposition'] = f'filename="{name}"'
|
response['Content-Disposition'] = f'filename="{name}"'
|
||||||
response.write(merged.getvalue())
|
response.write(merged.getvalue())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class AddCableTest(generic.CreateView):
|
||||||
|
model = testing.CableTest
|
||||||
|
template = 'cable_test_form.html'
|
||||||
|
|||||||
Reference in New Issue
Block a user