Exemplo n.º 1
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(name=post['name'],
                       description=post['description'],
                       category=post['category'],
                       image=post['image'],
                       value=int(post['value']))
         badge.save()
     elif post['kind'] == 'article':
         date = datetime.datetime.strptime(post['date'], '%Y-%m-%d').date()
         article = NewsArticle(title=post['title'],
                               author=post['author'],
                               body=post['body'],
                               date=date)
         article.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(member=member,
                           badge=badge,
                           date=datetime.date.today(),
                           proof=post['proof'])
             award.save()
     elif post['kind'] == 'talk':
         talk = Talk(title=post['title'],
                     date=datetime.datetime.strptime(
                         post['date'], '%Y-%m-%d').date(),
                     description=post['description'],
                     member=Member.get_by_id(int(post['member'])),
                     video=post['video'])
         talk.put()
     self.get()
Exemplo n.º 2
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         b = Badge(name=post['name'],
                   description=post['description'],
                   category=post['category'],
                   image=post['image'],
                   value=int(post['value']))
         b.save()
     elif post['kind'] == 'article':
         a = NewsArticle(title=post['title'],
                         author=post['author'],
                         body=post['body'],
                         date=datetime.date.today())
         a.save()
     elif post['kind'] == 'award':
         badge = Badge.gql('WHERE name = :1', post['badge']).get()
         for h in post.getall('hackers'):
             hacker = Hacker.gql('WHERE handle = :1', h).get()
             a = Award(hacker=hacker,
                       badge=badge,
                       date=datetime.date.today(),
                       proof=post['proof'])
             a.save()
             hacker.score_cache = hacker.score + badge.value
             hacker.save()
     self.get()
Exemplo n.º 3
0
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(
             name=post['name'],
             description=post['description'],
             category=post['category'],
             image=post['image'],
             value=int(post['value'])
         )
         badge.save()
     elif post['kind'] == 'article':
         date = datetime.datetime.strptime(post['date'], '%Y-%m-%d').date()
         article = NewsArticle(
             title=post['title'],
             author=post['author'],
             body=post['body'],
             date=date
         )
         article.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(
                 member=member,
                 badge=badge,
                 date=datetime.date.today(),
                 proof=post['proof']
             )
             award.save()
             member.score_cache = member.score + badge.value
             member.save()
     elif post['kind'] == 'talk':
         talk = Talk(
             title=post['title'],
             date=datetime.datetime.strptime(post['date'], '%Y-%m-%d').date(),
             description=post['description'],
             member=Member.get_by_id(int(post['member'])),
             video=post['video']
         )
         talk.put()
     self.get()
Exemplo n.º 4
0
 def post(self):
     post =  self.request.POST
     if post['kind'] == 'badge':
         b = Badge(name=post['name'], description=post['description'], 
                   category=post['category'], image=post['image'],
                   value=int(post['value']))
         b.save()
     elif post['kind'] == 'article':
         a = NewsArticle(title=post['title'], author=post['author'],
                          body=post['body'], date=datetime.date.today())
         a.save()
     elif post['kind'] == 'award':
         badge = Badge.gql('WHERE name = :1', post['badge']).get()
         for h in post.getall('hackers'):
             hacker = Hacker.gql('WHERE handle = :1', h).get()
             a=Award(hacker=hacker, 
                     badge=badge,
                     date=datetime.date.today(),
                     proof=post['proof'])
             a.save()
             hacker.score_cache = hacker.score + badge.value
             hacker.save()
     self.get()