contest maker
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 15 Nov 2011 12:46:49 +0000 (13:46 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 15 Nov 2011 12:46:49 +0000 (13:46 +0100)
apps/poetry/models.py

index 244538a..b0d15b1 100644 (file)
@@ -3,6 +3,7 @@ import os
 import subprocess
 from django.db import models
 from django.core.urlresolvers import reverse
 import subprocess
 from django.db import models
 from django.core.urlresolvers import reverse
+from django.conf import settings
 from poetry.utils import get_hash
 
 
 from poetry.utils import get_hash
 
 
@@ -44,6 +45,14 @@ class Poet(models.Model):
             )
         return poem
 
             )
         return poem
 
+    def make_for_contest(self):
+        assert not self.poem_set.filter(for_contest=True).exists()
+        for i in range(settings.POETRY_POEMS_FOR_CONTEST):
+            p = self.write()
+            p.for_contest = True
+            p.save()
+        return self.poem_set.filter(for_contest=True)
+
 
 class Poem(models.Model):
     slug = models.SlugField(max_length=50, db_index=True)
 
 class Poem(models.Model):
     slug = models.SlugField(max_length=50, db_index=True)