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
Beispiel #2
0
    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})
Beispiel #3
0
 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
Beispiel #4
0
 def decrement(self, key):
     setting = self._model.objects.get(key=key)
     setting.val -= 1
     setting.save()
     notify_ui(self._type, {key: setting.val})
Beispiel #5
0
 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})
Beispiel #6
0
 def handle(self, *args, **options):
     notify_ui('photo_thubnails_generating', True)
     self.generate_thumbnails()
     notify_ui('photo_thubnails_generating', False)