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)
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,))
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)
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, ))
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])))
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])))