Пример #1
0
def select():
    text = ['Loading an Image stack may take a few seconds']
    form = SelectForm()
    if form.validate_on_submit():
        session['ch'] = form.choice.data
        return redirect(url_for('confirm'))
    return render_template('select.html',
                           title='Germix Selection Menu',
                           form=form,
                           text=text)
Пример #2
0
def add_teacher():
    if current_user.admin:
        form = SelectForm()
        form.school_list.choices = DB.list_school_form()
        form.teacher_list2.choices = DB.teacher_list_form()
        form.teacher_list3.choices = DB.teacher_list_form()
        form.teacher_list.choices = DB.teacher_list_form()
        if form.submit.data:
            DB.add_teacher(form.school_list.data, form.name.data,
                           form.surname.data, form.patronymic.data,
                           form.sex.data, form.subject.data)
            return redirect(url_for("add_teacher"))
        if form.submit3.data:
            DB.update_teacher(id=form.teacher_list2.data,
                              name=form.name2.data,
                              surname=form.surname2.data,
                              patronymic=form.patronymic2.data,
                              subject=form.subject2.data,
                              sex=form.sex2.data)
            return redirect(url_for("add_teacher"))
        if form.submit2.data:
            DB.delete_teacher(form.teacher_list3.data)
            return redirect(url_for("add_teacher"))
        return render_template("add_teacher.html",
                               form=form,
                               rows=DB.teacher_list())
    else:
        return redirect(url_for("index"))
Пример #3
0
def tst():
    form = SelectForm()
    if form.submit.data:
        print(form.a1.data)
    if not current_user.admin or not current_user.super_admin:
        return render_template("jq.html",
                               form=form,
                               name=DB.get_student_name(current_user.id))
    return render_template("jq.html", form=form, name="Админ")
Пример #4
0
def change_pass():
    form = SelectForm()
    if form.submit.data:
        token = generate_confirmation_token(form.email.data)
        confirm_url = url_for('confirm_pass', token=token, _external=True)
        html = render_template('change_pass.html', confirm_url=confirm_url)
        subject = "Сылка для изменения пароля"
        send_email(form.email.data, subject, html)
        return "На ваш email отправлено письмо"
    return render_template('email_pass.html', title='Email', form=form)
Пример #5
0
def del_schedule():
    if current_user.admin:
        form = SelectForm()
        form.schedule_list.choices = DB.schedule_list()
        if form.submit2.data:
            DB.delete_schedule(form.schedule_list.data)
            return redirect(url_for("index"))
        return render_template("del_schedule.html", form=form)
    else:
        return redirect(url_for("index"))
Пример #6
0
def add_schedule():
    if current_user.admin:
        form = SelectForm()
        form.class_list.choices = DB.class_list_form()
        if form.submit2.data:
            DB.add_schedule(form.class_list.data)
            return redirect(
                url_for("add_schedule2", class_id=form.class_list.data))
        return render_template("add_schedule1.html", form=form)
    else:
        return redirect(url_for("index"))
Пример #7
0
def add_studentgroup2(class_id):
    if current_user.admin:
        form = SelectForm()
        form.group_list.choices = DB.group_list_form(class_id)
        form.a1.choices = DB.student_list_form()
        if form.submit2.data:
            DB.add_student_to_group(form.a1.data, form.group_list.data)
            return redirect(url_for("add_studentgroup"))
        return render_template("add_stundentgroup2.html", form=form)
    else:
        return redirect(url_for("index"))
Пример #8
0
def del_student_to_group():
    if current_user.admin:
        form = SelectForm()
        form.group_list.choices = DB.studentgroup_list_form()
        if form.submit2.data:
            a = form.group_list.data
            a = a.split(" ")
            DB.delete_student_from_group(a[1], a[0])
            return redirect(url_for("index"))
        return render_template("del_student_group.html", form=form)
    else:
        return redirect(url_for("index"))
Пример #9
0
def dell_group(class_id):
    if current_user.admin:
        form = SelectForm()
        form.group_list.choices = DB.group_list_form(class_id)
        if form.submit2.data:
            DB.delete_group(form.group_list.data)
            return redirect(url_for("add_group"))
        return render_template("de_group.html",
                               form=form,
                               rows=DB.group_list())
    else:
        return redirect(url_for("index"))
Пример #10
0
def confirm_pass(token):
    form = SelectForm()
    try:
        email = confirm_token(token)
    except:
        flash('The confirmation link is invalid or has expired.', 'danger')
    user = User.query.filter_by(email=email).first_or_404()
    if form.submit.data:
        user.set_password(str(form.name.data))
        db.session.commit()
        return redirect(url_for("logout"))
    return render_template("ch_pass.html", form=form)
