The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Add User.failed_words()

It lists all the words the user has failed to upload work for
master
Gergely Polonkai 7 years ago
parent 3da4b39860
commit 65019fd713
  1. 8
      words/apps.py
  2. 18
      words/tests.py

@ -78,6 +78,13 @@ def _draw_word(self):
return word
def _failed_words(self):
from .models import Draw
flt = filter(lambda x: not x.successful(), Draw.objects.filter(user=self))
return [draw.word for draw in flt]
class WordsConfig(AppConfig):
name = 'words'
@ -85,3 +92,4 @@ class WordsConfig(AppConfig):
User.current_word = _current_word
User.draw_word = _draw_word
User.last_draw = _last_draw
User.failed_words = _failed_words

@ -194,3 +194,21 @@ class DrawTest(TestCase):
draw.save()
self.assertIsNotNone(draw.successful())
self.assertFalse(draw.successful())
def test_failed_words(self):
self.assertEquals([], self.user.failed_words())
draw = Draw.objects.create(user=self.user,
word=self.word,
accepted=True,
timestamp=timezone.now() - timedelta(days=2))
self.assertEquals([draw.word], self.user.failed_words())
draw2 = Draw.objects.create(user=self.user,
word=Word.objects.create(),
accepted=True,
timestamp=timezone.now() - timedelta(days=3))
Work.objects.create(draw=draw2,
upload_time=timezone.now() - timedelta(days=3))
self.assertEquals([draw.word], self.user.failed_words())

Loading…
Cancel
Save