Skip to content

Commit dfde9ec

Browse files
committed
Merge remote-tracking branch 'adrien/master'
2 parents e02f5d0 + c253594 commit dfde9ec

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

bot/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ async def check_user_is_declared(update, context):
4747
def outside_business_hours():
4848
"""Don't bother people outside business hours"""
4949
now = datetime.now()
50-
return now.weekday() in (5, 6) or now.hour < 9 or now.hour > 19
50+
today = date.today()
51+
holiday_today = Holiday.objects.filter(day__contains=today)
52+
return now.weekday() in (5, 6) or now.hour < 9 or now.hour > 19 or holiday_today.count() > 0
5153

5254

5355
@db_sync_to_async
@@ -60,10 +62,6 @@ def get_consultants():
6062
@db_sync_to_async
6163
def time_to_declare(consultant):
6264
today = date.today()
63-
holidays = Holiday.objects.all()
64-
if today.weekday() < 5 and today not in holidays:
65-
declared = Timesheet.objects.filter(consultant=consultant, working_date=today).aggregate(Sum("charge"))[
66-
"charge__sum"] or 0
67-
return 1 - declared
68-
else:
69-
return 0
65+
declared = Timesheet.objects.filter(consultant=consultant, working_date=today).aggregate(Sum("charge"))[
66+
"charge__sum"] or 0
67+
return 1 - declared

0 commit comments

Comments
 (0)