def forgot_password_client(): if session.get('id', '') != '': if not Business.check_confirmed(session.get('id', '')): session['id'] = '' return redirect(url_for('business.business_card', business_id=session.get('id', ''))) session['id_client'] = '' form = ForgotPasswordForm() if form.validate_on_submit(): if Process.query.filter_by(number=form.number.data).first(): client_password = Client.random_password(10) rows = Process.query.filter_by(id=Process.get_id(form.number.data)).update( {'password': generate_password_hash(client_password)}) db.session.commit() Business.send_password_client(Client.get_email(Process.get_client_id(Process.get_id(form.number.data))), form.number.data, client_password) return redirect( "/business/feedback/Мы отправили вам новый пароль на почту! Если вы не получили письмо, \ проверьте, что вы написали номер правильно!") else: form.number.errors = ('Неправильный номер', '') return render_template('forgot_password_client.html', title='Забыли пароль?', form=form)
def build_process(id): form = Add_process() if form.validate_on_submit(): info = Process(engineer_id=form.engineer_id.data, time=form.time.data, process_one=form.process_one.data, process_two=form.process_two.data, ticket_id=id) info.save() return redirect(url_for('main.index')) return render_template('main/build_process.html', form=form)
def get_st(process_number): if session.get('id', '') != '': if Business.query.filter_by(id=session.get('id', '')).first() is None: session['id'] = '' return redirect('/business/profile_business') print(process_number) try: current_stage = Process.get_stages(Process.get_id(process_number)) except: return ("Заказ с данным номером не существует") current_stage_name = Process.get_stage_name(current_stage) return ("Заказ " + "находится в стадии \"" + str(current_stage_name) + "\"")
def mutate(self, info, **kwargs): user = info.context.user process = Process.filter_permissions( Process.objects, Process.permission_filters(user))\ .get(pk=kwargs["id"]) if "input" in kwargs: process.input = kwargs["input"] if "result" in kwargs: process.result = kwargs["result"] if "user" in kwargs: user = User.objects.get(pk=kwargs["user"]) process.user = user process.save() return SetProcessMutation(process=process)
def query_add_product_version(product_id, **product_attributes): '''adds a product with persisting product_id''' product = Process(product_id = product_id, **product_attributes) db.session.add(product) db.session.commit() db.session.close() return
def process_init_func(row): c = Category.query.filter_by(name=row['category']).first() p = Process(category=c, display_as=row['display_as'], firstname=row['firstname'], lastname=row['lastname'], adresse=row['adresse'], telephone=row['telephone'], email=row['email']) return p
def create_process(): if session.get('id', '') == '': return redirect('/business/') elif not Business.check_confirmed(session.get('id', '')): return redirect('/business/unconfirmed') b_id = session['id'] form = CreateProcessForm() s_form = SelectFieldTypeForm() h = HelpForm() s_form.select_type.choices = [(p.id, p.type) for p in PossibleProcess.query.filter_by(business_id=b_id).all()] d_form = DateForm() if form.validate_on_submit() and d_form.validate_on_submit(): if Client.email_is_free(form.client_email.data): client = Client(form.client_email.data) cl_id = client.save() else: cl_id = Client.get_id(form.client_email.data) client_password = Client.random_password(10) number = Process.random_number() process = Process(s_form.select_type.data, form.description.data, b_id, cl_id, number, form.price.data, client_password, d_form.dt.data, 0) pr_id = process.save() id_stage = Stage.get_not_started(s_form.select_type.data) process = Process.query.filter_by(id=pr_id).first() process.current_stage = id_stage chat = Chat(pr_id, b_id) chat.save() process.save() Process.send_number(form.client_email.data, Business.get_name(b_id), number, client_password) # string = "Услуга была создана под номером: " + number return redirect(url_for('business.created_process', process_id=pr_id)) elif form.validate_on_submit() and not d_form.validate_on_submit(): d_form.dt.errors = ("Выберите дату", "") h.desc.choices = [(p.desc, p.desc) for p in PossibleProcess.query.filter_by(business_id=b_id).all()] h.price.choices = [(p.price, p.price) for p in PossibleProcess.query.filter_by(business_id=b_id).all()] h.pic.choices = [(p.picture, p.picture) for p in PossibleProcess.query.filter_by(business_id=b_id).all()] return render_template('create_process.html', form=form, h=h, s_form=s_form, d_form=d_form, title='Создание заказа')
def new_process(user_id, **user_inputs): query = db.engine.execute('''select max(process_id) from Process''') max_id = next(query)[0] or 0 process_id = max_id + 1 created_by = user_id owner = user_id process = Process(process_id=process_id, created_by=created_by, owner=owner, **user_inputs) db.session.add(process) db.session.commit() return process_id
def pygempick(): form = ZipForm() if form.validate_on_submit(): filename = archives.save(request.files['archive']) url = archives.url(filename) Zip = Process(author=current_user, archive_filename=filename, archive_url=url, img_state=form.choice1.data) db.session.add(Zip) db.session.commit() if request.method == "POST": return redirect(url_for('main.double_picker')) return render_template('pygempick.html', title='pyGemPick 1.1.3', form=form )
def client_process_list(client_id): if session.get('id', '') != '': if Business.query.filter_by(id=session.get('id', '')).first() is None: session['id'] = '' return redirect(url_for('business.business_card', business_id=session.get('id', ''))) elif session.get('id_client', '') == '': return redirect('/business_client/login') elif int(client_id) != int(session.get('id_client', '')): return redirect('/business_client/login') process_list = Client.get_processes(client_id) form = FindForm() if form.validate_on_submit(): process_list = Process.find_for_client(form.words.data, client_id) if process_list[0] == 0: form.words.errors = ("Ничего не найдено", "") return render_template('client_process_list.html', title='Ваши заказы', form=form, processes=process_list[::-1], client_id=client_id, PossibleProcess=PossibleProcess, Business=Business, Process=Process)
def created_process_list(): if session.get('id', '') == '': return redirect('/business/') elif not Business.check_confirmed(session.get('id', '')): return redirect('/business/unconfirmed') form = FindForm() business_id = session['id'] process_list = Business.get_processes(business_id) if form.validate_on_submit(): process_list = Process.find(form.words.data, business_id) if process_list[0] == 0: form.words.errors = ("Ничего не найдено", "") ''' if Process.is_real_number(form.words.data) is None: form.words.errors = ("Такого номера не существует", '') elif Process.get_business(Process.get_id(form.words.data)) != session.get('id', ''): form.words.errors = ("Такого номера не существует", '') else: return redirect(url_for('business.created_process', process_id=Process.get_id(form.words.data))) ''' return render_template('created_process_list.html', title='Список заказов', form=form, processes=process_list[::-1], PossibleProcess=PossibleProcess, Process=Process)
def login(): if session.get('id', '') != '': if not Business.check_confirmed(session.get('id', '')): session['id'] = '' return redirect(url_for('business.business_card', business_id=session.get('id', ''))) session['id_client'] = '' find_form = FindForm() business_card_list = BusinessCard.sort_by_rating()[::-1] if find_form.submit2.data and find_form.validate_on_submit(): business_card_list = BusinessCard.find(find_form.words.data) if business_card_list[0] == 0: find_form.words.errors = ("Ничего не найдено", "") form = OrderForm() if form.submit.data and form.validate_on_submit(): number = form.number.data password = form.password.data if Process.query.all() is None: form.password.errors = ('Введён неверный номер заказа или пароль', '') elif Process.query.filter_by(number=number).first() is None: form.password.errors = ('Введён неверный номер заказа или пароль', '') elif Process.is_real_number(number) is False: form.password.errors = ('Введён неверный номер заказа или пароль', '') else: if Process.check_p(Process.get_id(number), password): session['id_client'] = Process.get_client_id(Process.get_id(number)) return redirect(url_for('business_client.status', process_id=Process.get_id(number))) else: form.password.errors = ('Введён неверный номер заказа или пароль', '') return render_template('business_client_index.html', title='Найти заказ', msg='Введите данные заказа', form=form, find_form=find_form, business_card_list=business_card_list, BusinessCard=BusinessCard, )
def created_process(process_id): if session.get('id', '') == '': return redirect('/business/') elif not Process.is_real(process_id): return redirect('/business/created_process_list') elif Process.get_business(process_id) != session.get('id', ''): return redirect('/business/created_process_list') elif not Business.check_confirmed(session.get('id', '')): return redirect('/business/unconfirmed') form = ChangeForm() s_form = SelectFieldStageForm() d_form = DateForm() if form.validate_on_submit() and d_form.validate_on_submit(): if int(Process.get_stages(process_id)) != int(s_form.select_stage.data): Business.send_stages(Client.get_email(Process.get_client_id(process_id)), s_form.select_stage.data, Business.get_name(session.get('id', '')), Process.get_number(process_id), PossibleProcess.get_type(Process.get_type_id(process_id))) rows = Process.query.filter_by(id=process_id).update({'desc': form.desc.data}) rows = Process.query.filter_by(id=process_id).update({'current_stage': s_form.select_stage.data}) rows = Process.query.filter_by(id=process_id).update({'data': d_form.dt.data}) rows = Process.query.filter_by(id=process_id).update({'percent': round(form.percent.data)}) rows = Process.query.filter_by(id=process_id).update({'price': form.price.data}) db.session.commit() return redirect('/business/created_process_list') number = Process.get_number(process_id) client = Client.get_email(Process.get_client_id(process_id)) type = PossibleProcess.get_type(Process.get_type_id(process_id)) form.desc.data = Process.get_desc(process_id) percent = Process.get_percent(process_id) form.percent.data = percent form.price.data = Process.get_price(process_id) s_form.select_stage.choices = [(s.id, s.type) for s in Stage.sort_by_id_for_business(Process.get_type_id(process_id))] s_form.select_stage.default = Process.get_stages(process_id) s_form.process() d_form.dt.data = Process.get_data(process_id) desc_type = PossibleProcess.get_desc(Process.get_type_id(process_id)) star = Process.get_star(process_id) chat = Chat.get_by_proc(process_id).id picture = PossibleProcess.get_picture(Process.get_type_id(process_id)) is_picture = (PossibleProcess.get_picture(Process.get_type_id(process_id)) != "-1") return render_template('created_process.html', title='Созданная услуга', desc_type=desc_type, percent=percent, d_form=d_form, id=process_id, form=form, s_form=s_form, number=number, type=type, client=client, Process=Process, chat=chat, rating=star, picture=picture, is_picture=is_picture)
def get_queryset(self): user = self.request.user return Process.filter_permissions( super().get_queryset(), Process.permission_filters(user))
def resolve_process(self, info, id): user = info.context.user return ProcessModel.filter_permissions( ProcessModel.objects, ProcessModel.permission_filters(user)).get(pk=id)
def status(process_id): if session.get('id', '') != '': return redirect(url_for('business.business_card', business_id=session.get('id', ''))) elif session.get('id_client', '') == '': return redirect('/business_client/login') elif Process.get_client_id(process_id) != session.get('id_client', ''): return redirect('/business_client/login') form_stage = StatusEmailForm() form_check = CheckBoxForm() form_star = RatingForm() starsave = "" stagesave = "" if form_stage.submit1.data: if Process.get_send(process_id): rows = Process.query.filter_by(id=process_id).update({'send_all_stages': 0}) db.session.commit() else: rows = Process.query.filter_by(id=process_id).update({'send_all_stages': 1}) db.session.commit() stagesave = "Изменения были сохранены" if form_star.submit2.data: rows = Process.query.filter_by(id=process_id).update({"star": form_star.star.data}) db.session.commit() starsave = "Спасибо за оценку" rating = Process.get_star(process_id) form_check.checkbox.data = False send_stages = Process.get_send(process_id) number = Process.get_number(process_id) client_email = Client.get_email(Process.get_client_id(process_id)) business_name = Business.get_name(Process.get_business(process_id)) data = Process.get_data(process_id).strftime("%B %d, %Y") type = PossibleProcess.get_type(Process.get_type_id(process_id)) desc_type = PossibleProcess.get_desc(Process.get_type_id(process_id)) desc = Process.get_desc(process_id) percent = Process.get_percent(process_id) current_stage = Process.get_stages(process_id) current_stage_name = Process.get_stage_name(current_stage) client_id = Process.get_client_id(process_id) price = Process.get_price(process_id) business_id = Process.get_business(process_id) business_card_exists = BusinessCard.is_real(Process.get_business(process_id)) # получение всех стадий процесса stages = Stage.sort_by_id_for_business(Process.get_type_id(process_id)) chat = Chat.get_by_proc(process_id).id is_picture = (PossibleProcess.get_picture(Process.get_type_id(process_id)) != "-1") picture = PossibleProcess.get_picture(Process.get_type_id(process_id)) return render_template('Status.html', title='Статус заказа', number=number, client_email=client_email, business_name=business_name, type=type, desc=desc, desc_type=desc_type, percent=percent, data=data, current_stage=current_stage, current_stage_name=current_stage_name, stages=stages, price=price, business_id=business_id, form_stage=form_stage, form_check=form_check, send_stages=send_stages, form_star=form_star, rating=rating, starsave=starsave, stagesave=stagesave, business_card_exists=business_card_exists, client_id=client_id, chat=chat, is_picture=is_picture, picture=picture, Widget=Widget)
def mock(): db.drop_all() db.create_all() # Первый бизнес business = Business(name="Туристическое агенство Маленький Принц", password="******", email="*****@*****.**", confirmed=True) Business.save(business) # возможная услуга для первого бизнеса process = PossibleProcess("Помощь выбора путёвки", "Подбор идеального места для отдыха", 1, "10000") pr_id = process.save() stage_not_started = Stage("Не начат", 1) stage_not_started.save() stage_finished = Stage("Закончен", 1) stage_finished.save() # стадии для этой услуги stage = Stage("Анкетирование", 1) stage.save() stage = Stage("Диалог с клиентом", 1) stage.save() stage = Stage("Покупка путёвки", 1) stage.save() Stage.fix_not_finished(1) # созданный заказ для первой услуги client = Client('*****@*****.**') client.save() process = Process(1, 'Подбор идеального места для отдыха', 1, 1, "AAAAAA-AAAAAA", "10000", "qweqwe") process.save() # вторая возможная услуга для первого бизнеса process = PossibleProcess("Собственная экскурсия", "Создание экскурсии спецально по персональным требованиям клиента", 1, "20000") pr_id = process.save() # стадии для этой услуги stage_not_started = Stage("Не начат", 2) stage_not_started.save() stage_finished = Stage("Закончен", 2) stage_finished.save() stage = Stage("Диалог с клиентом", 2) stage.save() stage = Stage("Поиск экукурсоводов", 2) stage.save() stage = Stage("Создание программы экскурсии", 2) stage.save() Stage.fix_not_finished(2) pic = Pictures(1) id_picture = Pictures.save(pic) picture = "2.jpeg" rows = Pictures.query.filter_by(id=id_picture).update({'picture': picture}) rows = PossibleProcess.query.filter_by(id=2).update({'picture': picture}) db.session.commit() # созданный заказ для второй услуги client = Client('*****@*****.**') client.save() process = Process(2, 'Предпочитает картинные галереи', 1, 2, "BBBBBB-BBBBBB", "20000", "asdasd") process.save() rows = Process.query.filter_by(id=2).update({'current_stage': 9}) rows = Process.query.filter_by(id=2).update({'percent': round(45)}) db.session.commit() # создать страницу первого бизнеса card = BusinessCard("Туристическое агенство Маленький Принц", "Поможем Вам найти место для идеального препровождения", "Телефон: +7(924)732-90-65", "метро Добрынинская", 1) BusinessCard.save(card) pic = Pictures(1) id_picture = Pictures.save(pic) picture = "1.jpg" rows = Pictures.query.filter_by(id=id_picture).update({'picture': picture}) rows = BusinessCard.query.filter_by(business_id=1).update({'picture': picture}) db.session.commit() # создать комментарии к бизнесу comments = Comments( "Очень доволен фирмой! Крайне приятный персонал: были вежливы и очень быстро мне подобрали место для отдыха", 1, 1, "Александр", 5) Comments.save(comments) # еще один comments = Comments("Всё, конечно, хорошо, но с местом немного прогадали. Но никаких особых претензий нет", 2, 1, "Анастасия", 1) Comments.save(comments) rating = BusinessCard.get_new_rating(1) rows = BusinessCard.query.filter_by(business_id=1).update( {'rating': rating}) db.session.commit() # Второй бизнес business = Business(name="Общество историков 1984", password="******", email="*****@*****.**", confirmed=True) Business.save(business) # возможная услуга для второго бизнеса process = PossibleProcess("Подготовка к ЕГЭ", "Курсы по подготовке к ЕГЭ по истории", 2, "30000") pr_id = process.save() stage_not_started = Stage("Не начат", 3) stage_not_started.save() stage_finished = Stage("Закончен", 3) stage_finished.save() # стадии для этой услуги stage = Stage("Первый триместр", 3) stage.save() stage = Stage("Второй триместр", 3) stage.save() stage = Stage("Третий триместр", 3) stage.save() Stage.fix_not_finished(3) # созданный заказ для первой услуги client = Client('*****@*****.**') client.save() process = Process(3, 'Курсы по подготовки к ЕГЭ по истории', 2, 3, "CCCCCC-CCCCCC", "30000", "zxczxc") process.save() # вторая возможная услуга для второго бизнеса process = PossibleProcess("Консультирование", "Помощь в написании курсовой/докторской и прочих работ", 2, "40000") pr_id = process.save() stage_not_started = Stage("Не начат", 4) stage_not_started.save() stage_finished = Stage("Закончен", 4) stage_finished.save() # стадии для этой услуги stage = Stage("Первая встреча", 4) stage.save() stage = Stage("Поиск информации", 4) stage.save() stage = Stage("Консультирование", 4) stage.save() Stage.fix_not_finished(4) # созданный заказ для второй услуги process = Process(4, 'Помощь в написании курсовой/докторской и прочих работ', 2, 1, "DDDDDD-DDDDDD", "40000", "werwer") process.save() business = Business(name="Как у бабушки", password="******", email="*****@*****.**", confirmed=True) Business.save(business) w = Widget(-1, 'game', 'http://0.0.0.0:8080/business/widget', 'game', 1, 3) w.save() # возможная услуга для 3 бизнеса process = PossibleProcess("Домашняя пицца", "Сделанная дома пицца по рецепту моей бабушки", 3, "50000") pr_id = process.save() stage_not_started = Stage("Не начат", 5) stage_not_started.save() stage_finished = Stage("Закончен", 5) stage_finished.save() # стадии для этой услуги stage = Stage("Приготовление пиццы", 5) stage.save() stage = Stage("Упаковка пиццы", 5) stage.save() stage = Stage("Доставка", 5) stage.save() Stage.fix_not_finished(5) process = Process(5, 'Сделанная дома пицца', 3, 1, "EEEEEE-EEEEEE", "30000", "sdfsdf") process.save() # вторая возможная услуга для второго бизнеса process = PossibleProcess("Домашняя шаурма", "Сделанная дома шаурма по-моему рецепту", 3, "40000") pr_id = process.save() stage_not_started = Stage("Не начат", 6) stage_not_started.save() stage_finished = Stage("Закончен", 6) stage_finished.save() # стадии для этой услуги stage = Stage("Приготовление шаурмы", 6) stage.save() stage = Stage("Упаковка", 6) stage.save() stage = Stage("Доставка", 6) stage.save() Stage.fix_not_finished(6) process = Process(6, 'Сделанная дома шаурма', 3, 1, "FFFFFF-FFFFFF", "40000", "xcvxcv") process.save() process = Process(2, 'Детская экскурсия', 1, 2, "GGGGGG-GGGGGG", "25000", "ertert") process.save() rows = Process.query.filter_by(id=7).update({'current_stage': 7}) rows = Process.query.filter_by(id=7).update({'percent': round(100)}) db.session.commit() print('Success')