예제 #1
0
def wrong_answer_message(**kwargs):
    if kwargs['created']:
        wa = kwargs['instance']
        humbug_send(user='******',
                    stream='p%d' % (wa.puzzle.id,),
                    subject='wrong answer',
                    message='Wrong answer: %s' % wa.answer)
예제 #2
0
    def save(self, *args, **kwargs):
        # Grab old instance to see if our answer is new.
        try:
            old_puzzle = Puzzle.objects.get(id=self.id)
            old_answer = old_puzzle.answer
        except Puzzle.DoesNotExist:
            old_answer = ''

        # Save first, so that we don't create a new spreadsheet if the
        # save would fail.
        super(Puzzle, self).save(*args, **kwargs)

        if self.spreadsheet == '':
            self.spreadsheet = create_google_spreadsheet(self.title)
            # create() uses force_insert, override that here.
            kwargs['force_update'] = True
            kwargs['force_insert'] = False
            super(Puzzle, self).save(*args, **kwargs)

        if self.answer != old_answer:
            humbug_send(user='******',
                        stream='p%d' % (self.id,),
                        subject='solved!',
                        message=':thumbsup: **%s**' % self.answer)

            humbug_send(user='******',
                        stream='status',
                        subject='solved',
                        message='Puzzle %s solved' % (self.title,))
예제 #3
0
def wrong_answer_message(**kwargs):
    if kwargs['created']:
        wa = kwargs['instance']
        humbug_send(user='******',
                    stream='p%d' % (wa.puzzle.id, ),
                    subject='wrong answer',
                    message='Wrong answer: %s' % wa.answer)
예제 #4
0
    def save(self, *args, **kwargs):
        # Grab old instance to see if our answer is new.
        try:
            old_puzzle = Puzzle.objects.get(id=self.id)
            old_answer = old_puzzle.answer
        except Puzzle.DoesNotExist:
            old_answer = ''

        # Save first, so that we don't create a new spreadsheet if the
        # save would fail.
        super(Puzzle, self).save(*args, **kwargs)

        if self.spreadsheet == '':
            self.spreadsheet = create_google_spreadsheet(self.title)
            # create() uses force_insert, override that here.
            kwargs['force_update'] = True
            kwargs['force_insert'] = False
            super(Puzzle, self).save(*args, **kwargs)

        if self.answer != old_answer:
            humbug_send(user='******',
                        stream='p%d' % (self.id, ),
                        subject='solved!',
                        message=':thumbsup: **%s**' % self.answer)

            humbug_send(user='******',
                        stream='status',
                        subject='solved',
                        message='Puzzle %s solved' % (self.title, ))
예제 #5
0
def send_puzzle_humbug(**kwargs):
    if kwargs['created']:
        puzzle = kwargs['instance']
        humbug_send(user='******',
                    stream='p%d' % (puzzle.id,),
                    subject='new',
                    message='New puzzle "%s"' % (puzzle.title,))
        humbug_send(user='******',
                    stream='status',
                    subject='new puzzle',
                    message='New puzzle [%s](%s) ([p%d](%s))' %
                    (puzzle.title, puzzle.url, puzzle.id,
                     settings.BASE_URL + reverse('puzzles.views.puzzle', args=[puzzle.id])))
예제 #6
0
def send_puzzle_humbug(**kwargs):
    if kwargs['created']:
        puzzle = kwargs['instance']
        humbug_send(user='******',
                    stream='p%d' % (puzzle.id, ),
                    subject='new',
                    message='New puzzle "%s"' % (puzzle.title, ))
        humbug_send(user='******',
                    stream='status',
                    subject='new puzzle',
                    message='New puzzle [%s](%s) ([p%d](%s))' %
                    (puzzle.title, puzzle.url, puzzle.id, settings.BASE_URL +
                     reverse('puzzles.views.puzzle', args=[puzzle.id])))