def update_organisation(self, org_id, cached_service_ids=None, **kwargs): api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs) if cached_service_ids: redis_client.delete(*map('service-{}'.format, cached_service_ids)) return api_response
def _delete_template_cache_for_service(self, service_id): templates_for_service = self.get_service_templates(service_id)['data'] if templates_for_service: redis_client.delete(*[ f"template-{x['id']}-version-None" for x in templates_for_service ])
def archive_service(self, service_id, cached_service_user_ids): if cached_service_user_ids: redis_client.delete( *map('user-{}'.format, cached_service_user_ids)) ret = self.post('/service/{}/archive'.format(service_id), data=None) self._delete_template_cache_for_service(str(service_id)) return ret
def new_client_method(client_instance, *args, **kwargs): try: api_response = client_method(client_instance, *args, **kwargs) finally: redis_key = _make_key(key_format, client_method, args, kwargs) redis_client.delete(redis_key) return api_response
def move_to_folder(self, service_id, folder_id, template_ids, folder_ids): if folder_id: url = '/service/{}/template-folder/{}/contents'.format(service_id, folder_id) else: url = '/service/{}/template-folder/contents'.format(service_id) self.post(url, { 'templates': list(template_ids), 'folders': list(folder_ids), }) if template_ids: redis_client.delete(*(f'service-{service_id}-template-{id}-version-None' for id in template_ids))
def sign_out(): """Log the user out of the system.""" # Go through each Redis key prefix we have and construct # a wildcard key to find all stored keys for prefix in redis_utils.RedisKeys: key = redis_utils.make_key(prefix, current_user.username, current_user.signin_token, "*") # Take the found keys and delete them from Redis for record in redis_client.keys(key): redis_client.delete(record) # Also record the current time so we know when they last logged out database.user_record_login_time(current_user.username) # Remove this user session and sign them out current_user.authenticated = False logout_user() flash("You have successfully signed out. Thank you for serving!", "info") return redirect(url_for("root.index"))
def archive_service(self, service_id, cached_service_user_ids): if cached_service_user_ids: redis_client.delete( *map('user-{}'.format, cached_service_user_ids)) return self.post('/service/{}/archive'.format(service_id), data=None)
def new_client_method(client_instance, *args, **kwargs): redis_key = _make_key(key_format, client_method, args, kwargs) redis_client.delete(redis_key) return client_method(client_instance, *args, **kwargs)