diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-15 14:55:22 +0100 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-15 14:55:22 +0100 |
commit | e4c0cecb34b159392f95b081916b13534754603d (patch) | |
tree | 6f67ee52b72b26b29cb288ab478a3bdd4bdb3214 /chat_api | |
parent | 8c1767884dedb6c87906265a2c35a3f1a6124a6e (diff) | |
download | lom_api-e4c0cecb34b159392f95b081916b13534754603d.tar.gz lom_api-e4c0cecb34b159392f95b081916b13534754603d.zip |
upgrade Group messages api
Diffstat (limited to 'chat_api')
-rw-r--r-- | chat_api/models.py | 2 | ||||
-rw-r--r-- | chat_api/serializers.py | 4 |
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 | ||
23 | class Gm(models.Model): | 23 | class 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 @@ | |||
1 | from django.db.models import fields | 1 | from django.db.models import fields |
2 | from django.contrib.auth.models import User | ||
3 | |||
2 | from rest_framework import serializers | 4 | from rest_framework import serializers |
3 | from .models import * | 5 | from .models import * |
6 | from auth_api.serializers import UserSerializer | ||
4 | 7 | ||
5 | class GroupSerializer(serializers.ModelSerializer): | 8 | class 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 | ||
31 | class GmSerializer(serializers.ModelSerializer): | 34 | class 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') |