def add_department(): form = DepartmentsForm() if form.validate_on_submit(): session = db_session.create_session() if not session.query(User).filter(User.id == form.chief.data).first(): return render_template('department.html', title='Добавление департамента', form=form, message="Id ТимЛида не существует") if session.query(Departments).filter( Departments.email == form.email.data).first(): return render_template( 'department.html', title='Добавление департамента', form=form, message="Департамент с такой почтой уже существует") dep = Departments(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data) current_user.departments.append(dep) session.merge(current_user) session.commit() return redirect('/departments') return render_template('department.html', title='Добавление департамента', form=form)
def adding_department(): form = AddingDepartment() if form.validate_on_submit(): connect = db_session.create_session() department = Departments(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data, user_id=current_user.id) connect.add(department) connect.commit() return redirect("/departments") return render_template('adding_department.html', title="Add department", form=form)
def add_dep(): form = DepForm() if form.validate_on_submit(): db_session.global_init('db/blogs.db') db_sess = db_session.create_session() dep = Departments() dep.title = form.title.data dep.chief = int(form.chief.data) dep.members = form.members.data dep.email = form.email.data db_sess.add(dep) db_sess.commit() return redirect("/dep") return render_template('add_dep.html', title='Add a dep', form=form)
def add_department(): form = DepartmentForm() if request.method == 'POST' and form.validate_on_submit(): s = db_session.create_session() dep = Departments() dep.chief = form.chief.data dep.title = form.title.data dep.members = form.members.data dep.email = form.email.data s.add(dep) s.commit() return redirect('/departments') return render_template('add_department.html', title='Добавление департамента', form=form)
def adddepartment(): form = Department() if request.method == "POST": if form.submit.data: db_session.global_init("db/mars_explorer.sqlite") session = db_session.create_session() dep = Departments() dep.title = form.title.data dep.chief = form.chief.data dep.members = form.members.data dep.email = form.email.data session.add(dep) session.commit() return redirect('/department') return render_template('adddepart.html', form=form)
def add_department(): form = DepartmentsForm() if form.validate_on_submit(): print(1) session = create_session() department = Departments() department.title = form.title.data department.chief = form.chief.data department.members = form.members.data department.email = form.email.data session.add(department) session.merge(current_user) session.commit() return redirect('/departments') return render_template('departmentsAdd.html', title='Adding a department', form=form)
def add_departments(): form = DepartmentsForm() if form.validate_on_submit(): session = db_session.create_session() departments = Departments() departments.title = form.title.data departments.chief = form.chief.data departments.members = form.members.data departments.email = form.email.data current_user.department.append(departments) session.merge(current_user) session.commit() return redirect('/departments') return render_template('new_department.html', title='Добавление департамента', form=form)
def adddepartment(): form = DepartmentForm() if form.validate_on_submit(): if form.validate_on_submit(): session = db_session.create_session() d = Departments() d.title = form.title.data d.chief = form.chief.data d.members = form.members.data d.email = form.email.data session.add(d) session.commit() return redirect("/departments") return redirect('/logout') return render_template('adddepartment.html', title='Добавление департамента', form=form)
def add_dep(): form = DepartmentForm() if form.validate_on_submit(): db_sess = db_session.create_session() dep = Departments() dep.title = form.title.data dep.chief = form.chief.data dep.members = form.members.data dep.email = form.email.data db_sess.merge(current_user) db_sess.add(dep) db_sess.commit() return redirect('/departments_list') return render_template('departments_form.html', title='Добавление департамента', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): session = db_session.create_session() if str(current_user.id) == str(form.chief.data): department = Departments() department.members = form.members.data department.chief = form.chief.data department.title = form.title.data department.email = form.email.data session.add(department) session.commit() return redirect("/") return render_template('add_department.html', message="нет доступа", form=form, name='Добавление') return render_template('add_department.html', title='Добавление департамента', form=form, text='Наше приложение', name='Добавление')