Esempio n. 1
0
    def test_unpin(self):
        self.assertEqual(MessageBoardComment.objects.all().count(), 0)
        data = CommentForm(target_object=self.unicef).generate_security_data()
        data.update({
            'name': 'the supplied name',
            'comment': 'Foo'
        })
        response = self.url_post(
            self.unicef,
            reverse('comments-post-comment'), data)
        self.assertEqual(MessageBoardComment.objects.all().count(), 1)
        response = self.url_post(
            self.unicef,
            reverse('msg_board.messageboardcomment_pin', kwargs={'pk': MessageBoardComment.objects.all().first().pk})
        )
        self.assertEqual(response.status_code, 204)
        self.assertEqual(MessageBoardComment.get_all(self.unicef, pinned=True).count(), 1)

        response = self.url_get('unicef', reverse('msg_board.messageboardcomment_pinned'))
        self.assertEqual(len(response.json['results']), 1)

        response = self.url_post(
            self.unicef,
            reverse('msg_board.messageboardcomment_unpin', kwargs={'pk': MessageBoardComment.objects.all().first().pk})
        )
        self.assertEqual(response.status_code, 204)
        self.assertEqual(MessageBoardComment.get_all(self.unicef, pinned=True).count(), 0)

        response = self.url_get('unicef', reverse('msg_board.messageboardcomment_pinned'))
        self.assertEqual(len(response.json['results']), 0)
Esempio n. 2
0
    def test_unpin(self):
        self.assertEqual(MessageBoardComment.objects.all().count(), 0)
        data = CommentForm(target_object=self.unicef).generate_security_data()
        data.update({"name": "the supplied name", "comment": "Foo"})
        response = self.url_post(self.unicef, reverse("comments-post-comment"),
                                 data)
        self.assertEqual(MessageBoardComment.objects.all().count(), 1)
        response = self.url_post(
            self.unicef,
            reverse(
                "msg_board.messageboardcomment_pin",
                kwargs={"pk": MessageBoardComment.objects.all().first().pk}),
        )
        self.assertEqual(response.status_code, 204)
        self.assertEqual(
            MessageBoardComment.get_all(self.unicef, pinned=True).count(), 1)

        response = self.url_get(
            "unicef", reverse("msg_board.messageboardcomment_pinned"))
        self.assertEqual(len(response.json["results"]), 1)

        response = self.url_post(
            self.unicef,
            reverse(
                "msg_board.messageboardcomment_unpin",
                kwargs={"pk": MessageBoardComment.objects.all().first().pk}),
        )
        self.assertEqual(response.status_code, 204)
        self.assertEqual(
            MessageBoardComment.get_all(self.unicef, pinned=True).count(), 0)

        response = self.url_get(
            "unicef", reverse("msg_board.messageboardcomment_pinned"))
        self.assertEqual(len(response.json["results"]), 0)
Esempio n. 3
0
    def test_unpin(self):
        self.assertEqual(MessageBoardComment.objects.all().count(), 0)
        data = CommentForm(target_object=self.unicef).generate_security_data()
        data.update({'name': 'the supplied name', 'comment': 'Foo'})
        response = self.url_post(self.unicef, reverse('comments-post-comment'),
                                 data)
        self.assertEqual(MessageBoardComment.objects.all().count(), 1)
        response = self.url_post(
            self.unicef,
            reverse(
                'msg_board.messageboardcomment_pin',
                kwargs={'pk': MessageBoardComment.objects.all().first().pk}))
        self.assertEqual(response.status_code, 204)
        self.assertEqual(
            MessageBoardComment.get_all(self.unicef, pinned=True).count(), 1)

        response = self.url_get(
            'unicef', reverse('msg_board.messageboardcomment_pinned'))
        self.assertEqual(len(response.json['results']), 1)

        response = self.url_post(
            self.unicef,
            reverse(
                'msg_board.messageboardcomment_unpin',
                kwargs={'pk': MessageBoardComment.objects.all().first().pk}))
        self.assertEqual(response.status_code, 204)
        self.assertEqual(
            MessageBoardComment.get_all(self.unicef, pinned=True).count(), 0)

        response = self.url_get(
            'unicef', reverse('msg_board.messageboardcomment_pinned'))
        self.assertEqual(len(response.json['results']), 0)
Esempio n. 4
0
 def get_object(self, queryset=None):
     return get_object_or_404(MessageBoardComment.get_all(
         self.request.org),
                              pk=self.kwargs.get("pk"))
Esempio n. 5
0
 def get_queryset(self):
     return MessageBoardComment.get_all(
         self.request.org, pinned=True).order_by("-pinned_on")
Esempio n. 6
0
 def get_queryset(self):
     return MessageBoardComment.get_all(
         self.request.org).order_by("-submit_date")
Esempio n. 7
0
 def get_object(self, queryset=None):
     return get_object_or_404(MessageBoardComment.get_all(self.request.org), pk=self.kwargs.get('pk'))
Esempio n. 8
0
 def get_queryset(self):
     return MessageBoardComment.get_all(self.request.org, pinned=True).order_by('-pinned_on')
Esempio n. 9
0
 def get_queryset(self):
     return MessageBoardComment.get_all(self.request.org).order_by('-submit_date')