From 728e04dee47a97212b36903463e5aa86bc050b69 Mon Sep 17 00:00:00 2001 From: Adnan Kattekaden Date: Fri, 1 Dec 2023 00:45:35 +0530 Subject: [PATCH] task issue fixed --- api/dashboard/task/dash_task_serializer.py | 30 ++++++++++++---------- db/task.py | 4 ++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/api/dashboard/task/dash_task_serializer.py b/api/dashboard/task/dash_task_serializer.py index 692bf38c..6c7dad8f 100644 --- a/api/dashboard/task/dash_task_serializer.py +++ b/api/dashboard/task/dash_task_serializer.py @@ -1,7 +1,8 @@ import uuid + from rest_framework import serializers -from db.task import TaskList, KarmaActivityLog, TaskType +from db.task import TaskList, TaskType from utils.permission import JWTUtils from utils.utils import DateTimeUtils @@ -39,10 +40,11 @@ class Meta: "updated_by", "created_by", "created_at", + "bonus_time", + "bonus_karma", ] def get_total_karma_gainers(self, obj): - return obj.karma_activity_log_task.filter( appraiser_approved=True ).count() @@ -68,6 +70,8 @@ class Meta: "event", "updated_by", "created_by", + "bonus_karma", + "bonus_time", ) @@ -121,25 +125,26 @@ def validate_usage_count(self, value): if value is None: return 1 return value - + def validate_variable_karma(self, value): if value is None: return False return value + class TasktypeSerializer(serializers.ModelSerializer): - updated_by=serializers.CharField(source='updated_by.fullname') - created_by=serializers.CharField(source='created_by.fullname') + updated_by = serializers.CharField(source='updated_by.fullname') + created_by = serializers.CharField(source='created_by.fullname') class Meta: model = TaskType - fields = ["id", "title","updated_by","updated_at","created_by","created_at"] + fields = ["id", "title", "updated_by", "updated_at", "created_by", "created_at"] -class TaskTypeCreateUpdateSerializer(serializers.ModelSerializer): +class TaskTypeCreateUpdateSerializer(serializers.ModelSerializer): class Meta: - model=TaskType - fields=["title"] + model = TaskType + fields = ["title"] def create(self, validated_data): user_id = self.context.get("user_id") @@ -151,15 +156,12 @@ def create(self, validated_data): created_by_id=user_id, created_at=DateTimeUtils.get_current_utc_time(), ) + def update(self, instance, validated_data): updated_title = validated_data.get("title") instance.title = updated_title user_id = JWTUtils.fetch_user_id(self.context.get("request")) instance.updated_by_id = user_id - instance.updated_at=DateTimeUtils.get_current_utc_time(), + instance.updated_at = DateTimeUtils.get_current_utc_time(), instance.save() return instance - - - - diff --git a/db/task.py b/db/task.py index e8377e3f..729fdc29 100644 --- a/db/task.py +++ b/db/task.py @@ -114,6 +114,8 @@ class TaskList(models.Model): active = models.BooleanField(default=True) variable_karma = models.BooleanField(default=False) usage_count = models.IntegerField(default=1) + bonus_time = models.DateTimeField(blank=True, null=True) + bonus_karma = models.IntegerField(blank=True, null=True) updated_by = models.ForeignKey(User, models.DO_NOTHING, db_column="updated_by", related_name="task_list_updated_by") updated_at = models.DateTimeField(auto_now=True) created_by = models.ForeignKey(User, models.DO_NOTHING, db_column="created_by", related_name="task_list_created_by") @@ -128,7 +130,7 @@ class Wallet(models.Model): id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4) user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="wallet_user") karma = models.IntegerField(default=0) - # karma_last_update_at = models.DateTimeField(blank=True, null=True, auto_now_add=True) + karma_last_update_at = models.DateTimeField(blank=True, null=True, auto_now=True) coin = models.FloatField(default=0) updated_by = models.ForeignKey(User, on_delete=models.CASCADE, db_column="updated_by", related_name="wallet_updated_by")