-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
41 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
INSIGHTSAPI/carousel_image/migrations/0004_remove_banner_active.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.0.7 on 2024-09-20 09:48 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('carousel_image', '0003_alter_banner_order'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='banner', | ||
name='active', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,10 @@ | ||
from rest_framework import viewsets | ||
from rest_framework import status | ||
from rest_framework.response import Response | ||
from rest_framework.permissions import DjangoModelPermissions | ||
from .models import Banner | ||
from .serializer import BannerSerializer | ||
|
||
|
||
class BannerViewSet(viewsets.ModelViewSet): | ||
queryset = Banner.objects.filter(active=True) | ||
queryset = Banner.objects.filter().order_by("order") | ||
serializer_class = BannerSerializer | ||
|
||
def create(self, request, *args, **kwargs): | ||
print("Create2") | ||
print("request:", request.data) | ||
serializer = self.get_serializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
print("serializer:", serializer.validated_data) | ||
response = super().create(request, *args, **kwargs) | ||
print(response.data) | ||
return response | ||
|
||
def destroy(self, request, *args, **kwargs): | ||
instance = self.get_object() | ||
instance.active = False | ||
instance.save() | ||
return Response(status=status.HTTP_204_NO_CONTENT) | ||
permission_classes = [DjangoModelPermissions] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters