Skip to content

Commit b2a7f56

Browse files
Valentina Khudiakovaauvipy
Valentina Khudiakova
authored andcommitted
Issue 796: remove days of the week from human readable description when the whole week is specified
1 parent b31fde0 commit b2a7f56

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

django_celery_beat/models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ def human_readable(self):
325325
day_of_month=self.day_of_month,
326326
month_of_year=self.month_of_year,
327327
)
328-
day_of_week = cronexp(",".join(str(day) for day in c.day_of_week))
328+
if c.day_of_week and set(c.day_of_week) == set(range(7)):
329+
day_of_week = "*"
330+
else:
331+
day_of_week = cronexp(",".join(map(str, c.day_of_week)))
329332
except ValueError:
330333
day_of_week = cronexp(self.day_of_week)
331334

t/unit/test_models.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,16 @@ def test_invalid(self):
234234
def test_long_name(self):
235235
"""Long day name display."""
236236
for day_day_of_week, expected in (
237-
("1", "Monday"),
238-
("mon", "Monday"),
239-
("Monday,tue", "Monday and Tuesday"),
240-
("sat-sun/2", "Saturday"),
241-
("mon-wed", "Monday, Tuesday, and Wednesday"),
237+
("1", ", only on Monday"),
238+
("mon", ", only on Monday"),
239+
("Monday,tue", ", only on Monday and Tuesday"),
240+
("sat-sun/2", ", only on Saturday"),
241+
("mon-wed", ", only on Monday, Tuesday, and Wednesday"),
242+
("*", ""),
243+
("0-6", ""),
244+
("2-1", ""),
245+
("mon-sun", ""),
246+
("tue-mon", ""),
242247
):
243248
cron = CrontabSchedule.objects.create(
244249
hour="2",
@@ -247,5 +252,7 @@ def test_long_name(self):
247252
)
248253

249254
self.assertEqual(
250-
cron.human_readable, f"At 02:00 AM, only on {expected} UTC"
255+
cron.human_readable,
256+
f"At 02:00 AM{expected} UTC",
257+
day_day_of_week,
251258
)

0 commit comments

Comments
 (0)