def index(self, context, request: TracimRequest): app_config = request.registry.settings["CFG"] # type: CFG # TODO - G.M - 2018-08-07 - Refactor autogen valid app list for frontend frontend_apps = [] app_api = ApplicationApi(app_list=app_list) applications = [ app_api.get_application_in_context(app, app_config) for app in app_api.get_all() ] for app in applications: app_frontend_path = APP_FRONTEND_PATH.replace( "{minislug}", app.minislug) app_path = os.path.join(self.dist_folder_path, app_frontend_path) if os.path.exists(app_path): frontend_apps.append(app) return render_to_response( self._get_index_file_path(), { "colors": { "primary": ExtendedColor(app_config.APPS_COLORS["primary"]) }, "applications": frontend_apps, "website_title": app_config.WEBSITE__TITLE, "custom_toolbox_files": self.custom_toolbox_files, "cache_token": self.cache_token, "excluded_notifications": app_config.WEB__NOTIFICATIONS__EXCLUDED, }, )
def index(self, context, request: TracimRequest): app_config = request.registry.settings['CFG'] # TODO - G.M - 2018-08-07 - Refactor autogen valid app list for frontend frontend_apps = [] app_api = ApplicationApi( app_list=app_list, ) applications = app_api.get_all() for app in applications: app_frontend_path = APP_FRONTEND_PATH.replace('{minislug}', app.minislug) # nopep8 app_path = os.path.join(self.dist_folder_path, app_frontend_path) # nopep8 if os.path.exists(app_path): frontend_apps.append(app) return render_to_response( self._get_index_file_path(), { 'colors': { 'primary': ExtendedColor(app_config.APPS_COLORS['primary']), }, 'applications': frontend_apps, } )
def test_extended_color__lighten_darken__white(self): color = ExtendedColor("#FFFFFF") assert color.web == "white" color_darken = color.darken color_lighten = color.lighten assert color_lighten == color assert color_lighten != color_darken assert color_lighten.web == color.web
def test_extended_color__lighten_darken__white(self): color = ExtendedColor('#FFFFFF') assert color.web == 'white' color_darken = color.darken color_lighten = color.lighten assert color_lighten == color assert color_lighten != color_darken assert color_lighten.web == color.web
def index(self, context, request: TracimRequest): app_config = request.registry.settings["CFG"] # type: CFG # TODO - G.M - 2018-08-07 - Refactor autogen valid app list for frontend frontend_apps = [] app_api = ApplicationApi(app_list=app_list) applications = [ app_api.get_application_in_context(app, app_config) for app in app_api.get_all() ] for app in applications: app_frontend_path = APP_FRONTEND_PATH.replace( "{minislug}", app.minislug) app_path = os.path.join(self.dist_folder_path, app_frontend_path) if os.path.exists(app_path): frontend_apps.append(app) base_response = None csp_nonce = "" if app_config.CONTENT_SECURITY_POLICY__ENABLED: csp_nonce = os.urandom(CSP_NONCE_SIZE).hex() csp_headers = [] csp_header_key = ("Content-Security-Policy-Report-Only" if app_config.CONTENT_SECURITY_POLICY__REPORT_ONLY else "Content-Security-Policy") csp = "; ".join("{} {}".format(k, v) for k, v in BASE_CSP_DIRECTIVES) csp = "{}; {}".format( csp, app_config.CONTENT_SECURITY_POLICY__ADDITIONAL_DIRECTIVES) csp_header_value = csp.format(nonce=csp_nonce) if app_config.CONTENT_SECURITY_POLICY__REPORT_URI: csp_headers.append( ("Report-To", app_config.CONTENT_SECURITY_POLICY__REPORT_URI)) csp_header_value = "{}; report-uri {}".format( csp_header_value, app_config.CONTENT_SECURITY_POLICY__REPORT_URI) csp_headers.append((csp_header_key, csp_header_value)) base_response = Response( headerlist=[("Content-Type", "text/html")] + csp_headers) return render_to_response( self._get_index_file_path(), { "colors": { "primary": ExtendedColor(app_config.APPS_COLORS["primary"]) }, "applications": frontend_apps, "website_title": app_config.WEBSITE__TITLE, "custom_toolbox_files": self.custom_toolbox_files, "cache_token": self.cache_token, "excluded_notifications": app_config.WEB__NOTIFICATIONS__EXCLUDED, "csp_nonce": csp_nonce, "glob": self.glob, }, request=request, response=base_response, )
def test_extended_color__lighten_darken__black(self): color = ExtendedColor("#000000") assert color.web == "black" color_darken = color.darken color_lighten = color.lighten assert color_darken == color # INFO - G.M - 2018-09-12 - lighten can not # add X% more light to something already dark. assert color_darken == color_lighten assert color_darken.web == color.web
def test_extended_color__lighten_darken__nominal_case(self): color = ExtendedColor("#9f6644") color_darken = color.darken assert isinstance(color_darken, ExtendedColor) assert color_darken != color assert color_darken.web != color.web color_lighten = color.lighten assert isinstance(color_lighten, ExtendedColor) assert color_lighten != color assert color_lighten.web != color.web assert color_lighten != color_darken assert color_lighten.web != color_darken.web
def test_extended_color__init__ok_nominal_case(self): color = ExtendedColor("#FFFFFF") assert color.web == "white"
def test_extended_color__init__ok_nominal_case(self): color = ExtendedColor('#FFFFFF') assert color.web == 'white'