Skip to content

Commit

Permalink
Merge pull request #1781 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
taskedt
  • Loading branch information
adnankattekaden authored Dec 8, 2023
2 parents 00b5921 + 7215329 commit e9c0df3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 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()
23 changes: 12 additions & 11 deletions api/dashboard/profile/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,18 @@ def update(self, instance, validated_data):
def create_karma_activity_log(task_title, karma_value):
task = TaskList.objects.filter(title=task_title).first()
if task:
KarmaActivityLog.objects.create(
task_id=task.id,
karma=karma_value,
user_id=user_id,
updated_by_id=user_id,
created_by_id=user_id,
peer_approved=True,
peer_approved_by_id=user_id,
appraiser_approved_by_id=user_id,
appraiser_approved=True,
)
if karma_value > 0:
KarmaActivityLog.objects.create(
task_id=task.id,
karma=karma_value,
user_id=user_id,
updated_by_id=user_id,
created_by_id=user_id,
peer_approved=True,
peer_approved_by_id=user_id,
appraiser_approved_by_id=user_id,
appraiser_approved=True,
)
Wallet.objects.filter(user_id=user_id).update(
karma=F("karma") + karma_value,
updated_by_id=user_id
Expand Down

0 comments on commit e9c0df3

Please sign in to comment.