def random(): word = Entry.get_random() # Test if an entry was returned if word: word = word['slug'] return redirect(url_for('qchar', word=word)) else: return ""
def define(slug): captcha = {'ip_address': request.remote_addr} form = DefinitionForm(request.form, captcha=captcha) if slug != 'x': form.entry.data = slug.replace('_', ' ') if request.method == 'POST' and form.validate(): #Check if entry exists previously slug = slugEncode(form.entry.data).lower() try: entry = Entry.objects.get(slug=slug) except Entry.DoesNotExist: entry = Entry(name=form.entry.data) d = Definition(content=form.definition.data, example=form.example.data) d.save() entry.definitions.append(d) entry.save() return redirect(url_for('qchar', word=slug)) return render_template('new_definition.html', form=form)
def main(): samples = [] for i in range(3): e = Entry.objects.get(slug=Entry.get_random()['slug']) samples.append({'name': e.name, 'definition': e.get_hero()}) return render_template('main.html', letters=[x for x in uppercase], samples=samples)
def main(): samples = [] for i in range(3): e = Entry.objects.get(slug=Entry.get_random()['slug']) samples.append({'name': e.name, 'definition': e.get_hero()}) return render_template( 'main.html', letters=[x for x in uppercase], samples=samples )
def search(page=0): id_list = Entry.search(''.join(request.args['b'])) count = len(id_list) / settings.PAGE_SIZE + 1 if page >= count: page = count - 1 r = [] for i in id_list[page * settings.PAGE_SIZE: settings.PAGE_SIZE * (page + 1)]: r.append(Entry.objects.get(id=i)) paginator = Paginator(page, count) return render_template('results.html', results=r, paginator=paginator)
def search(page=0): id_list = Entry.search(''.join(request.args['b'])) count = len(id_list) / settings.PAGE_SIZE + 1 if page >= count: page = count - 1 r = [] for i in id_list[page * settings.PAGE_SIZE:settings.PAGE_SIZE * (page + 1)]: r.append(Entry.objects.get(id=i)) paginator = Paginator(page, count) return render_template('results.html', results=r, paginator=paginator)
def main(): """ Presents main Page With 3 random words on the front page if DB has more than 3 words. """ samples = [] for i in range(3): #e = Entry.objects.get(slug=Entry.get_random()['slug']) entry = Entry.get_random() if entry: samples.append({'name': entry.name, 'definition': entry.get_hero()}) return render_template( 'main.html', letters=[x for x in uppercase], samples=samples )
def random(): word = Entry.get_random()['slug'] return redirect(url_for('qchar', word=word))
(page + 1)]: r.append(Entry.objects.get(id=i)) paginator = Paginator(page, count) return render_template('results.html', results=r, paginator=paginator) @app.route('/buscar/top/') def searchbox(): term = request.args['term'] if not re.match(ur"^[a-zA-Z0-9\s_áéíóúÁÉÍÓÚñÑ]+$", term): return "" term = term.encode('translit/long') if len(term) >= 1: return simplejson.dumps(Entry.search_terms(term)) else: return "" """ # make apache handle it later on @app.errorhandler(404) def page_not_found(error): return render_template('404.html'), 404 @app.errorhandler(500) def page_not_found(error): return render_template('404.html'), 500 """
for i in id_list[page * settings.PAGE_SIZE: settings.PAGE_SIZE * (page + 1)]: r.append(Entry.objects.get(id=i)) paginator = Paginator(page, count) return render_template('results.html', results=r, paginator=paginator) @app.route('/buscar/top/') def searchbox(): term = request.args['term'] if not re.match(ur"^[a-zA-Z0-9\s_áéíóúÁÉÍÓÚñÑ]+$", term): return "" term = term.encode('translit/long') if len(term) >= 1: return simplejson.dumps(Entry.search_terms(term)) else: return "" """ # make apache handle it later on @app.errorhandler(404) def page_not_found(error): return render_template('404.html'), 404 @app.errorhandler(500) def page_not_found(error): return render_template('404.html'), 500 """