Skip to content

Commit

Permalink
property additions
Browse files Browse the repository at this point in the history
  • Loading branch information
muremwa committed Feb 15, 2023
1 parent f464c00 commit 74a0d0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Meta:
class ApiCommentSerializer(serializers.ModelSerializer):
comment_id = serializers.IntegerField(source='pk')
key = serializers.FloatField(source='stamp')
created = serializers.FloatField(source='created_stamp')
user = ApiUserSerializer(many=False)
mentioned = ApiProfileSerializer(many=True)
time = serializers.CharField(source='get_created')
Expand All @@ -106,7 +107,8 @@ class ApiCommentSerializer(serializers.ModelSerializer):
class Meta:
model = Comment
fields = (
'comment_id', 'key', 'user', 'time', 'text', 'edited', 'replies', 'reply_url', 'action_url', 'mentioned',
'comment_id', 'key', 'user', 'time', 'text', 'edited', 'replies',
'reply_url', 'action_url', 'mentioned', 'created'
)


Expand Down
3 changes: 2 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def comment_actions_v2(request, comment_pk):
if notify:
notes_signal.send(comment_actions, comment=comment, mentioned=notify)

res_status = status.HTTP_200_OK
response.update({
'success': True,
'comment': ApiCommentSerializer(comment).data
Expand All @@ -294,6 +295,6 @@ def comment_actions_v2(request, comment_pk):
if request.user == comment.user or request.user == comment.note.user:
comment.delete()
res_status = status.HTTP_200_OK
response.update({'success': True})
response.update({'success': True, 'comment_id': comment_pk})

return Response(response, status=res_status)
4 changes: 4 additions & 0 deletions notes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def is_modified(self):
def stamp(self):
return self.modified.timestamp() if self.is_modified() else self.created.timestamp()

@property
def created_stamp(self):
return self.created.timestamp()

@property
def reply_url(self):
return reverse('notes:reply-comment', kwargs={'comment_id': str(self.pk)})
Expand Down

0 comments on commit 74a0d0c

Please # to comment.