From 5b49ff6840c90252280dedaf0fca3b9756177be8 Mon Sep 17 00:00:00 2001 From: Philipp Kilian Date: Tue, 27 Jul 2021 13:33:03 +0200 Subject: [PATCH] Use mor python like way for checking assets. --- b3lb/rest/b3lb/endpoints.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/b3lb/rest/b3lb/endpoints.py b/b3lb/rest/b3lb/endpoints.py index 30dc6b9..b51f708 100644 --- a/b3lb/rest/b3lb/endpoints.py +++ b/b3lb/rest/b3lb/endpoints.py @@ -132,12 +132,8 @@ async def join(params, node, secret): params = await sync_to_async(lb.check_parameter)(params, secret.tenant, join=True) # check custom style css - if Parameter.USERDATA_BBB_CUSTOM_STYLE_URL not in params: - try: - if secret.tenant.asset and secret.tenant.asset.custom_css: - params[Parameter.USERDATA_BBB_CUSTOM_STYLE_URL] = secret.tenant.asset.custom_css_url - except Asset.DoesNotExist: - pass + if Parameter.USERDATA_BBB_CUSTOM_STYLE_URL not in params and hasattr(secret.tenant, 'asset') and secret.tenant.asset.custom_css: + params[Parameter.USERDATA_BBB_CUSTOM_STYLE_URL] = secret.tenant.asset.custom_css_url url = "{}{}".format(node.api_base_url, lb.get_endpoint_str("join", params, node.secret)) @@ -161,21 +157,13 @@ async def create(request, endpoint, params, node, secret): params = await sync_to_async(lb.check_parameter)(params, secret.tenant) # check for custom logo - if Parameter.LOGO not in params: - try: - if secret.tenant.asset and secret.tenant.asset.logo: - params["logo"] = secret.tenant.asset.logo_url - except Asset.DoesNotExist: - pass + if Parameter.LOGO not in params and hasattr(secret.tenant, 'asset') and secret.tenant.asset.logo: + params["logo"] = secret.tenant.asset.logo_url # check for custom slide - if request.method == "GET": - try: - if secret.tenant.asset and secret.tenant.asset.slide: - body = await sync_to_async(lb.get_slide_body_for_post)(secret) - request.method = "POST" - except Asset.DoesNotExist: - pass + if request.method == "GET" and hasattr(secret.tenant, 'asset') and secret.tenant.asset.slide: + body = await sync_to_async(lb.get_slide_body_for_post)(secret) + request.method = "POST" response = await pass_through(request, endpoint, params, node, body=body)