Пример #11
0
def add_school():
    if current_user.super_admin:
        form = SelectForm()
        form.school_list.choices = DB.list_school_form()
        if form.submit2.data:
            DB.add_school(form.name.data, form.surname.data)
            return redirect(url_for("add_school"))
        if form.submit.data:
            DB.delete_school(form.school_list.data)
            return redirect(url_for("add_school"))
        return render_template("school.html", form=form, rows=DB.school_list())
    else:
        return redirect(url_for("index"))
Пример #12
0
def select():
    form = SelectForm()
    imgs = get_imgs_name(app.config['UPLOADED_PHOTOS_DEST'])

    if request.method == 'POST':
        if form.validate_on_submit():
            short_name = form.name.data
            full_name = ''
            for f_name in imgs:
                if f_name.split('@')[0] == short_name:
                    full_name = f_name
            print(full_name)

            selecting(full_name)

            flash(f"you have f*****g select the {short_name}.")
        return redirect('select')
    else:
        return render_template('select.html',
                               title='Select',
                               form=form,
                               images=imgs)
Пример #13
0
def add_email():
    form = SelectForm()
    if form.submit.data:
        User.query.filter_by(id=current_user.id).update(
            {"email": form.email.data})
        db.session.commit()
        token = generate_confirmation_token(current_user.email)
        confirm_url = url_for('confirm_email', token=token, _external=True)
        html = render_template('activate.html', confirm_url=confirm_url)
        subject = "Please confirm your email"
        send_email(current_user.email, subject, html)
        print(1)
        flash('Congratulations, you are now a registered user!')
        return "На ваш email было высланно письмо"
    return render_template('email.html', title='Email', form=form)
Пример #14
0
def add_group():
    if current_user.admin:
        form = SelectForm()
        form.class_list.choices = DB.class_list_form()
        form.class_list2.choices = DB.class_list_form()
        if form.submit.data:
            DB.add_group(form.class_list.data, form.name.data)
            return redirect(url_for("add_group"))
        if form.submit2.data:
            return redirect(
                url_for("dell_group", class_id=form.class_list2.data))
        return render_template("add_groupp.html",
                               form=form,
                               rows=DB.group_list())
    else:
        return redirect(url_for("index"))
Пример #15
0
def add_studentgroup():
    if current_user.admin:
        form = SelectForm()
        form.class_list.choices = DB.class_list_form()
        form.group_list.choices = DB.studentgroup_list_form()
        if form.submit2.data:
            return redirect(
                url_for("add_studentgroup2", class_id=form.class_list.data))
        if form.submit.data:
            a = form.group_list.data
            a = a.split(" ")
            DB.delete_student_from_group(a[1], a[0])
            return redirect(url_for("add_studentgroup"))
        return render_template("add_studentgroup.html",
                               form=form,
                               rows=DB.studentgroup_list_form())
    else:
        return redirect(url_for("index"))
Пример #16
0
def add_student():
    if current_user.admin:
        form = SelectForm()
        form.student_list.choices = DB.student_list_form()
        form.class_list.choices = DB.class_list_form()
        form.school_list.choices = DB.list_school_form()
        form.student_list2.choices = DB.student_list_form()
        form.class_list2.choices = DB.class_list_form()
        if form.submit.data:
            DB.add_student(form.school_list.data, form.class_list.data,
                           form.name.data, form.surname.data,
                           form.patronymic.data, form.sex.data,
                           form.password.data)
            return "Данные для " + str(form.name.data) + " " + str(
                form.surname.data
            ) + " " + str(form.patronymic.data) + " Логин:пароль  " + str(
                DB.get_last_added_userid()
            ) + " : " + form.password.data + """ <a href="/add_student" font-size="16">ок</a>"""

        if form.submit3.data:
            DB.update_student(id=form.student_list2.data,
                              class_id=form.class_list2.data,
                              sex=form.sex2.data,
                              name=form.name2.data,
                              surname=form.surname2.data,
                              patronymic=form.patronymic2.data,
                              password=form.password2.data)
            return redirect(url_for("add_student"))
        if form.submit2.data:
            student = db.session.query(Students).filter_by(
                id=form.student_list.data)
            student = student.all()
            user_id = student[0].id_user
            db.session.query(User).filter_by(id=user_id).delete()
            db.session.query(Students).filter_by(
                id=form.student_list.data).delete()
            db.session.commit()
            return redirect(url_for("add_student"))
        return render_template("add_student2.html",
                               form=form,
                               rows=DB.student_list())
    else:
        return redirect(url_for("index"))