From: Radek Czajka Date: Tue, 15 Nov 2011 12:46:49 +0000 (+0100) Subject: contest maker X-Git-Url: https://git.mdrn.pl/turniej.git/commitdiff_plain/acea41cd89c5d8d9700e0afd7af59d4a5a8b4d2c?ds=inline;hp=c9d036f4b17b01b352e3a1d20b31fac6fff9b26b contest maker --- diff --git a/apps/poetry/models.py b/apps/poetry/models.py index 244538a..b0d15b1 100644 --- a/apps/poetry/models.py +++ b/apps/poetry/models.py @@ -3,6 +3,7 @@ import os import subprocess from django.db import models from django.core.urlresolvers import reverse +from django.conf import settings from poetry.utils import get_hash @@ -44,6 +45,14 @@ class Poet(models.Model): ) 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)