remove the hostname attribute from Computer
The device name should be used as a hostname for computers
This commit is contained in:
parent
36bee7ba1f
commit
34b91ca1bf
|
@ -206,7 +206,6 @@ warranty.
|
|||
|
||||
#+BEGIN_SRC python :tangle ../inventory/models.py :padline 2
|
||||
class Computer(Device):
|
||||
hostname = models.CharField(max_length=20, unique=True)
|
||||
os = models.ForeignKey(OperatingSystem, on_delete=models.PROTECT)
|
||||
cpu = models.ManyToManyField(Cpu, through='ComputerCpuRelation')
|
||||
ram = models.ManyToManyField(Ram, through='ComputerRamRelation')
|
||||
|
@ -216,7 +215,7 @@ class Computer(Device):
|
|||
on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.hostname)
|
||||
return str(self.name)
|
||||
#+END_SRC
|
||||
|
||||
** ComputerDiskRelation, ComputerRamRelation and ComputerCpuRelation
|
||||
|
@ -233,7 +232,7 @@ class ComputerDiskRelation(models.Model):
|
|||
on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Disks in Computer"
|
||||
|
@ -245,7 +244,7 @@ class ComputerRamRelation(models.Model):
|
|||
amount = models.IntegerField()
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "RAM Modules in Computer"
|
||||
|
@ -257,7 +256,7 @@ class ComputerCpuRelation(models.Model):
|
|||
amount = models.IntegerField()
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "CPUs in Computer"
|
||||
|
@ -346,7 +345,7 @@ class CpusInLine(admin.StackedInline):
|
|||
|
||||
|
||||
class ComputerAdmin(admin.ModelAdmin):
|
||||
list_display = ('hostname', 'ip', 'host')
|
||||
list_display = ('name', 'ip', 'host')
|
||||
inlines = (CpusInLine, RamInLine, DiskInLine,)
|
||||
#+END_SRC
|
||||
|
||||
|
@ -557,7 +556,6 @@ The computer details show all the known information about the selected computer.
|
|||
{% block content %}
|
||||
<h3>Description</h3>
|
||||
<p>{{ computer.description }}</p>
|
||||
<p><b>Hostname:</b> {{ computer.hostname }}</p>
|
||||
<p><b>OS:</b> {{ computer.os }}</p>
|
||||
<p><b>CPU:</b> {{ cpu.cpu }}</p>
|
||||
<p><b>RAM Modules: </b>{{ram.amount}}x {{ ram.ram }}</p>
|
||||
|
|
|
@ -26,7 +26,7 @@ class CpusInLine(admin.StackedInline):
|
|||
|
||||
|
||||
class ComputerAdmin(admin.ModelAdmin):
|
||||
list_display = ('hostname', 'ip', 'host')
|
||||
list_display = ('name', 'ip', 'host')
|
||||
inlines = (CpusInLine, RamInLine, DiskInLine,)
|
||||
|
||||
|
||||
|
|
|
@ -145,7 +145,6 @@ class Raid(models.Model):
|
|||
|
||||
|
||||
class Computer(Device):
|
||||
hostname = models.CharField(max_length=20, unique=True)
|
||||
os = models.ForeignKey(OperatingSystem, on_delete=models.PROTECT)
|
||||
cpu = models.ManyToManyField(Cpu, through='ComputerCpuRelation')
|
||||
ram = models.ManyToManyField(Ram, through='ComputerRamRelation')
|
||||
|
@ -155,7 +154,7 @@ class Computer(Device):
|
|||
on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.hostname)
|
||||
return str(self.name)
|
||||
|
||||
|
||||
class ComputerDiskRelation(models.Model):
|
||||
|
@ -166,7 +165,7 @@ class ComputerDiskRelation(models.Model):
|
|||
on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Disks in Computer"
|
||||
|
@ -178,7 +177,7 @@ class ComputerRamRelation(models.Model):
|
|||
amount = models.IntegerField()
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "RAM Modules in Computer"
|
||||
|
@ -190,7 +189,7 @@ class ComputerCpuRelation(models.Model):
|
|||
amount = models.IntegerField()
|
||||
|
||||
def __str__(self):
|
||||
return self.computer.hostname
|
||||
return self.computer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "CPUs in Computer"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
{% block content %}
|
||||
<h3>Description</h3>
|
||||
<p>{{ computer.description }}</p>
|
||||
<p><b>Hostname:</b> {{ computer.hostname }}</p>
|
||||
<p><b>OS:</b> {{ computer.os }}</p>
|
||||
<p><b>CPU:</b> {{ cpu.cpu }}</p>
|
||||
<p><b>RAM Modules: </b>{{ram.amount}}x {{ ram.ram }}</p>
|
||||
|
|
Loading…
Reference in New Issue