コード例 #1
0
ファイル: app.py プロジェクト: pierce403/hashbounty
 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)
コード例 #2
0
ファイル: app.py プロジェクト: pierce403/hashbounty
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)