Skip to content

Commit

Permalink
Merge pull request #1780 from adnankattekaden/dev
Browse files Browse the repository at this point in the history
edit task
  • Loading branch information
adnankattekaden authored Dec 8, 2023
2 parents 4781cf0 + c228568 commit 7215329
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 4 additions & 2 deletions api/dashboard/events/events_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Meta:
model = Events
fields = "__all__"


class EventsCUDSerializer(serializers.ModelSerializer):
class Meta:
model = Events
Expand All @@ -29,8 +30,9 @@ def update(self, instance, validated_data):
user_id = self.context.get("user_id")

instance.name = validated_data.get("name", instance.name)
instance.description = validated_data.get("description", instance.description)
instance.updated_by_id = user_id
instance.updated_at = DateTimeUtils.get_current_utc_time()
instance.save()
return instance

return instance
13 changes: 5 additions & 8 deletions api/dashboard/events/events_views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from rest_framework.views import APIView
from utils.permission import CustomizePermission, JWTUtils, role_required

from db.task import Events
from utils.permission import CustomizePermission, JWTUtils
from utils.response import CustomResponse
from utils.types import RoleType
from utils.utils import CommonUtils
from .events_serializer import EventsCUDSerializer, EventsListSerializer
from db.task import Events


class EventAPI(APIView):
Expand All @@ -30,7 +30,6 @@ def get(self, request):
)
)


def post(self, request):
user_id = JWTUtils.fetch_user_id(request)

Expand All @@ -52,7 +51,6 @@ def post(self, request):
return CustomResponse(
general_message=serializer.errors,
).get_failure_response()


def put(self, request, event_id):
user_id = JWTUtils.fetch_user_id(request)
Expand Down Expand Up @@ -80,10 +78,9 @@ def put(self, request, event_id):
return CustomResponse(
message=serializer.errors
).get_failure_response()


def delete(self, request, event_id):

events = Events.objects.filter(id=event_id).first()

if events is None:
Expand All @@ -95,4 +92,4 @@ def delete(self, request, event_id):

return CustomResponse(
general_message=f"{events.name} Deleted Successfully"
).get_success_response()
).get_success_response()

0 comments on commit 7215329

Please sign in to comment.