示例#1
0
def user_process_engdict_edit(username, engword):
    username = User.query.filter_by(username=username).first_or_404()
    form = WordInsertForm()
    word_in_form = form.insert.data
    english_word, translation = user_engdict_add_word(word_in_form, engword,
                                                      username)
    flash(
        f'Cлово "{english_word}" добавлено в ваш английский словарь, перевод: "{translation}".'
    )
    return redirect(url_for('.user_engdict_index', username=username.username))
示例#2
0
def user_process_frenchdict_insert(username):
    username = User.query.filter_by(username=username).first_or_404()
    form = WordInsertForm()
    word_in_form = form.insert.data
    word = session.get('word')
    french_word, translation = user_frenchdict_add_word(
        word_in_form, word, username)
    flash(
        f'Cлово "{french_word}" добавлено в ваш французский словарь, перевод: "{translation}".'
    )
    return redirect(
        url_for('.user_frenchdict_index', username=username.username))
示例#3
0
def user_edit_frenchword(username, word_to_edit):
    username = User.query.filter_by(username=username).first_or_404()
    word_to_edit = user_frenchdict_delete_word(word_to_edit, username)
    translation = user_frenchdict_translate(word_to_edit.word_itself)
    translation_form = WordInsertForm()
    title = 'Ваш французский словарь'
    search_form = FrenchDictionarySearchForm()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_frenchdict_edit.html',
                           page_title=title,
                           french_word=word_to_edit.word_itself,
                           translation=translation,
                           form=search_form,
                           translation_form=translation_form,
                           user=username.username,
                           user_status=user_status)
示例#4
0
def user_process_engdict_search(username):
    username = User.query.filter_by(username=username).first_or_404()
    title = 'Ваш английский словарь'
    search_form = EngDictionarySearchForm()
    delete_form = DeleteEngWordButton()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    if search_form.validate_on_submit():
        word_in_form, word = search_form.word.data, None
        session['word'] = search_form.word.data
        word, user_english_word_status, user_english_word_date, userword_id = user_engdict_search(
            word_in_form, username)

        if word:
            return render_template(
                'dictionary/user_engdict_search.html',
                page_title=title,
                english_word=word,
                english_word_status=user_english_word_status,
                english_word_date=user_english_word_date,
                form=search_form,
                delete_form=delete_form,
                user=username.username,
                user_status=user_status)

        flash('Такого слова нет в вашем английском словаре')
        translation = user_engdict_translate(word_in_form)
        if translation:
            translation_form = WordInsertForm()
            return render_template('dictionary/user_engdict_insert.html',
                                   page_title=title,
                                   english_word=word_in_form,
                                   translation=translation,
                                   form=search_form,
                                   translation_form=translation_form,
                                   user=username.username,
                                   user_status=user_status)
        return redirect(
            url_for('.user_engdict_index', username=username.username))