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 #742
  • Loading branch information
dougharris committed Mar 11, 2024
1 parent 9ea17af commit 962dc97
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions django_celery_beat/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,26 @@ 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 @@ -274,11 +292,22 @@ class ClockedScheduleAdmin(admin.ModelAdmin):


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

list_display = ('__str__', 'human_readable')
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.site.register(IntervalSchedule)
admin.site.register(SolarSchedule)
@admin.register(IntervalSchedule)
class IntervalScheduleAdmin(ScheduleAdmin):
"""Admin class for IntervalSchedule."""
pass

0 comments on commit 962dc97

Please sign in to comment.