Skip to content

Commit

Permalink
Merge pull request #1661 from gtech-mulearn/dev-server
Browse files Browse the repository at this point in the history
[fix] task issue
  • Loading branch information
adnankattekaden authored Nov 30, 2023
2 parents 31bc30b + 61e3c18 commit 0e554f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 16 additions & 14 deletions api/dashboard/task/dash_task_serializer.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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()
Expand All @@ -68,6 +70,8 @@ class Meta:
"event",
"updated_by",
"created_by",
"bonus_karma",
"bonus_time",
)


Expand Down Expand Up @@ -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")
Expand All @@ -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




4 changes: 3 additions & 1 deletion db/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 0e554f4

Please sign in to comment.