Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from django.utils.translation import gettext_lazy as _
2from superdjango import ui
3from .models import Activity, Job
5# Inlines
8class ActivityInline(ui.InlineModelUI):
9 model = Activity
11 controls = {
12 'cached_success': ui.controls.BooleanControl(align="center", css_icon=True),
13 }
15 detail_options = ui.InlineDetailOptions(
16 "job",
17 "added_dt",
18 "start_dt",
19 "end_dt",
20 "elapsed_time",
21 "status",
22 "cached_success",
23 "message",
24 "output",
25 )
27# Models
30class ActivityUI(ui.ModelUI):
31 model = Activity
33 controls = {
34 'cached_success': ui.controls.BooleanControl(align="center", css_icon=True),
35 }
37 detail_options = ui.DetailOptions(
38 "cached_job_label",
39 "added_dt",
40 "start_dt",
41 "end_dt",
42 "elapsed_time",
43 "status",
44 "cached_success",
45 "message",
46 "output",
47 )
48 list_options = ui.ListOptions(
49 "cached_job_label",
50 "added_dt",
51 "start_dt",
52 "end_dt",
53 "elapsed_time",
54 "status",
55 "cached_success",
56 filtering=ui.Filtering("status", "cached_success"),
57 link_field="cached_job_label"
58 )
61class JobUI(ui.ModelUI):
62 model = Job
64 controls = {
65 'is_active': ui.controls.BooleanControl(align="center", css_icon=True),
66 }
68 detail_options = ui.DetailOptions(
69 "app_name",
70 "label",
71 "description",
72 "at",
73 "interval",
74 "frequency",
75 "is_active",
76 "callback",
77 inlines=[
78 ActivityInline,
79 ],
80 orientation=ui.ORIENTATION.HORIZONTAL
81 )
82 list_options = ui.ListOptions(
83 "label",
84 "app_name",
85 "at",
86 "interval",
87 "frequency",
88 "is_active",
89 filtering=ui.Filtering("frequency", "is_active"),
90 link_field="label"
91 )
94# Menus
97class ScheduledJobsMenu(ui.Menu):
98 icon = "fas fa-clock"
99 items = [
100 JobUI,
101 ActivityUI,
102 ]
103 prefix = "scheduled-jobs"
104 label = _("Scheduled Jobs")