def solve(self, solution, winner): self.active = False self.solved = True self.solution = solution self.winner = winner self.put() send_message(self.email, "bounty_solved", bounty=self)
def bounties(): cursor = request.values.get("cursor") sortfilterform = SortFilterForm(request.values) form = BountyForm(request.form) if request.method == 'POST' and form.validate(): b = Bounty.from_form(form) b.put() send_message(b.email, "bounty_submitted", bounty=b) return redirect(url_for('bounties')) query = Bounty.all().filter('active =', True) if sortfilterform.validate(): sort = sortfilterform.sort.data filter = sortfilterform.filter.data if sort == 'age_desc': query = query.order('-ctime') elif sort == 'age_asc': query = query.order('ctime') elif sort == 'reward_desc': query = query.order('-bounty') elif sort == 'reward_asc': query = query.order('bounty') if filter == 'md5': query = query.filter('type =', 'md5') elif filter == 'sha1': query = query.filter('type =', 'sha1') if cursor: query.with_cursor(cursor) bounties = query.fetch(24) cursor = query.cursor() return render_template('bounties.html', form=form, sortfilterform=sortfilterform, bounties=bounties, cursor=cursor)