Skip to content

Commit

Permalink
Adding inline to each schedule admin to show PeriodicTasks using the …
Browse files Browse the repository at this point in the history
…schedule

For issue celery#742
  • Loading branch information
dougharris committed Mar 11, 2024
1 parent 9ea17af commit 797dbf1
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions django_celery_beat/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,24 @@ def run_tasks(self, request, queryset):
)


class PeriodicTaskInline(admin.TabularInline):
model = PeriodicTask
fields = ('name', 'task', 'args', 'kwargs')
readonly_fields = fields
can_delete = False
extra = 0
show_change_link = True
verbose_name = "Periodic Tasks Using This Schedule"
verbose_name_plural = verbose_name

def has_add_permission(self, request, obj):
return False

class ScheduleAdmin(admin.ModelAdmin):
inlines = [PeriodicTaskInline]

@admin.register(ClockedSchedule)
class ClockedScheduleAdmin(admin.ModelAdmin):
class ClockedScheduleAdmin(ScheduleAdmin):
"""Admin-interface for clocked schedules."""

fields = (
Expand All @@ -272,13 +288,21 @@ class ClockedScheduleAdmin(admin.ModelAdmin):
'clocked_time',
)


@admin.register(CrontabSchedule)
class CrontabScheduleAdmin(admin.ModelAdmin):
class CrontabScheduleAdmin(ScheduleAdmin):
"""Admin class for CrontabSchedule."""

list_display = ('__str__', 'human_readable')


admin.site.register(IntervalSchedule)
admin.site.register(SolarSchedule)
fields = ('human_readable', 'minute', 'hour', 'day_of_month',
'month_of_year', 'day_of_week', 'timezone')
readonly_fields = ('human_readable', )

@admin.register(SolarSchedule)
class SolarScheduleAdmin(ScheduleAdmin):
"""Admin class for SolarSchedule."""
pass

@admin.register(IntervalSchedule)
class IntervalScheduleAdmin(ScheduleAdmin):
"""Admin class for IntervalSchedule."""
pass

0 comments on commit 797dbf1

Please sign in to comment.