from django.db import models from polymorphic.models import PolymorphicModel import random # EngineeringModel und erbende Klassen class EngineeringModel(PolymorphicModel): name = models.CharField(default="random EngineeringModel", max_length=30) description = models.CharField(default="random description", max_length=200) pros = models.CharField(default="random pro", max_length=100) cons = models.CharField(default="random con", max_length=100) # wird bei zuweisen des models ausgelöst def recalculate(self, order, company): pass # wird bei workload berechnung ausgelöst, wenn workermodel nicht ordermodel def penalty(self, worker, order): worker.calculateHappyness(-5) def bonus(self, worker, order): pass def __str__(self): return self.name def getPros(self): return self.pros.split(",") def getCons(self): return self.cons.split(",") class ModelV(EngineeringModel): def recalculate(self, order, company): # positives # +10 workerSatisfaction +10 happyness company.calculateAllWorkersHappyness(addhappyness=10) company.calculateWorkerSatisfaction(number=10) # +10 customerSatisfaction company.calculateCustomerSatisfaction(10) # negatives # 1: extra work for SOPrototyp und SOChangeRequirement # +10% workload order.changeWorkload(1.1) order.recalculated = True order.save() company.save() class ModelSpiral(EngineeringModel): def recalculate(self, order, company): # positives # 1: BONUS AUF SOPrototyp UND SOChangeRequirement # +10 customerSatisfaciton company.calculateCustomerSatisfaction(10) # negatives # 1: -10 happyness and workersatisfaction company.calculateAllWorkersHappyness(addhappyness=-10) company.calculateWorkerSatisfaction(number=-10) # +10% workload order.changeWorkload(1.1) order.recalculated = True order.save() company.save() class ModelWaterfall(EngineeringModel): def recalculate(self, order, company): # positives # +10 workerSatisfaction +10 happyness company.calculateAllWorkersHappyness(addhappyness=10) company.calculateWorkerSatisfaction(number=10) # -10% workload order.changeWorkload(0.9) # negatives # 1: extra work for SOPrototyp und SOChangeRequirement # -10 customerSatisfaction company.calculateCustomerSatisfaction(-10) order.recalculated = True order.save() company.save() class ModelScrum(EngineeringModel): def recalculate(self, order, company): # positives # 1: BONUS bei SOPrototyp und SOChangeRequirement # 2: +20% if skilledModel of worker is scrum # IN BONUS HIER UNTEN # # negatives # 1: random workload shift zwischen 1% und +20% randnum = round(random.uniform(1.01, 1.2), 2) order.changeWorkload(randnum) # -40% auf skills wenn skilled model nicht scrum # IN ORDER.CALCULATEWORKLOAD order.recalculated = True order.save() company.save() def bonus(self, worker, order): ampnew = worker.amplifyer + 0.2 return ampnew class ModelChaotic(EngineeringModel): def recalculate(self, order, company): # positives # NIX # negatives: # +10% workload order.changeWorkload(1.1) # -20 workerSatisfaction -10 happyness company.calculateAllWorkersHappyness(addhappyness=-10) company.calculateWorkerSatisfaction(number=-20) # extra work bei prototyp und changerequirement order.recalculated = True order.save() company.save() class ModelHeyJoe(EngineeringModel): def recalculate(self, order, company): # positives # 1: BONUS AUF SOPrototyp UND SOChangeRequirement # +30 customerSatisfaciton company.calculateCustomerSatisfaction(30) # negatives # 1: -10 happyness and workersatisfaction company.calculateAllWorkersHappyness(addhappyness=-15) company.calculateWorkerSatisfaction(number=-15) # +10% workload order.changeWorkload(1.2) order.recalculated = True order.save() company.save()