|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- from django.db import models
- import random
-
-
- # attributeset für worker skills und order workload
- class AttributeSet(models.Model):
- experience = models.IntegerField(default=10)
- reliability = models.IntegerField(default=10)
- python = models.IntegerField(default=10)
- javascript = models.IntegerField(default=10)
- cpp = models.IntegerField(default=10)
- management = models.IntegerField(default=10)
-
- def __str__(self):
- return "AttributeSet"
-
- @classmethod
- def createRandom(cls, median):
- attributelist = []
- for j in range(6):
- randnumber = round(random.uniform(0.5, 1.5) * (median))
- # if randnumber > 100:
- # randnumber = 100
- attributelist.append(randnumber)
- attributeset = cls(
- experience=attributelist[0],
- reliability=attributelist[1],
- python=attributelist[2],
- javascript=attributelist[3],
- cpp=attributelist[4],
- management=attributelist[5],
- )
- attributeset.save()
- return attributeset
-
- def increase(self, amount, attribute):
- if attribute in [
- "experience",
- "reliability",
- "python",
- "javascript",
- "cpp",
- "management",
- ]:
- setattr(self, attribute, (getattr(self, attribute) + amount))
- self.save()
|