File tree 3 files changed +10
-24
lines changed
3 files changed +10
-24
lines changed Original file line number Diff line number Diff line change @@ -150,17 +150,8 @@ class ContractStates(Enum):
150
150
COMPLETED = 3
151
151
UPCOMING = 4
152
152
153
-
154
- def get_filter_button_label (state : ContractStates ):
155
- """Returns the label for the given state"""
156
- if state .value == ContractStates .ACTIVE .value :
157
- return "Active"
158
- elif state .value == ContractStates .UPCOMING .value :
159
- return "Upcoming"
160
- elif state .value == ContractStates .COMPLETED .value :
161
- return "Completed"
162
- else :
163
- return "All"
153
+ def __str__ (self ):
154
+ return self .name .capitalize ()
164
155
165
156
166
157
def get_filter_button_tooltip (state : ContractStates ):
@@ -224,7 +215,7 @@ def set_filter_buttons(self):
224
215
"""Sets all the filter buttons"""
225
216
for state in ContractStates :
226
217
button = self .filter_button (
227
- label = get_filter_button_label ( state ),
218
+ label = state . __str__ ( ),
228
219
state = state ,
229
220
onClick = self .on_filter_button_clicked ,
230
221
tooltip = get_filter_button_tooltip (state ),
Original file line number Diff line number Diff line change @@ -205,17 +205,8 @@ class ProjectStates(Enum):
205
205
COMPLETED = 3
206
206
UPCOMING = 4
207
207
208
-
209
- def get_filter_button_label (state : ProjectStates ):
210
- """returns the label for the filter button"""
211
- if state .value == ProjectStates .ACTIVE .value :
212
- return "Active"
213
- elif state .value == ProjectStates .UPCOMING .value :
214
- return "Upcoming"
215
- elif state .value == ProjectStates .COMPLETED .value :
216
- return "Completed"
217
- else :
218
- return "All"
208
+ def __str__ (self ):
209
+ return self .name .capitalize ()
219
210
220
211
221
212
def get_filter_button_tooltip (state : ProjectStates ):
@@ -279,7 +270,7 @@ def set_filter_buttons(self):
279
270
"""sets the filter buttons for each project state"""
280
271
for state in ProjectStates :
281
272
button = self .filter_button (
282
- label = get_filter_button_label ( state ),
273
+ label = state . __str__ ( ),
283
274
state = state ,
284
275
onClick = self .on_filter_button_clicked ,
285
276
tooltip = get_filter_button_tooltip (state ),
Original file line number Diff line number Diff line change @@ -350,6 +350,8 @@ def is_active(self) -> bool:
350
350
"""Check if contract is active.A contract is active if it is not completed and the end date is in the future."""
351
351
if self .is_completed :
352
352
return False
353
+ if self .is_upcoming ():
354
+ return False
353
355
if self .end_date :
354
356
today = datetime .date .today ()
355
357
return self .end_date > today
@@ -440,6 +442,8 @@ def is_active(self) -> bool:
440
442
"""Is the project active? A project is active if it is not completed and if the end date is in the future."""
441
443
if self .is_completed :
442
444
return False
445
+ if self .is_upcoming ():
446
+ return False
443
447
if self .end_date :
444
448
today = datetime .date .today ()
445
449
return self .end_date >= today
You can’t perform that action at this time.
0 commit comments