Exemplo n.º 1
0
def record_event(user, thread, icon, message, links=None):
    event = Event.objects.create(category=thread.category,
                                 thread=thread,
                                 author=user,
                                 author_name=user.username,
                                 author_slug=user.slug,
                                 icon=icon,
                                 message=format_message(message, links))

    update_event_checksum(event)
    event.save(update_fields=['checksum'])

    thread.has_events = True
    return event
Exemplo n.º 2
0
def record_event(user, thread, icon, message, links=None):
    event = Event.objects.create(
        forum=thread.forum,
        thread=thread,
        author=user,
        author_name=user.username,
        author_slug=user.slug,
        icon=icon,
        message=format_message(message, links))

    update_event_checksum(event)
    event.save(update_fields=['checksum'])

    thread.has_events = True
    return event
Exemplo n.º 3
0
    def test_is_event_valid(self):
        """event is_valid flag returns valid value"""
        event = Event.objects.create(forum=self.forum,
                                     thread=self.thread,
                                     author=self.user,
                                     message="Lorem ipsum",
                                     author_name=self.user.username,
                                     author_slug=self.user.slug)

        update_event_checksum(event)

        self.assertTrue(is_event_valid(event))
        self.assertTrue(event.is_valid)

        event.message = "Ipsum lorem"

        self.assertFalse(is_event_valid(event))
        self.assertFalse(event.is_valid)
Exemplo n.º 4
0
    def test_is_event_valid(self):
        """event is_valid flag returns valid value"""
        event = Event.objects.create(
            forum=self.forum,
            thread=self.thread,
            author=self.user,
            message="Lorem ipsum",
            author_name=self.user.username,
            author_slug=self.user.slug)

        update_event_checksum(event)

        self.assertTrue(is_event_valid(event))
        self.assertTrue(event.is_valid)

        event.message = "Ipsum lorem"

        self.assertFalse(is_event_valid(event))
        self.assertFalse(event.is_valid)