Exemple #1
0
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
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
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