def qchar(word): """ """ slug = slugEncode(word).lower() try: entry = Entry.objects.get(slug=slug) return render_template('word.html', entry=entry, definitions=entry.get_definitions(), word="todo bien") except Entry.DoesNotExist: return render_template('word.html', word=word.replace('_', ' ')) return render_template('404.html'), 404
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 qchar(word): """ """ slug = slugEncode(word).lower() try: entry = Entry.objects.get(slug=slug) return render_template( 'word.html', entry=entry, definitions=entry.get_definitions(), word="todo bien" ) except Entry.DoesNotExist: return render_template( 'word.html', word=word.replace('_', ' ') ) return render_template('404.html'), 404