#50 feat: add StoreSettings model and API for store address and map coordinates

This commit is contained in:
2026-08-08 13:50:43 -05:00
parent f65b85c7e7
commit 56bbc8f9b4
10 changed files with 260 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ from .payments import (
Pagination,
)
from .admin import AdminCodeValidateView
from .store_settings import StoreSettingsView
__all__ = [
# Catalogue Images
@@ -44,4 +45,6 @@ __all__ = [
"Pagination",
# Admin
"AdminCodeValidateView",
# Store Settings
"StoreSettingsView",
]

View File

@@ -0,0 +1,28 @@
from rest_framework import status
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from ..models.store_settings import StoreSettings
from ..permissions import IsAdministrator
from ..serializers.store_settings import StoreSettingsSerializer
class StoreSettingsView(APIView):
def get_permissions(self):
if self.request.method == "GET":
return [AllowAny()]
return [IsAuthenticated(), IsAdministrator()]
def get(self, request):
settings = StoreSettings.get_singleton()
return Response(StoreSettingsSerializer(settings).data)
def patch(self, request):
settings = StoreSettings.get_singleton()
serializer = StoreSettingsSerializer(
settings, data=request.data, partial=True
)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)