<s> import datetime <EOL> from django . utils import timezone <EOL> from django . db import models <EOL> from lino . api import dd <EOL> class Poll ( dd . Model ) : <EOL> question = models . CharField ( "<STR_LIT>" , max_length = <NUM_LIT:200> ) <EOL> hidden = models . BooleanField ( <EOL> "<STR_LIT>" , <EOL> help_text = "<STR_LIT>" , <EOL> default = False ) <EOL> pub_date = models . DateTimeField ( '<STR_LIT>' , default = dd . today ) <EOL> class Meta : <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return self . question <EOL> def was_published_recently ( self ) : <EOL> return self . pub_date >= timezone . now ( ) - datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> class Choice ( dd . Model ) : <EOL> poll = models . ForeignKey ( Poll ) <EOL> choice = models . CharField ( "<STR_LIT>" , max_length = <NUM_LIT:200> ) <EOL> votes = models . IntegerField ( "<STR_LIT>" , default = <NUM_LIT:0> ) <EOL> class Meta : <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return self . choice <EOL> @ dd . action ( help_text = "<STR_LIT>" ) <EOL> def vote ( self , ar ) : <EOL> def yes ( ar ) : <EOL> self . votes += <NUM_LIT:1> <EOL> self . save ( ) <EOL> return ar . success ( <EOL> "<STR_LIT>" % self , <EOL> "<STR_LIT>" , refresh = True ) <EOL> if self . votes > <NUM_LIT:0> : <EOL> msg = "<STR_LIT>" % ( self , self . votes ) <EOL> msg += "<STR_LIT>" <EOL> return ar . confirm ( yes , msg ) <EOL> return yes ( ar ) <EOL> from . ui import * </s>
