Skip to content

Commit

Permalink
Adding human readable descriptions of crontab schedules (#622)
Browse files Browse the repository at this point in the history
* Adding human-readable descriptions of crontab schedules

* Adding helpful text to days of week.

Updated all .po files with new help string. Added translations for es and de

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updates to make flake8 happy

---------

Co-authored-by: Doug Harris <dharris@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
  • Loading branch information
4 people authored Mar 2, 2023
1 parent 5680798 commit 8f9fd1b
Show file tree
Hide file tree
Showing 17 changed files with 884 additions and 619 deletions.
28 changes: 24 additions & 4 deletions django_celery_beat/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class PeriodicTaskAdmin(admin.ModelAdmin):
'classes': ('extrapretty', 'wide'),
}),
(_('Schedule'), {
'fields': ('interval', 'crontab', 'solar', 'clocked',
'start_time', 'last_run_at', 'one_off'),
'fields': ('interval', 'crontab', 'crontab_translation', 'solar',
'clocked', 'start_time', 'last_run_at', 'one_off'),
'classes': ('extrapretty', 'wide'),
}),
(_('Arguments'), {
Expand All @@ -138,9 +138,25 @@ class PeriodicTaskAdmin(admin.ModelAdmin):
}),
)
readonly_fields = (
'last_run_at',
'last_run_at', 'crontab_translation',
)

def crontab_translation(self, obj):
return obj.crontab.human_readable

change_form_template = 'admin/djcelery/change_periodictask_form.html'

def changeform_view(self, request, object_id=None, form_url='',
extra_context=None):
extra_context = extra_context or {}
crontabs = CrontabSchedule.objects.all()
crontab_dict = {}
for crontab in crontabs:
crontab_dict[crontab.id] = crontab.human_readable
extra_context['readable_crontabs'] = crontab_dict
return super().changeform_view(request, object_id,
extra_context=extra_context)

def changelist_view(self, request, extra_context=None):
extra_context = extra_context or {}
scheduler = getattr(settings, 'CELERY_BEAT_SCHEDULER', None)
Expand Down Expand Up @@ -247,8 +263,12 @@ class ClockedScheduleAdmin(admin.ModelAdmin):
)


class CrontabScheduleAdmin(admin.ModelAdmin):
list_display = ('__str__', 'human_readable')


admin.site.register(IntervalSchedule)
admin.site.register(CrontabSchedule)
admin.site.register(CrontabSchedule, CrontabScheduleAdmin)
admin.site.register(SolarSchedule)
admin.site.register(ClockedSchedule, ClockedScheduleAdmin)
admin.site.register(PeriodicTask, PeriodicTaskAdmin)
Binary file modified django_celery_beat/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 8f9fd1b

Please sign in to comment.