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()
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})
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})
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})
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 })
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()
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})