Coverage for core/choices.py: 100%
39 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1from django.utils.translation import gettext_lazy as _
3from utilities.choices import Choice, ChoiceSet
5#
6# Data sources
7#
10class DataSourceStatusChoices(ChoiceSet):
11 NEW = 'new'
12 QUEUED = 'queued'
13 SYNCING = 'syncing'
14 COMPLETED = 'completed'
15 FAILED = 'failed'
17 CHOICES = (
18 Choice(NEW, _('New'), color='blue', description=_('Newly created and not yet synchronized')),
19 Choice(QUEUED, _('Queued'), color='orange', description=_('Queued for synchronization')),
20 Choice(SYNCING, _('Syncing'), color='cyan', description=_('Synchronization in progress')),
21 Choice(COMPLETED, _('Completed'), color='green', description=_('Most recent synchronization succeeded')),
22 Choice(FAILED, _('Failed'), color='red', description=_('Most recent synchronization failed')),
23 )
26#
27# Managed files
28#
30class ManagedFileRootPathChoices(ChoiceSet):
31 SCRIPTS = 'scripts' # settings.SCRIPTS_ROOT
32 REPORTS = 'reports' # settings.REPORTS_ROOT
34 CHOICES = (
35 Choice(SCRIPTS, _('Scripts')),
36 Choice(REPORTS, _('Reports')),
37 )
40#
41# Jobs
42#
44class JobStatusChoices(ChoiceSet):
46 STATUS_PENDING = 'pending'
47 STATUS_SCHEDULED = 'scheduled'
48 STATUS_RUNNING = 'running'
49 STATUS_COMPLETED = 'completed'
50 STATUS_ERRORED = 'errored'
51 STATUS_FAILED = 'failed'
53 CHOICES = (
54 Choice(STATUS_PENDING, _('Pending'), color='cyan', description=_('Awaiting execution')),
55 Choice(STATUS_SCHEDULED, _('Scheduled'), color='gray', description=_('Scheduled to run at a future time')),
56 Choice(STATUS_RUNNING, _('Running'), color='blue', description=_('Currently executing')),
57 Choice(STATUS_COMPLETED, _('Completed'), color='green', description=_('Finished successfully')),
58 Choice(STATUS_ERRORED, _('Errored'), color='red', description=_('Terminated due to an unhandled error')),
59 Choice(STATUS_FAILED, _('Failed'), color='red', description=_('Failed to complete')),
60 )
62 ENQUEUED_STATE_CHOICES = (
63 STATUS_PENDING,
64 STATUS_SCHEDULED,
65 STATUS_RUNNING,
66 )
68 TERMINAL_STATE_CHOICES = (
69 STATUS_COMPLETED,
70 STATUS_ERRORED,
71 STATUS_FAILED,
72 )
75class JobNotificationChoices(ChoiceSet):
76 NOTIFICATION_ALWAYS = 'always'
77 NOTIFICATION_ON_FAILURE = 'on_failure'
78 NOTIFICATION_NEVER = 'never'
80 CHOICES = (
81 Choice(NOTIFICATION_ALWAYS, _('Always'), description=_('Notify after every job execution')),
82 Choice(NOTIFICATION_ON_FAILURE, _('On failure'), description=_('Notify only when a job fails')),
83 Choice(NOTIFICATION_NEVER, _('Never'), description=_('Never send job notifications')),
84 )
87class JobIntervalChoices(ChoiceSet):
88 INTERVAL_MINUTELY = 1
89 INTERVAL_HOURLY = 60
90 INTERVAL_DAILY = 60 * 24
91 INTERVAL_WEEKLY = 60 * 24 * 7
93 CHOICES = (
94 Choice(INTERVAL_MINUTELY, _('Minutely')),
95 Choice(INTERVAL_HOURLY, _('Hourly')),
96 Choice(INTERVAL_HOURLY * 12, _('12 hours')),
97 Choice(INTERVAL_DAILY, _('Daily')),
98 Choice(INTERVAL_WEEKLY, _('Weekly')),
99 Choice(INTERVAL_DAILY * 30, _('30 days')),
100 )
103#
104# ObjectChanges
105#
107class ObjectChangeActionChoices(ChoiceSet):
109 ACTION_CREATE = 'create'
110 ACTION_UPDATE = 'update'
111 ACTION_DELETE = 'delete'
113 CHOICES = (
114 Choice(ACTION_CREATE, _('Created'), color='green'),
115 Choice(ACTION_UPDATE, _('Updated'), color='blue'),
116 Choice(ACTION_DELETE, _('Deleted'), color='red'),
117 )