Example #1
0
def stacked_vertical():
    total = Totals.get_or_insert('total')
    if len(total.shirts) == 0:
        shirts = sorted(T_Shirts, key= lambda shirt: shirt[0])
        for shirt in shirts:
            total.shirts.append(shirt[0])
            total.votes.append(0)
    
    votes = []
    shirts = []
    i = 0
    while i < len(total.votes):
        if total.votes[i] != 0:
            votes.append(total.votes[i])
            shirts.append('Design %s' % total.shirts[i])
        i += 1
    
    if len(votes) == 0:
      return ''
      
    
    chart = PieChart3D(650, 300)
    chart.add_data(votes)
    chart.set_pie_labels(shirts)
    return chart.get_url()
Example #2
0
 def post(self):
     lugger = Lugger.get_by_key_name(self.request.get('id'))
     vote = int(self.request.get('vote'))
     if lugger.votes.count(vote) == 0:
         total = Totals.get_or_insert('total')
         lugger.votes.append(vote)
         if len(total.shirts) == 0:
             shirts = sorted(T_Shirts, key= lambda shirt: shirt[0])
             for shirt in shirts:
                 total.shirts.append(shirt[0])
                 total.votes.append(0)                    
         total.votes[total.shirts.index(vote)] += (4-len(lugger.votes))
         total.put()
         lugger.put()
     self.redirect('/vote')