Пример #1
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()
Пример #2
0
 def get(self):
     order = self.request.GET.get('order', 'value')
     if order == 'receivers':
         badges = list(Badge.all())
         badges.sort(key=lambda i: i.awards.count())
     else:
         badges = Badge.gql('ORDER BY ' + order)
     self.render_template('badges', {'badges': badges})
Пример #3
0
 def get(self):
     order = self.request.GET.get('order', 'value')
     if order == 'receivers':
         b = list(Badge.all())
         b.sort(key=lambda i:i.awards.count())
     else:
         b = Badge.gql('ORDER BY ' + order)
     self.render_template('badges', {'badges': b})
Пример #4
0
 def get(self):
     selected_badge = self.request.GET.getall('badge')
     if selected_badge:
         selected_badge = selected_badge[0]
     else:
         selected_badge = None
     
     badges = Badge.gql('ORDER BY name')
     self.render_template('badge_application', template_dict={'badges':badges,
         'selected_badge': selected_badge})
Пример #5
0
 def get(self):
     selected_badge = self.request.GET.getall('badge')
     if selected_badge:
         selected_badge = selected_badge[0]
     else:
         selected_badge = None
     badges = Badge.gql('ORDER BY name')
     self.render_template('badge_application', {
         'badges': badges,
         'selected_badge': selected_badge
     })
Пример #6
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()
Пример #7
0
 def get(self, name):
     query = Badge.gql('WHERE name = :1', urllib.unquote(name))
     badge = iter(query).next() if query.count() else None
     self.render_template('badge', {'badge': badge})
Пример #8
0
 def get(self, name):
     query = Badge.gql('WHERE name = :1', urllib.unquote(name))
     badge = iter(query).next() if query.count() else None
     self.render_template('badge', {'badge': badge})