Blame view

src/core/pyros_django/scheduler/UserManager.py 1.05 KB
bca9a283   Jeremy   Reworked the sche...
1
from common.models import *
43e6176d   Etienne Pallier   Model splitting g...
2
3
from routine_manager.models import Sequence

bca9a283   Jeremy   Reworked the sche...
4
5
6
from utils.Logger import *
from decimal import *

a6e63604   Alexis Koralewski   adding agentSP an...
7
class UserQuotaManager(Logger):
bca9a283   Jeremy   Reworked the sche...
8
9
10
11
12
13
14
15
    REJECTED = "Insufficient quota"

    def __init__(self, user: PyrosUser):
        super().__init__("UserManager", "UserManager")
        self.user = user

    @classmethod
    def determineQuota(cls, sequence: Sequence) -> float:
2fdcd8bb   Alexis Koralewski   adapt tests to ne...
16
17
        #TODO : change return value (quota isn't associated with PyrosUser)
        return 100
bca9a283   Jeremy   Reworked the sche...
18
19
20
21
        return sequence.request.pyros_user.quota

    @classmethod
    def isSufficient(cls, quota: float, sequence: Sequence) -> bool:
e573c1f1   Etienne Pallier   All unit tests no...
22
23
        #print("seq is", sequence.duration)
        #print("quota is", quota)
bca9a283   Jeremy   Reworked the sche...
24
25
26
27
28
29
30
31
32
        if quota < sequence.duration:
            return False
        return True

    @classmethod
    def determinePriority(cls, sequence: Sequence) -> float:
        return 0

    def decreaseQuota(self, value: Decimal) -> int:
2fdcd8bb   Alexis Koralewski   adapt tests to ne...
33
34
35
        #TODO : update this method according to new models
        #self.user.quota -= float(value)
        #self.user.save()
bca9a283   Jeremy   Reworked the sche...
36
        return 0