def search_tag(tag): battle_with_tags = [] battles = Battle.all() for battle in battles: for each_tag in battle.tags: if each_tag.lower() == tag.lower(): battle_with_tags.append(battle) return render_template('all_battles.html',battles=battle_with_tags,title="Battles with tag " + tag,current_user=users.get_current_user().email())
def check_existing_battle(left,right,battle=None): existing_battles = Battle.all() for existing in existing_battles: if (existing.left.lower() == left.lower() and existing.right.lower() == right.lower()) or (existing.right.lower() == left.lower() and existing.left.lower() == right.lower()): if not battle: return True elif battle.key() != existing.key(): return True return False
def index(): count = Battle.all().count() recent_battles = Battle.all().order('-when').order('-votes').fetch(5) return render_template('new_index.html', count=count, recent_battles=recent_battles)
def yourbattles(): battles = Battle.all().filter('author =',users.get_current_user()) return render_template('all_battles.html',battles=battles,title="Your Battles",current_user=users.get_current_user().email())
def all_battles(): battles = Battle.all() return render_template('all_battles.html',battles=battles,title="Existing Battles",current_user=users.get_current_user().email())