summaryrefslogtreecommitdiffstats
path: root/chat_api
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2021-12-15 14:55:22 +0100
committerjdlugosz963 <jdlugosz963@gmail.com>2021-12-15 14:55:22 +0100
commite4c0cecb34b159392f95b081916b13534754603d (patch)
tree6f67ee52b72b26b29cb288ab478a3bdd4bdb3214 /chat_api
parent8c1767884dedb6c87906265a2c35a3f1a6124a6e (diff)
downloadlom_api-e4c0cecb34b159392f95b081916b13534754603d.tar.gz
lom_api-e4c0cecb34b159392f95b081916b13534754603d.zip
upgrade Group messages api
Diffstat (limited to 'chat_api')
-rw-r--r--chat_api/models.py2
-rw-r--r--chat_api/serializers.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/chat_api/models.py b/chat_api/models.py
index 3be795a..3a3f51e 100644
--- a/chat_api/models.py
+++ b/chat_api/models.py
@@ -18,7 +18,7 @@ class Group(models.Model):
18 create_date = models.DateTimeField(auto_now=True) 18 create_date = models.DateTimeField(auto_now=True)
19 19
20 def __str__(self): 20 def __str__(self):
21 return self.name 21 return str(self.pk) + " " + self.name
22 22
23class Gm(models.Model): 23class Gm(models.Model):
24 sender = models.ForeignKey(User, related_name="sender_gm", on_delete=models.CASCADE) 24 sender = models.ForeignKey(User, related_name="sender_gm", on_delete=models.CASCADE)
diff --git a/chat_api/serializers.py b/chat_api/serializers.py
index 15828be..dee0c45 100644
--- a/chat_api/serializers.py
+++ b/chat_api/serializers.py
@@ -1,6 +1,9 @@
1from django.db.models import fields 1from django.db.models import fields
2from django.contrib.auth.models import User
3
2from rest_framework import serializers 4from rest_framework import serializers
3from .models import * 5from .models import *
6from auth_api.serializers import UserSerializer
4 7
5class GroupSerializer(serializers.ModelSerializer): 8class GroupSerializer(serializers.ModelSerializer):
6 is_mine = serializers.SerializerMethodField('_is_mine') 9 is_mine = serializers.SerializerMethodField('_is_mine')
@@ -30,6 +33,7 @@ class DmSerializer(serializers.ModelSerializer):
30 33
31class GmSerializer(serializers.ModelSerializer): 34class GmSerializer(serializers.ModelSerializer):
32 is_mine = serializers.SerializerMethodField('_is_mine') 35 is_mine = serializers.SerializerMethodField('_is_mine')
36 sender = UserSerializer(read_only=True)
33 37
34 def _is_mine(self, obj): 38 def _is_mine(self, obj):
35 request = self.context.get('request') 39 request = self.context.get('request')