Skip to content

Commit

Permalink
Merge pull request #1501 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Task created update fix
  • Loading branch information
adnankattekaden authored Nov 2, 2023
2 parents 4081417 + 35a184e commit f63911d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions api/dashboard/task/dash_task_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def get(self, request):
def post(self, request): # create
user_id = JWTUtils.fetch_user_id(request)

request.data["created_by"] = request.data["updated_by"] = user_id
serializer = TaskModifySerializer(data=request.data)
mutable_data = request.data.copy() # Create a mutable copy of request.data
mutable_data["created_by"] = user_id
mutable_data["updated_by"] = user_id

serializer = TaskModifySerializer(data=mutable_data)

if not serializer.is_valid():
return CustomResponse(
Expand Down Expand Up @@ -140,13 +143,14 @@ def get(self, request, task_id):
def put(self, request, task_id): # edit

user_id = JWTUtils.fetch_user_id(request)
request.data["updated_by"] = user_id
mutable_data = request.data.copy() # Create a mutable copy of request.data
mutable_data["updated_by"] = user_id

task = TaskList.objects.get(pk=task_id)

serializer = TaskModifySerializer(
task,
data=request.data,
data=mutable_data,
partial=True
)

Expand Down
2 changes: 1 addition & 1 deletion db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class User(models.Model):
active = models.BooleanField(default=True)
exist_in_guild = models.BooleanField(default=False)
profile_pic = models.CharField(max_length=200, blank=True, null=True)
district = models.ForeignKey("District",on_delete=models.CASCADE, blank=True, null=True)
district = models.ForeignKey("District",on_delete=models.CASCADE, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
Expand Down

0 comments on commit f63911d

Please sign in to comment.