Exemple #1
0
    def save(self, *args, **kwargs):
        if self.status not in [status[0] for status in MESSAGE_STATUSES]:
            raise ValueError('Invalid topic status')
        if not self.pk:
            self.topic.new_message_update()

        # update the metainfo about creole display
        self.topic.get_creole()
        brushes = brushes_used(self.topic.Creole.parser.parse(self.content))
        self.set_brushes(list(brushes))

        new_message = self.id is None

        super(DiscussionMessage, self).save(*args, **kwargs)

        # handle subscriptions
        if new_message:
            subs = DiscussionSubscription.objects.filter(
                member__offering=self.topic.offering).select_related(
                    'member__person')
            for s in subs:
                s.notify_message(self)
            subs = TopicSubscription.objects.filter(
                member__offering=self.topic.offering,
                topic=self.topic).select_related('member__person')
            for s in subs:
                s.notify(self)
Exemple #2
0
 def test_codeblock(self):
     Creole = self._get_creole()
     brushes = brushes_used(Creole.parser.parse(wikitext))
     self.assertEqual(brushes, set(['shBrushJScript.js', 'shBrushPython.js']))
     
     html = Creole.text2html(wikitext)
     self.assertIn('class="brush: python">for i', html)
     self.assertIn('print i</pre>', html)
     self.assertIn('i=1; i&lt;4; i++', html)
Exemple #3
0
 def test_codeblock(self):
     Creole = self._get_creole()
     brushes = brushes_used(Creole.parser.parse(wikitext))
     self.assertEqual(brushes, set(['shBrushJScript.js', 'shBrushPython.js']))
     
     html = Creole.text2html(wikitext)
     self.assertIn('class="brush: python">for i', html)
     self.assertIn('print i</pre>', html)
     self.assertIn('i=1; i&lt;4; i++', html)
Exemple #4
0
    def save(self, *args, **kwargs):
        if self.status not in [status[0] for status in TOPIC_STATUSES]:
            raise ValueError('Invalid topic status')

        # update the metainfo about creole display        
        self.get_creole()
        brushes = brushes_used(self.Creole.parser.parse(self.content))
        self.set_brushes(list(brushes))
        # TODO: nobody sets config.math to True, but it is honoured if it is set magically. UI for that?

        new_topic = self.id is None
        super(DiscussionTopic, self).save(*args, **kwargs)

        # handle subscriptions
        if new_topic:
            subs = DiscussionSubscription.objects.filter(member__offering=self.offering).select_related('member__person')
            for s in subs:
                s.notify(self)
Exemple #5
0
    def save(self, *args, **kwargs):
        if self.status not in [status[0] for status in TOPIC_STATUSES]:
            raise ValueError('Invalid topic status')

        # update the metainfo about creole display
        self.get_creole()
        brushes = brushes_used(self.Creole.parser.parse(self.content))
        self.set_brushes(list(brushes))
        # TODO: nobody sets config.math to True, but it is honoured if it is set magically. UI for that?

        new_topic = self.id is None
        super(DiscussionTopic, self).save(*args, **kwargs)

        # handle subscriptions
        if new_topic:
            subs = DiscussionSubscription.objects.filter(
                member__offering=self.offering).select_related(
                    'member__person')
            for s in subs:
                s.notify(self)
Exemple #6
0
    def save(self, *args, **kwargs):
        if self.status not in [status[0] for status in MESSAGE_STATUSES]:
            raise ValueError('Invalid topic status')
        if not self.pk:
            self.topic.new_message_update()

        # update the metainfo about creole display        
        self.topic.get_creole()
        brushes = brushes_used(self.topic.Creole.parser.parse(self.content))
        self.set_brushes(list(brushes))
        
        new_message = self.id is None
        
        super(DiscussionMessage, self).save(*args, **kwargs)

        # handle subscriptions
        if new_message:
            subs = DiscussionSubscription.objects.filter(member__offering=self.topic.offering).select_related('member__person')
            for s in subs:
                s.notify_message(self)
            subs = TopicSubscription.objects.filter(member__offering=self.topic.offering, topic=self.topic).select_related('member__person')
            for s in subs:
                s.notify(self)