Exemplo n.º 1
0
def process_engdict_search(username):
    username = User.query.filter_by(username=username).first_or_404()
    title = 'Английский словарь (в алфавитном порядке)'
    search_form = EngDictionarySearchForm()
    english_words = EnglishWord.query.order_by(EnglishWord.word_itself).all()
    english_words_sum = len(english_words)
    if search_form.validate_on_submit():
        word = search_form.word.data
        if re.fullmatch('[a-zA-Z- ]+', word):
            word = EnglishWord.query.filter_by(
                word_itself=search_form.word.data).first()
        elif re.fullmatch('[а-яА-Я- ]+', word):
            word = EnglishWord.query.filter_by(
                translation_rus=search_form.word.data).first()
        else:
            word = None
        if word:
            return render_template('dictionary/engdict_search.html',
                                   page_title=title,
                                   english_word=word,
                                   english_list_len=english_words_sum,
                                   form=search_form,
                                   user=username.username)

        flash('Такого слова нет в нашем английском словаре')
        return redirect(url_for('.engdict_index', username=username.username))
Exemplo n.º 2
0
def engdict_index(username):
    username = User.query.filter_by(username=username).first_or_404()
    search_form = EngDictionarySearchForm()
    title = 'Английский словарь (в алфавитном порядке)'
    english_words = EnglishWord.query.order_by(EnglishWord.word_itself).all()
    english_words_sum = len(
        EnglishWord.query.order_by(EnglishWord.word_itself).all())
    return render_template('dictionary/engdict_index.html',
                           page_title=title,
                           english_list=english_words,
                           english_list_len=english_words_sum,
                           form=search_form,
                           user=username.username)
Exemplo n.º 3
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))
Exemplo n.º 4
0
def user_edit_engword_transcription(username, word_to_edit):
    username = User.query.filter_by(username=username).first_or_404()
    transcription_form = TranscriptionInsertForm()
    title = 'Ваш английский словарь'
    search_form = EngDictionarySearchForm()
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_engdict_edit_transcription.html',
                           page_title=title,
                           english_word=word_to_edit,
                           form=search_form,
                           transcription_form=transcription_form,
                           user=username.username,
                           user_status=user_status)
Exemplo n.º 5
0
def user_engdict_index(username):
    username = User.query.filter_by(username=username).first_or_404()
    search_form = EngDictionarySearchForm()
    title = 'Ваш английский словарь'
    english_list = process_user_engdict_index(username)
    english_words_sum = len(english_list)
    user_id = current_user.get_id()
    user_status = check_teacher_student(user_id)
    return render_template('dictionary/user_engdict_index.html',
                           page_title=title,
                           english_list=english_list,
                           english_list_len=english_words_sum,
                           form=search_form,
                           user=username.username,
                           user_status=user_status)
Exemplo n.º 6
0
def user_search_engword_button(username, word_to_search):
    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)
    word, user_english_word_status, user_english_word_date, userword_id = user_engdict_search(
        word_to_search, username)
    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)