示例#1
0
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)
示例#2
0
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)