Coverage for baibu/core/context_processors.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-10-06 13:07 +0000

1import re 

2 

3from django.conf import settings 

4 

5# Only plain colour values reach the inline style in base.html. 

6_SAFE_COLOR = re.compile(r"^(#[0-9a-fA-F]{3,8}|[a-zA-Z]+|(rgb|hsl|oklch)a?\([0-9.,%\s/]+\))$") 

7 

8 

9def platform(request): 

10 brand_color = (settings.PLATFORM_BRAND_COLOR or "").strip() 

11 return { 

12 "platform": { 

13 "name": settings.PLATFORM_NAME, 

14 "tagline": settings.PLATFORM_TAGLINE, 

15 "contact_email": settings.PLATFORM_CONTACT_EMAIL, 

16 "logo_path": settings.PLATFORM_LOGO_PATH, 

17 "brand_color": brand_color if _SAFE_COLOR.match(brand_color) else "", 

18 "languages": settings.LANGUAGES, 

19 "allow_registration": settings.ACCOUNT_ALLOW_REGISTRATION, 

20 "chat_enabled": settings.CHAT_ENABLED, 

21 "phone_sign_in": settings.PHONE_SIGN_IN_ENABLED, 

22 }, 

23 }