Ejemplo n.º 1
0
def word(request, wordid):
    current_word = Definition.objects.get(word = wordid)
    same_language = Definition.objects.filter(definition =
            current_word.definition).filter(word__language=current_word.word.language).exclude(word__word
                    = current_word.word.word)
    different_languages = Definition.objects.filter(definition =
            current_word.definition).exclude(word__language=current_word.word.language)

    comments = Comment.objects.filter(word=current_word).order_by('date')
    wordCommentForm = CommentForm(request.POST or None)
    if request.method=="POST":
        print wordCommentForm
        if wordCommentForm.is_valid():
            wcfCD = wordCommentForm.cleaned_data
            comment = Comment(
                    word = current_word,
                    author=wcfCD['author_name'],
                    comment = wcfCD['comment'],
                    approved = True,
                    source_type = 1,
                    )
            comment.save()

    return render_to_response("glossy/word_page.html", locals(),
            context_instance=RequestContext(request))
Ejemplo n.º 2
0
def language(request, languageid, order=""):
    language = Language.objects.get(id = languageid)
    words = Definition.objects.filter(word__language=language).order_by('word').extra(select={'lower_name': 'lower(word)'}).order_by('lower_name')
    if order=="english":
        words = words.extra(select={'lower_name': 'lower(definition)'}).order_by('lower_name')
    comments = Comment.objects.filter(language=language).order_by('date')
    languageCommentForm = CommentForm(request.POST or None)
    if request.method=="POST":
        print languageCommentForm
        if languageCommentForm.is_valid():
            lcfCD = languageCommentForm.cleaned_data
            comment = Comment(
                    language = language,
                    author=lcfCD['author_name'],
                    comment = lcfCD['comment'],
                    approved = True,
                    source_type = 2,
                    )
            comment.save()
    return render_to_response("glossy/language_page.html", locals(),
            context_instance=RequestContext(request))