def dow_to_dict_from_self(self):
        # res = {'name': self.name, 'enabled': self.enabled }
        res = {'sun': 0, 'mon': 0, 'tue': 0, 'wed': 0, 'thr': 0, 'fri': 0,
               'sat': 0,
               'enabled': 0, 'dow': 0, 'name': 'untitled'}

        if (int(self.days_of_week) & 0x01) == 0x01:  # sun
            res['sun'] = 1
        if (int(self.days_of_week) & 0x02) == 0x02:  # mon
            res['mon'] = 1
        if (int(self.days_of_week) & 0x04) == 0x04:  # tue
            res['tue'] = 1
        if (int(self.days_of_week) & 0x08) == 0x08:  # wed
            res['wed'] = 1
        if (int(self.days_of_week) & 0x10) == 0x10:  # thr
            res['thr'] = 1
            res['thu'] = 1  # '%a' returns thu for Thursday
        if (int(self.days_of_week) & 0x20) == 0x20:  # fri
            res['fri'] = 1
        if (int(self.days_of_week) & 0x40) == 0x40:  # sat
            res['sat'] = 1
        if (int(
                self.days_of_week) & 0x40) == 0x80:  # enabled # new enable#
            # flag -- duplicate in db
            res['enabled'] = 1

        res['enabled'] = self.enabled  # remove this
        res['dow'] = self.days_of_week
        res['name'] = self.name

        return res

kept the original comments - they're very helpful

By Anonymous, 2018-07-11 19:40:44