diff options
-rw-r--r-- | chat_api/models.py | 2 | ||||
-rw-r--r-- | chat_api/serializers.py | 4 | ||||
-rw-r--r-- | index.http | 6 | ||||
-rw-r--r-- | lom_api/settings.py | 3 |
4 files changed, 13 insertions, 2 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') |
@@ -32,3 +32,9 @@ content-type: application/json | |||
32 | 32 | ||
33 | GET http://localhost:8000/api/auth/info/? | 33 | GET http://localhost:8000/api/auth/info/? |
34 | Authorization: Token bd057a90565d85b2efa23f73deb9e5afdb4e4d56b24ba405a1cf33b66b49f4ed | 34 | Authorization: Token bd057a90565d85b2efa23f73deb9e5afdb4e4d56b24ba405a1cf33b66b49f4ed |
35 | |||
36 | ### | ||
37 | |||
38 | GET http://localhost:8000/api/chat/groups/detail/22/messages/ | ||
39 | Authorization: Token b4bd0a69d9f78c9447b4f7581a8b8cc53f5732a7f6542db9a5fea093ce734b2c | ||
40 | content-type: application/json | ||
diff --git a/lom_api/settings.py b/lom_api/settings.py index a09c7a7..77a754e 100644 --- a/lom_api/settings.py +++ b/lom_api/settings.py | |||
@@ -50,8 +50,9 @@ REST_FRAMEWORK = { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | REST_KNOX = { | 52 | REST_KNOX = { |
53 | # 'TOKEN_LIMIT_PER_USER': 1, | 53 | 'TOKEN_TTL': None, |
54 | } | 54 | } |
55 | |||
55 | 56 | ||
56 | MIDDLEWARE = [ | 57 | MIDDLEWARE = [ |
57 | 'django.middleware.security.SecurityMiddleware', | 58 | 'django.middleware.security.SecurityMiddleware', |