class Connection(models.Model):
name = models.CharField(max_length=50)
gender = models.CharField(max_length=20)
class Manufacturer(models.Model):
name = models.CharField(max_length=200)
# other fields describing the mfg location etc.
class Equipment(models.Model):
"""
components in a rack or a speaker or a microphone; anything
that is connected with cables
"""
name = models.CharField(max_length=100)
manufacturer = models.ForeignKey(Manufacturer)
# other fields describing the equipment type, etc.
class EquipmentConnection(models.Model):
"""
this represents any connection on a piece of equipment
there can be many connections per parentEquipment
"""
parentEquipment = models.ForeignKey(Equipment)
connection = models.ForeignKey(Connection)
labelText = models.CharField(max_length=20)
# other fields here relevant to labels
class Cable(models.Model):
"""
This connects to equipment connections, OR connects to each other for extending
OR connects to a BreakoutPair
"""
name = models.CharField(max_length=100)
origin_connection = models.ForeignKey(Connection, related_name="origin_connection")
destination_connection = models.ForeignKey(Connection, related_name="destination_connection")
class CableBreakout(models.Model):
"""
Some cables have "breakouts" or "tails" that are made up of
multiple channels.
Think of it like the 1/8" iPod cable that breaks out to the Red and White
RCA connectors.
The two RCA connectors would be the breakout. This comparison is kinda crappy.
Suffice it to say that this model needs to exist for the next model, BreakoutPair.
"""
name = models.CharField(max_length=100)
cable = models.ForeignKey(Cable)
whichEndOfTheCable = models.CharField(max_length=20) # just to keep track of which side of the cable this breakout is on and to prevent duplicates
class BreakoutPair(models.Model):
"""
there can be many of these related to each Cable Breakout
"""
breakout = models.ForeignKey(CableBreakout)
channel = models.CharField(max_length=20)
labelText = models.CharField(max_length=40)
connection = models.ForeignKey(Connection)
class PatchPoint(models.Model):
"""
here's the question...
I need to keep track of patch points.
A patch point consists of two connections, A and B
It represents the connection point between two items.
For example, plugging in an HDMI cable to a TV would be represented with this.
The HDMI cable connector is pointA and the HDMI port on the TV is pointB
The problem is that each connection can be any of the following:
- Cable.origin_connection, Cable.destination_connection
- BreakoutPair.connection
- EquipmentConnection.connection
I would like to have this as a database table so that I can check for errors
such as "This cable connection is already patched into Equipment Connection X."
and create reports detailing what connections are patched
"""
pointA = ''# ? genericForeignKey? GenericForeignKey would only relate to a Cable, BreakoutPair, or EquipmentConnection instance\
# not a Cable, BreakoutPair or EquipmentConnection field