-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimprovement.py
71 lines (53 loc) · 1.67 KB
/
improvement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Improvement(object):
IMPROVEMENTS = []
def __init__(self, uuid, name):
self.improvements = 1
self.uuid = uuid
self.name = name
if not self.contains_improvement(uuid):
Improvement.IMPROVEMENTS.append(self)
def increment_improvements(self):
self.improvements += 1
@classmethod
def contains_improvement(cls, uuid):
for i in cls.IMPROVEMENTS:
if i.uuid == uuid:
i.increment_improvements()
return True
return False
@classmethod
def get_all_improvements(cls):
data = []
for i in cls.IMPROVEMENTS:
data.append(i.convert_json())
cls.IMPROVEMENTS = []
return data
@classmethod
def has_elements(cls):
return len(cls.IMPROVEMENTS) != 0
class EmployeeImprovements(Improvement):
def __init__(self, uuid, name, occupation):
super(EmployeeImprovements, self).__init__(uuid, name)
self.occupation = occupation
def convert_json(self):
return {
"type": "EmployeeImprovements",
"id": self.uuid,
"attributes": {
"name": self.name,
"count": self.improvements,
"occupation": self.occupation
}
}
class SkillImprovements(Improvement):
def __init__(self, uuid, name):
super(SkillImprovements, self).__init__(uuid, name)
def convert_json(self):
return {
"type": "SkillImprovements",
"id": self.uuid,
"attributes": {
"name": self.name,
"count": self.improvements
}
}