mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-24 08:52:15 +00:00
Merge branch 'master' into assets_audit
# Conflicts: # assets/models.py # Migrations
This commit is contained in:
17
assets/migrations/0015_remove_asset_next_sched_maint.py
Normal file
17
assets/migrations/0015_remove_asset_next_sched_maint.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.0.3 on 2020-04-13 15:13
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0014_auto_20200218_1840'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='asset',
|
||||||
|
name='next_sched_maint',
|
||||||
|
),
|
||||||
|
]
|
||||||
34
assets/migrations/0016_auto_20200413_1632.py
Normal file
34
assets/migrations/0016_auto_20200413_1632.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 3.0.3 on 2020-04-13 15:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0015_remove_asset_next_sched_maint'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cabletype',
|
||||||
|
name='circuits',
|
||||||
|
field=models.IntegerField(default=1),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cabletype',
|
||||||
|
name='cores',
|
||||||
|
field=models.IntegerField(default=3),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cabletype',
|
||||||
|
name='plug',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='plug', to='assets.Connector'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cabletype',
|
||||||
|
name='socket',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='socket', to='assets.Connector'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -9,7 +9,7 @@ from django.dispatch.dispatcher import receiver
|
|||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
|
||||||
from RIGS.models import RevisionMixin, Profile
|
from RIGS.models import RevisionMixin
|
||||||
|
|
||||||
|
|
||||||
class AssetCategory(models.Model):
|
class AssetCategory(models.Model):
|
||||||
@@ -63,19 +63,23 @@ class Connector(models.Model):
|
|||||||
return self.description
|
return self.description
|
||||||
|
|
||||||
|
|
||||||
|
# Things are nullable that shouldn't be because I didn't properly fix the data structure when moving this to its own model...
|
||||||
class CableType(models.Model):
|
class CableType(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['plug', 'socket', '-circuits']
|
ordering = ['plug', 'socket', '-circuits']
|
||||||
|
|
||||||
circuits = models.IntegerField(blank=True, null=True)
|
circuits = models.IntegerField(default=1)
|
||||||
cores = models.IntegerField(blank=True, null=True)
|
cores = models.IntegerField(default=3)
|
||||||
plug = models.ForeignKey(Connector, on_delete=models.SET_NULL,
|
plug = models.ForeignKey(Connector, on_delete=models.CASCADE,
|
||||||
related_name='plug', blank=True, null=True)
|
related_name='plug', null=True)
|
||||||
socket = models.ForeignKey(Connector, on_delete=models.SET_NULL,
|
socket = models.ForeignKey(Connector, on_delete=models.CASCADE,
|
||||||
related_name='socket', blank=True, null=True)
|
related_name='socket', null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s → %s" % (self.plug.description, self.socket.description)
|
if self.plug and self.socket:
|
||||||
|
return "%s → %s" % (self.plug.description, self.socket.description)
|
||||||
|
else:
|
||||||
|
return "Unknown"
|
||||||
|
|
||||||
|
|
||||||
@reversion.register
|
@reversion.register
|
||||||
@@ -99,12 +103,6 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
||||||
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10)
|
||||||
comments = models.TextField(blank=True)
|
comments = models.TextField(blank=True)
|
||||||
# TODO Remove
|
|
||||||
next_sched_maint = models.DateField(blank=True, null=True)
|
|
||||||
|
|
||||||
# Audit
|
|
||||||
last_audited_at = models.DateTimeField(blank=True, null=True)
|
|
||||||
last_audited_by = models.ForeignKey(Profile, on_delete=models.SET_NULL, related_name='audited_by', blank=True, null=True)
|
|
||||||
|
|
||||||
# Cable assets
|
# Cable assets
|
||||||
is_cable = models.BooleanField(default=False)
|
is_cable = models.BooleanField(default=False)
|
||||||
@@ -112,7 +110,7 @@ class Asset(models.Model, RevisionMixin):
|
|||||||
length = models.DecimalField(decimal_places=1, max_digits=10,
|
length = models.DecimalField(decimal_places=1, max_digits=10,
|
||||||
blank=True, null=True, help_text='m')
|
blank=True, null=True, help_text='m')
|
||||||
csa = models.DecimalField(decimal_places=2, max_digits=10,
|
csa = models.DecimalField(decimal_places=2, max_digits=10,
|
||||||
blank=True, null=True, help_text='mm²')
|
blank=True, null=True, help_text='mm^2')
|
||||||
|
|
||||||
# Hidden asset_id components
|
# Hidden asset_id components
|
||||||
# For example, if asset_id was "C1001" then asset_id_prefix would be "C" and number "1001"
|
# For example, if asset_id was "C1001" then asset_id_prefix would be "C" and number "1001"
|
||||||
|
|||||||
Reference in New Issue
Block a user