From acea41cd89c5d8d9700e0afd7af59d4a5a8b4d2c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 15 Nov 2011 13:46:49 +0100 Subject: [PATCH] contest maker --- apps/poetry/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- 2.20.1