Coverage for apps/comments_views/journal/templatetags/comments_journal_tags.py: 88%

13 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-02-28 09:09 +0000

1from urllib.parse import urlencode 

2 

3from django import template 

4from django.conf import settings 

5from django.core.exceptions import ImproperlyConfigured 

6from django.http import HttpRequest 

7 

8register = template.Library() 

9 

10 

11@register.simple_tag 

12def login_server_url(request: HttpRequest) -> str: 

13 """ 

14 Returns the base URL of the login server as defined in the settings. 

15 """ 

16 if not hasattr(settings, "OIDC_OP_BASE_URL"): 16 ↛ 17line 16 didn't jump to line 17, because the condition on line 16 was never true

17 raise ImproperlyConfigured("You must define the OIDC_OP_BASE_URL settings.") 

18 

19 login_url = settings.OIDC_OP_BASE_URL 

20 query_params = {"origin_uri": request.build_absolute_uri()} 

21 return f"{login_url}?{urlencode(query_params)}"