Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding inline to each schedule admin to show PeriodicTasks using the schedule #743

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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