expalert/apps/views/update.py
2023-12-04 16:09:40 +01:00

32 lines
798 B
Python

from django.views.generic import View
from django.http.response import JsonResponse
from ..models import AppURL
class UpdateView(View):
"""A view that returns the currently available app versions
"""
def get(self, request, *args, **kwargs):
"""Return the JSON required for the app installation
Args:
request (HttpRequest): The request
*args: Additional arguments
**kwargs: Additional keyword arguments
Returns:
JsonResponse: The response
"""
app_versions = AppURL.objects.all()
data = {"versions": {}}
for app_version in app_versions:
data["versions"][app_version.name] = {"build": app_version.build, "url": app_version.url}
return JsonResponse(data)