Add documentation to UserAddDevice render function

This commit is contained in:
Paul Konstantin Gerke 2023-07-05 00:26:25 +02:00 committed by Christopher Charbonneau Wells
parent 894a4c540a
commit 1ef31cccf7
1 changed files with 6 additions and 0 deletions

View File

@ -253,6 +253,9 @@ class UserAddDevice(LoginRequiredMixin, View):
qr_code_template = "babybuddy/login_qr_code.txt" qr_code_template = "babybuddy/login_qr_code.txt"
def get(self, request): def get(self, request):
# Assemble qr_code json-data. For Home Assistant ingress support, we
# also need to extract the ingress_session token to allow an external
# app to authenticate with home assistant so it can reach baby buddy
session_cookies = {} session_cookies = {}
if request.is_homeassistant_ingress_request: if request.is_homeassistant_ingress_request:
session_cookies["ingress_session"] = request.COOKIES.get("ingress_session") session_cookies["ingress_session"] = request.COOKIES.get("ingress_session")
@ -264,6 +267,9 @@ class UserAddDevice(LoginRequiredMixin, View):
) )
qr_code_data = qr_code_response.content.decode().strip() qr_code_data = qr_code_response.content.decode().strip()
# Now that the qr_code json-data is assembled, we can pass the json
# structure as data to the user_add_device - template where it will
# be converted into a qr-code.
return render( return render(
request, request,
self.template_name, self.template_name,