def set(self, key, val, channel_name=None): if key not in initial_data[self._type]: raise KeyError('Key \'{}\' not in \'{}\''.format(key, self._type)) if channel_name: r.set(self._redis_key(key, channel_name), val, ex=SESSION_EXPIRE_TIME) notify_ui(self._type, {key: val}, channel_name) else: r.set(self._redis_key(key, channel_name), val) notify_ui(self._type, {key: val}) return True
def set(self, key, val): if key not in initial_data[self._type]: raise KeyError('Key \'{}\' not in \'{}\''.format(key, self._type)) try: saved_config = self._model.objects.get(key=key) except self._model.DoesNotExist: saved_config = self._model(key=key) saved_config.val = val saved_config.save() notify_ui(self._type, {key: val})
def decrement(self, key, channel_name=None): if key not in initial_data[self._type]: raise KeyError('Key \'{}\' not in \'{}\''.format(key, self._type)) val = r.decr(self._redis_key(key, channel_name)) notify_ui(self._type, {key: val}) return val
def decrement(self, key): setting = self._model.objects.get(key=key) setting.val -= 1 setting.save() notify_ui(self._type, {key: setting.val})
def increment(self, key): # self._model.objects.get(key=key).update(val=F('val') + 1) # Doesn't work because of json db type setting = self._model.objects.get(key=key) setting.val += 1 setting.save() notify_ui(self._type, {key: setting.val})
def handle(self, *args, **options): notify_ui('photo_thubnails_generating', True) self.generate_thumbnails() notify_ui('photo_thubnails_generating', False)