old_contents: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  
  from celerybeatmongo.models import PeriodicTask as BasePeriodicTask, PERIODS
  
  from udata.i18n import lazy_gettext as _
  from udata.models import db
  
  
  __all__ = ('PeriodicTask', 'PERIODS')
  
  
  class PeriodicTask(BasePeriodicTask):
      last_run_id = db.StringField()
  
      class Interval(BasePeriodicTask.Interval):
          def __unicode__(self):
              if self.every == 1:
                  return _('every {0.period_singular}').format(self)
              return _('every {0.every} {0.period}').format(self)
  
      @property
      def schedule_display(self):
          if self.interval:
              return str(self.interval)
          elif self.crontab:
              return str(self.crontab)
          else:
              raise Exception("must define internal or crontab schedule")
  
new_contents: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  
  from celerybeatmongo.models import PeriodicTask as BasePeriodicTask, PERIODS
  
  from udata.i18n import lazy_gettext as _
  from udata.models import db
  
  
  __all__ = ('PeriodicTask', 'PERIODS')
  
  CRON = '{minute} {hour} {day_of_month} {month_of_year} {day_of_week}'
  
  
  class PeriodicTask(BasePeriodicTask):
      last_run_id = db.StringField()
  
      class Interval(BasePeriodicTask.Interval):
          def __unicode__(self):
              if self.every == 1:
                  return _('every {0.period_singular}').format(self)
              return _('every {0.every} {0.period}').format(self)
  
      class Crontab(BasePeriodicTask.Crontab):
          def __unicode__(self):
              return CRON.format(**self._data)
  
      @property
      def schedule_display(self):
          if self.interval:
              return str(self.interval)
          elif self.crontab:
              return str(self.crontab)
          else:
              raise Exception("must define internal or crontab schedule")
  
      interval = db.EmbeddedDocumentField(Interval)
      crontab = db.EmbeddedDocumentField(Crontab)
  
subject: Fix periodic tasks model display