コード例 #1
0
    def test_for_user_doesnt_return_muted_conversations(self):
        """
        When we create a Comment, conversation gets created for the sharedfile owner and the
        commenter.  The conversation should appear for the commenter, unless the conversation
        gets muted, in which case it doesn't get returned.
        """
        comment = Comment(sharedfile_id=self.sharedfile.id, user_id=self.another_user.id, body='test')
        comment.save()

        another_user_conversation = Conversation.get('user_id = %s', self.another_user.id)
        self.assertEqual(0, another_user_conversation.muted)
        self.assertEqual(1, len(Conversation.for_user(self.another_user.id)))

        another_user_conversation.muted = 1
        another_user_conversation.save()
        self.assertEqual(0, len(Conversation.for_user(self.another_user.id)))
コード例 #2
0
ファイル: conversations.py プロジェクト: wjcstp/mltshp
    def get(self, show_only=None, page=None):
        current_user_object = self.get_current_user_object()
        if not page:
            page = 1
        page = int(page)
        if show_only == 'my-files':
            url_format = '/conversations/my-files/%d'
            conversations = Conversation.for_user(current_user_object.id,
                                                  type='myfiles',
                                                  page=page)
            conversations_count = Conversation.for_user_count(
                current_user_object.id, type='myfiles')
        elif show_only == 'my-comments':
            url_format = '/conversations/my-comments/%d'
            conversations = Conversation.for_user(current_user_object.id,
                                                  type='mycomments',
                                                  page=page)
            conversations_count = Conversation.for_user_count(
                current_user_object.id, type='mycomments')
        else:
            show_only = 'all'
            url_format = '/conversations/all/%d'
            conversations = Conversation.for_user(current_user_object.id,
                                                  page=page)
            conversations_count = Conversation.for_user_count(
                current_user_object.id)

        conversations_marshalled = []
        for conversation in conversations:
            conversations_marshalled.append({
                'sharedfile':
                conversation.sharedfile(),
                'comments':
                conversation.relevant_comments(),
                'conversation':
                conversation
            })

        return self.render("conversations/index.html", conversations=conversations_marshalled, \
            page=page, count=conversations_count, url_format=url_format, selected=show_only)