Beispiel #1
0
def index():

    form = ContactForm()
    request_form = RequestForm()

    if form.validate_on_submit():

        name = form.name.data
        body = form.body.data
        email = form.email.data
        
        send_mail(name, email, body)

        return redirect(url_for('index'))
    
    if request_form.validate_on_submit():

        name = request_form.name.data
        email = request_form.email.data
        phone = request_form.email.data
        option = request_form.select.data

        reply_request(name, email, option)

        return redirect(url_for('index'))

    return render_template('index.html', form=form, request_form=request_form)
Beispiel #2
0
def render_request_done():
    # Если данные не были отправлены
    if request.method != "POST":
        abort(404)

    # Если данные были отправлены
    form = RequestForm()
    if not form.validate_on_submit():
        # отправляем форму назад
        return render_template('request.html', form=form)

    # получаем данные
    client_name = form.clientName.data
    client_phone = form.clientPhone.data
    client_goal = form.clientGoal.data
    client_time = form.clientTime.data

    time = next((t[1] for t in form.clientTime.choices if t[0] == client_time),
                -1)

    goal = Goal.query.filter(Goal.code == client_goal).scalar()
    request_t = Request(name=client_name,
                        phone=client_phone,
                        goal=goal.goal,
                        time=time)
    db.session.add(request_t)
    db.session.commit()

    # переходим на request_done
    return render_template('request_done.html',
                           clientName=client_name,
                           clientPhone=client_phone,
                           clientGoal=request_t.goal,
                           clientTime=request_t.time)
Beispiel #3
0
def recipe():
    form = RequestForm()
    if form.validate_on_submit():
        recipe = sands_client.ask_for_recipe(form.rq_text.data)
        #request.values['rq_text']
        return str('show_recipe.html', recipe=recipe)

    return render_template('home.html', form=form)
Beispiel #4
0
def request_page():
    form_request = RequestForm()
    if form_request.validate_on_submit():
        request_goal = int(form_request.request_goal.data)
        request_client_name = form_request.request_client_name.data
        request_client_tel = form_request.request_client_tel.data
        request_new = Request(name=request_client_name, phone=request_client_tel, goal_id=request_goal)
        db.session.add(request_new)
        db.session.commit()
        return redirect(url_for('search_result_page'))
    return render_template('pick.html', form_request=form_request)
Beispiel #5
0
def request_book(id):
    session = Session()
    trans = session.query(Transaction).filter(Transaction.book == id).first()
    if (trans.address_to):
        return redirect(url_for("listings"))
    form = RequestForm()
    if form.validate_on_submit():

        address = form.streetNameNum.data + " " + form.city.data + ", " + form.state.data + " " + form.zipcode.data
        trans.address_to = address
        trans.buyer = current_user.user_id
        addressf = trans.address_from
        session.commit()
        return redirect(url_for("index"))
    # Very important, make sure to initialize the field of the OWNER's
    # associated user's ID after the post request. To be handled later
    return render_template('request_book.html', form=form)
Beispiel #6
0
def RequestSwapp():
    email1 = globals()['cur_user']
    if email1 == '':
        flash("Login as user to view schedule.")
        return redirect(url_for('login'))
    else:
        form = RequestForm()
        if form.validate_on_submit():
            email, examid, date, time, slot = form.email.data, form.examid.data, form.date.data, form.time.data, form.slot.data
            if email != email1:
                print(email, examid, date, time, slot)
                res = RequestSwap(email1, email, examid, date, time, slot)
                flash(res)
                return redirect(url_for("RequestSwapp"))
            elif email == email1:
                flash("you can't enter your own email!")
                return redirect(url_for("RequestSwapp"))
        return render_template('request_swap.html', form=form, ddtext='Request Swap')
Beispiel #7
0
def make_request():
    form = RequestForm()
    if request.method == 'GET':
        return render_template('request.html', form=form)
    if request.method == 'POST':
        form = RequestForm()
        if form.validate_on_submit():
            tr = TeacherRequest(goal=form.goals.data,
                                availability=form.availability.data,
                                clientName=form.clientName.data,
                                clientPhone=form.clientPhone.data)
            db.session.add(tr)
            db.session.commit()
            return render_template('request_done.html',
                                   goal=tr.goal,
                                   availability=tr.availability,
                                   clientName=tr.clientName,
                                   clientPhone=tr.clientPhone)
        return render_template('request.html', form=form)
Beispiel #8
0
def request():
  rooms = Rooms.query.all()
  rooms_list = [(-1, 'No Preference')]
  for room in rooms:
    rooms_list.append((room.room_id, room.name))

  form = RequestForm()
  form.room.choices = rooms_list

  if form.validate_on_submit():
    username = current_user.get_id()

    Requests.insert(requestee=username,
                    room= dict(form.room.choices)[form.room.data],
                    day=dict(form.day.choices)[form.day.data],
                    time=dict(form.time.choices)[form.time.data])

    return redirect(url_for("home"))

  return render_template("request.html", form=form)
def render_request():
    form = RequestForm()
    goals = db.session.query(Goal).all()
    choices = [(str(goal.id), goal.description) for goal in goals]
    form.goal.choices = choices
    form.goal.data = choices[0][0]
    if request.method == "POST":
        if form.validate_on_submit():
            goal_id = form.goal.data
            goal = db.session.query(Goal).get_or_404(goal_id)
            time = form.time.data
            name = form.name.data
            phone = form.phone.data
            lesson_request = Request(goal=goal,
                                     goal_id=goal_id,
                                     time=time,
                                     name=name,
                                     phone=phone)
            db.session.add(lesson_request)
            db.session.commit()
            return render_template('request_done.html', goal=goal, time=time, name=name, phone=phone)
    return render_template('request.html', form=form)
