1
0
Fork 0
mirror of https://github.com/Findus23/RPGnotes.git synced 2024-09-19 15:43:45 +02:00
RPGnotes/loot/models.py

29 lines
979 B
Python
Raw Normal View History

2021-08-22 20:10:29 +02:00
from django.db import models
from simple_history.models import HistoricalRecords
2021-08-29 22:09:22 +02:00
from characters.models import Character
from common.models import DescriptionModel
2021-09-06 20:34:43 +02:00
from locations.models import Location
2021-08-22 20:10:29 +02:00
class Loot(DescriptionModel):
name = models.CharField(max_length=1000)
quantity = models.PositiveSmallIntegerField()
value_gold = models.DecimalField("Value (Gold)", max_digits=7, decimal_places=2)
2021-08-29 16:45:40 +02:00
owner = models.ForeignKey(Character, on_delete=models.PROTECT, blank=True, null=True)
2021-09-06 20:34:43 +02:00
location = models.ForeignKey(Location, on_delete=models.PROTECT, blank=True, null=True)
2021-08-22 20:10:29 +02:00
magic_item = models.BooleanField(default=False)
created = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
history = HistoricalRecords()
2021-08-28 19:52:07 +02:00
class Meta:
ordering = ["name"]
2021-08-22 20:10:29 +02:00
@property
def value_per_unit(self):
return self.value_gold / self.quantity
def __str__(self):
return self.name