1 6
import logging
2

3 6
from django.db import models
4

5 6
from cyborgbackup.api.versioning import reverse
6 6
from cyborgbackup.main.models.base import PrimordialModel
7 6
from cyborgbackup.main.models.policies import Policy
8

9 6
analytics_logger = logging.getLogger('cyborgbackup.models.schedule')
10

11 6
__all__ = ['Schedule']
12

13

14 6
class CyborgBackupScheduleState(models.Model):
15 6
    schedule_last_run = models.DateTimeField(auto_now_add=True)
16

17

18 6
class Schedule(PrimordialModel):
19 6
    name = models.CharField(
20
        max_length=1024,
21
    )
22

23 6
    crontab = models.CharField(
24
        max_length=1024,
25
    )
26

27 6
    enabled = models.BooleanField(
28
        default=True
29
    )
30

31 6
    def get_absolute_url(self, request=None):
32 6
        return reverse('api:schedule_detail', kwargs={'pk': self.pk}, request=request)
33

34 6
    def get_ui_url(self):
35 0
        return "/#/schedules/{}".format(self.pk)
36

37 6
    @classmethod
38
    def get_cache_key(self, key):
39 0
        return key
40

41 6
    @classmethod
42
    def get_cache_id_key(self, key):
43 0
        return '{}_ID'.format(key)
44

45 6
    def updated_related_policies(self):
46 6
        refPolicies = Policy.objects.filter(schedule__pk=self.pk)
47 6
        if refPolicies.exists():
48 0
            for pol in refPolicies:
49 0
                pol.save()
50

51 6
    def save(self, *args, **kwargs):
52 6
        self.updated_related_policies()
53
        # If update_fields has been specified, add our field names to it,
54
        # if it hasn't been specified, then we're just doing a normal save.
55 6
        super(Schedule, self).save(*args, **kwargs)

Read our documentation on viewing source code .

Loading