예제 #1
0
파일: test_polls.py 프로젝트: pystar/pystar
    def make_metal_poll(bandname, opinions):
        pub = datetime.datetime.now()
        marks = '?' * random.randint(1, 5)
        question = bandname + marks
        chosen = random.sample(opinions, 5)
        choices = list()
        for c in chosen:
            votes = random.randint(1, 1000)
            choices.append(Choice(choice=c, votes=votes))

        p = Poll(question=question, pub_date=pub)
        p.save()
        p.choice_set = choices
        return p
예제 #2
0
 def make_metal_poll(bandname,opinions):
     pub = datetime.datetime.now()
     marks = '?' * random.randint(1,5)
     question = bandname + marks
     chosen = random.sample(opinions,5)
     choices = list()
     for c in chosen:
         votes = random.randint(1,1000)
         choices.append(Choice(choice=c,votes=votes))
     
     p = Poll(question=question,pub_date=pub)
     p.save()
     p.choice_set=choices
     return p