Beispiel #10
0
def request_done_view():
    form = RequestForm()
    if form.validate_on_submit():
        goal = form.goal.data
        time = form.time.data
        name = form.name.data
        phone = form.phone.data
        # Create and update request.json
        db_manager('request', [{
            'name': name,
            'phone': phone,
            'goal': goal,
            'time': time
        }])
        return render_template('request_done.html',
                               goals=goals,
                               goal=goal,
                               time=time,
                               name=name,
                               phone=phone)
    else:
        return redirect(url_for('request_view', form=form))
Beispiel #11
0
def render_request():
    form = RequestForm()
    goals = Goal.query.order_by(Goal.id)
    form.goal_id.choices = [(str(goal.id), goal.value) for goal in goals]
    goals = Goal.query.order_by(Goal.id).all()
    if request.method == 'POST' and form.validate_on_submit():
        lesson_request = RequestLesson()
        form.populate_obj(lesson_request)
        db.session.add(lesson_request)
        db.session.commit()
        client_name = form.client_name.data
        client_phone = form.client_phone.data
        goal = list(filter(lambda x: x.id == int(form.goal_id.data),
                           goals))[0].value
        free_time = form.free_time.data
        free_time = free_time + ' часа в неделю' if free_time == '1-2' else free_time + ' часов в неделю'
        return render_template('request_done.html',
                               goal=goal,
                               free_time=free_time,
                               name=client_name,
                               phone=client_phone)
    return render_template('request.html', form=form)
Beispiel #12
0
def show_request():
    form = RequestForm()

    if form.validate_on_submit():
        goal = form.goal.data
        time = form.time.data
        name = form.name.data
        phone = form.phone.data

        new_request = Request(time=time,
                              client_id=check_client(name, phone),
                              goal_id=goal)
        goal_name = form.goal.choices[int(goal) - 1][1]
        db.session.add(new_request)
        db.session.commit()
        return render_template("request_done.html",
                               goal=goal_name,
                               time=have_time[time],
                               name=name,
                               phone=phone)

    return render_template("request.html", form=form)
Beispiel #13
0
def render_request_done():
    if request.method == "GET":
        return redirect("/request/")
    form = RequestForm()
    if form.validate_on_submit():
        goal_abb = form.goal.data
        goal = db.session.query(Goal).filter(Goal.name_abb == goal_abb).first()
        time = form.time.data
        name = form.clientName.data
        phone = form.clientPhone.data
        s.request_successful(name, phone, goal, time)

        return render_template("request_done.html",
                               name=name,
                               phone=phone,
                               time=time_week[time],
                               goal=goal.name,
                               title="Запрос отправлен!")

    return render_template("request.html",
                           form=form,
                           title="Подбор преподавателя")
Beispiel #14
0
def make_request(stuff_id=None):
    form = RequestForm()
    message = None
    return_url = request.form['return_url']
    if form.validate_on_submit():
        message = form.message.data
        stuff_id = form.stuff_id.data
        duration = int(form.duration.data)
        unit = int(form.unit.data)

        address = Address.query.filter(Address.user_id == current_user.id).first()

        if address:
            if stuff_id is None or not (stuff_id > ''):
                flash(u'İstek gönderilemedi.')
                return redirect(return_url)
            stuff = Stuff.query.filter(Stuff.id == stuff_id).first()

            if stuff.is_wanted == True:
                user = stuff.owner
                from_user = current_user
            else:
                user = current_user
                from_user = stuff.owner

            new_request = Request(
                stuff_id=stuff_id,
                user_id=user.id,
                from_user_id=from_user.id,
                duration=(duration * unit)
            )

            db.session.add(new_request)
            new_conversation = Conversation(
                title='%s' % stuff.title,
                users=[current_user, stuff.owner],
                request=new_request
            )

            db.session.add(new_conversation)

            new_message = Message(
                from_user=current_user,
                to_user=stuff.owner,
                conversation=new_conversation,
                txt=message
            )

            db.session.add(new_message)

            db.session.commit()

            msg_body = render_template('email/request.txt', to_user=user, from_user=from_user,
                                       stuff=stuff, conversation_url=new_conversation.url)

            html_msg = render_template('email/request.html', to_user=user, from_user=from_user,
                                       stuff=stuff, conversation_url=new_conversation.url)
            if stuff.is_wanted:
                msg_subject = u"%s sana %s ödünç vermek istiyor" % (from_user.name, stuff.title)

            else:
                msg_subject = u"%s için bir talip var!" % stuff.title

            msg = MailMessage(
                body=msg_body,
                html=html_msg,
                subject=msg_subject,
                sender=(u"Eşya Kütüphanesi", "*****@*****.**"),
                recipients=[stuff.owner.email]
            )

            mail.send(msg)

            return redirect(url_for('my_messages'))

        else:
            flash(u'Ödünç istemek için adres girmelisin.')
            return redirect(url_for('new_address'))
    else:
        flash(u'İstek gönderilemedi. Kaç gün için ödünç istediğini girmelisin.')
        return redirect(return_url)