Skip to content

Commit

Permalink
Merge pull request #3184 from GerardPaligot/hotfix_create_mp
Browse files Browse the repository at this point in the history
fix(api): Returns all info of pm when we create one.
  • Loading branch information
pierre-24 committed Nov 12, 2015
2 parents a229312 + 8e9e118 commit 91b2e08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zds/mp/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class PrivateTopicCreateSerializer(serializers.ModelSerializer, TitleValidator,

class Meta:
model = PrivateTopic
fields = ('id', 'title', 'subtitle', 'participants', 'text')
read_only_fields = ('id',)
fields = ('id', 'title', 'subtitle', 'participants', 'text',
'author', 'participants', 'last_message', 'pubdate')
read_only_fields = ('id', 'author', 'last_message', 'pubdate')

def create(self, validated_data):
# This hack is necessary because `text` isn't a field of PrivateTopic.
Expand Down
6 changes: 6 additions & 0 deletions zds/mp/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ def test_create_of_private_topics(self):
self.assertEqual(response.data.get('subtitle'), private_topics[0].subtitle)
self.assertEqual(response.data.get('participants')[0], private_topics[0].participants.all()[0].id)
self.assertEqual(data.get('text'), private_topics[0].last_message.text)
self.assertEqual(response.data.get('author'), self.profile.user.id)
self.assertIsNotNone(response.data.get('last_message'))
self.assertIsNotNone(response.data.get('pubdate'))

def test_create_of_private_topics_without_subtitle(self):
"""
Expand All @@ -267,6 +270,9 @@ def test_create_of_private_topics_without_subtitle(self):
self.assertEqual(response.data.get('subtitle'), private_topics[0].subtitle)
self.assertEqual(response.data.get('participants')[0], private_topics[0].participants.all()[0].id)
self.assertEqual(data.get('text'), private_topics[0].last_message.text)
self.assertEqual(response.data.get('author'), self.profile.user.id)
self.assertIsNotNone(response.data.get('last_message'))
self.assertIsNotNone(response.data.get('pubdate'))

def test_create_of_private_topics_without_title(self):
"""
Expand Down

0 comments on commit 91b2e08

Please sign in to comment.