X-Git-Url: https://git.mdrn.pl/copyspeak.git/blobdiff_plain/b61fb61373dbb41f789aa0f28c5d944a53d36027..c0f0f87735b113fd510ef0a0c026c05f0daf077d:/src/words/models.py diff --git a/src/words/models.py b/src/words/models.py index a1c5fbd..cc1b1c1 100644 --- a/src/words/models.py +++ b/src/words/models.py @@ -31,15 +31,13 @@ class Word(models.Model): def get_next(self): try: - return Word.objects.filter(alignment=self.alignment, word__gt=self.word)[0] + return Word.objects.filter(word__gt=self.word)[0] except IndexError: - next_alignment = ALIGNMENTS[([a[0] for a in ALIGNMENTS].index(self.alignment) + 1) % len(ALIGNMENTS)][0] - return Word.objects.filter(alignment=next_alignment)[0] + return Word.objects.all()[0] def get_previous(self): words = Word.objects.order_by('-word') try: - return words.filter(alignment=self.alignment, word__lt=self.word)[0] + return words.filter(word__lt=self.word)[0] except IndexError: - prev_alignment = ALIGNMENTS[([a[0] for a in ALIGNMENTS].index(self.alignment) - 1) % len(ALIGNMENTS)][0] - return words.filter(alignment=prev_alignment)[0] + return words[0]