def add_department(): form = AddDepartmentForm() if form.validate_on_submit(): db_sess = db_session.create_session() if db_sess.query(Department).filter( Department.title == form.title.data).first(): return render_template('add_department.html', title='Добавление департамента', form=form, message="Такой департамент уже есть") if db_sess.query(Department).filter( Department.email == form.email.data).first(): return render_template('add_department.html', title='Добавление департамента', form=form, message='Такая почта уже есть') department = Department(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data) db_sess.add(department) db_sess.commit() return redirect('/departments') return render_template('add_department.html', title='Добавление департамента', form=form)
def department_add(): if not current_user.is_admin: abort(403) session = db_session.create_session() form = DepartmentForm() form.building.choices = [(x.id, x.name) for x in session.query(Building).all()] if form.building.choices: form.building.default = form.building.choices[0] if form.validate_on_submit(): department = Department() department.name = form.name.data department.building_id = form.building.data session.add(department) session.commit() return redirect('/departments') return render_template('department_edit.html', title='Добавление отдела', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): db_sess = db_session.create_session() department = Department( title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data ) db_sess.add(department) db_sess.commit() return redirect("/departments") return render_template('department.html', title='Adding a Department', form=form)
def add_depart(): add_form = AddDepartForm() if add_form.validate_on_submit(): db_sess = db_session.create_session() depart = Department(title=add_form.title.data, chief=add_form.chief.data, members=add_form.members.data, email=add_form.email.data) db_sess.add(depart) db_sess.commit() return redirect('/') return render_template('add_depart.html', title='Adding a Department', form=add_form)
def add_dep(): form = AddDepartmentForm() session = db_session.create_session() if form.validate_on_submit(): new_dep = Department(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data) session.add(new_dep) session.commit() return redirect('/departments_list') return render_template('add_dep.html', form=form, title='Добавление работы')
def addDepartment(): form = DepartmentForm() if form.validate_on_submit(): session = dbSession.createSession() department = Department(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data) current_user.departments.append(department) session.merge(current_user) session.commit() return redirect('/departments') return render_template('department.html', title='Department addition', form=form)
def add_dep(): form = DepForm() if form.validate_on_submit(): session = db_session.create_session() # noinspection PyArgumentList dep = Department( title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data ) current_user.department.append(dep) session.merge(current_user) session.commit() return redirect('/departments') return render_template('dep_form.html', title='Adding a department', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): session = create_session() Dep = Department() Dep.author = current_user.id Dep.chef = form.chef.data Dep.title = form.title.data Dep.members = form.members.data Dep.email = form.email.data session.add(Dep) session.commit() return redirect('/departments') return render_template('department.html', title='Добавление департамента', form=form)
def new_dep(): form = DepForm() if form.validate_on_submit(): session = db_session.create_session() dep = Department() dep.title = form.title.data dep.chief = form.chief_id.data dep.members = form.members.data dep.email = form.email.data dep.creator = current_user.id chief = session.query(User).filter( User.id == form.chief_id.data).first() chief.deps.append(dep) session.merge(current_user) session.commit() return redirect('/departments') return render_template('new_dep.html', title='New Department', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): session = db_session.create_session() dep = Department() dep.title = form.title.data dep.chief_id = form.chief_id.data dep.chief = session.query(User).filter( User.id == form.chief_id.data).first() dep.members = form.members.data dep.email = form.email.data session.add(dep) session.commit() return redirect('/departments') return render_template('departments.html', form=form, title="Add a Department")
def add_department(): form = DepartmentForm() if form.validate_on_submit(): db_sess = db_session.create_session() if not db_sess.query(User).filter(User.id == form.chief.data).first(): return render_template("department.html", title="Добавить департамент", form=form, message="Шеф не найден") department = Department(title=form.title.data, chief=form.chief.data, members=form.members.data, email=form.email.data) db_sess.add(department) db_sess.commit() return redirect('/departments') return render_template('department.html', title='Добавить департамент', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): session = db_session.create_session() department = Department() department.email = form.email.data department.chief = form.chief.data department.title = form.title.data department.members = form.members.data current_user.departments.append(department) session.merge(current_user) session.commit() return redirect("/departments") return render_template("department.html", title="Добавление департамента", form=form)
def adding_dep(): form = AddingDepForm() if form.validate_on_submit(): db_session.global_init("db/mars.db") db_sess = db_session.create_session() dep = Department() dep.title = form.title.data dep.chief = form.chief.data dep.members = form.members.data dep.email = form.email.data db_sess.add(dep) db_sess.commit() return redirect("/departments") return render_template('add_dep.html', form=form)
def add_deps(): if not current_user.is_authenticated: return redirect('/') form = AddDepartmentForm() if form.validate_on_submit(): db_sess = db_session.create_session() dep = Department() dep.title = form.title.data dep.chief = form.chief.data dep.email = form.email.data dep.members = form.members.data db_sess.add(dep) db_sess.commit() return redirect("/get_departments") return render_template('add_dep.html', title='Adding of department', form=form)
def add_depart(): form = DepartmentForm() if form.validate_on_submit(): depart = Department() depart.title = form.title.data depart.chief = form.chief.data depart.members = form.members.data depart.email = form.email.data session = db_session.create_session() session.add(depart) session.commit() return redirect('departments') return render_template('add_department.html', title='Добавление департамента', form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): session = db_session.create_session() department = Department() department.title = form.title.data department.chief_id = form.chief.data department.members = form.members.data department.email = form.email.data session.add(department) session.commit() return redirect("/departments") return render_template("adddepartment.html", title="Adding a Department", form=form)
def add_department(): form = DepartmentForm() if form.validate_on_submit(): db_sess = create_session() department = Department() department.title = form.title.data department.chief = form.chief.data department.members = form.members.data department.email = form.email.data current_user.departments.append(department) db_sess.merge(current_user) db_sess.commit() return redirect('/departments') return render_template('add_department.html', title='Adding a Department', form=form)
def add_departament(): form = DepartamentsForm() if form.validate_on_submit(): session = db_session.create_session() departament = Department() departament.title = form.title.data departament.chief = form.chief.data departament.members = form.members.data departament.email = form.email.data current_user.user_department.append(departament) session.merge(current_user) session.commit() return redirect('/departament') return render_template('departament.html', title='Add Departament', form=form)
def add_department_page(): form = AddDepartmentForm() if form.validate_on_submit(): session = database_session.create_session() department = Department() department.title = form.title.data department.chief = form.chief.data department.members = form.members.data department.email = form.email.data session.add(department) session.commit() return redirect('/departments') params = {"title": "Добавить департамент", "form": form} return render_template("add_department.html", **params)
def add_department(): form = DepartmentsForm() if form.validate_on_submit(): session = create_session() department = Department() department.chief = session.query(User).filter(User.email == current_user.email).first().id department.title = form.title.data department.email = form.email.data members = [] for member in form.members.data.split(','): surname, name = member.split() members.append(session.query(User).filter(User.surname == surname, User.name == name).first().id) department.members = ', '.join(map(str, members)) session.add(department) session.commit() return redirect('/departments') return render_template('department.html', title=f"Добавление департамента", form=form)
def main(): db_session.global_init("db/astro.db") capitan = User() capitan.surname = "Scott" capitan.name = "Ridley" capitan.age = 21 capitan.position = "captain" capitan.speciality = "research engineer" capitan.address = "module_1" capitan.email = "*****@*****.**" capitan.set_password('password') capitan.city_from = 'Berlin' colon1 = User() colon1.surname = "Weir" colon1.name = "Andy" colon1.age = 18 colon1.position = "common" colon1.speciality = "worker" colon1.address = "module_1" colon1.email = "*****@*****.**" colon1.city_from = 'New York' colon2 = User() colon2.surname = "Sanders" colon2.name = "Teddy" colon2.age = 19 colon2.position = "common" colon2.speciality = "worker" colon2.address = "module_2" colon2.email = "*****@*****.**" colon2.city_from = 'Paris' category1 = Category() category1.name = '1' category2 = Category() category2.name = '2' category3 = Category() category3.name = '3' job1 = Jobs() job1.team_leader = 1 job1.job = "deployment of residential modules 1 and 2" job1.work_size = 15 job1.collaborators = "2, 3" job1.start_date = datetime.datetime.now() job1.is_finished = False job1.categories.append(category1) job2 = Jobs() job2.team_leader = 2 job2.job = "Exploration of mineral resourses" job2.work_size = 15 job2.collaborators = "4, 3" job2.start_date = datetime.datetime.now() job2.is_finished = False job2.categories.append(category2) job3 = Jobs() job3.team_leader = 3 job3.job = "Development of management system" job3.work_size = 25 job3.collaborators = "5" job3.start_date = datetime.datetime.now() job3.is_finished = True job3.categories.append(category3) department1 = Department() department1.title = 'Department of geological exploration' department1.chief = 2 department1.members = '1, 2, 3' department1.email = '*****@*****.**' department2 = Department() department2.title = 'Department of biological research' department2.chief = 3 department2.members = '2, 3' department2.email = '*****@*****.**' department3 = Department() department3.title = 'Department of construction' department3.chief = 1 department3.members = '1, 3' department3.email = '*****@*****.**' db_sess = db_session.create_session() db_sess.add(capitan) db_sess.add(colon1) db_sess.add(colon2) db_sess.add(job1) db_sess.add(job2) db_sess.add(job3) db_sess.add(department1) db_sess.add(department2) db_sess.add(department3) db_sess.add(category1) db_sess.add(category2) db_sess.add(category3) db_sess.commit()