Esempio n. 1
0
def edit_appointment(appointment_id):
    form = AppointmentForm()
    print(form.validate_on_submit())
    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.

        current_appointment = Appointment.query.filter_by(
            appointment_id=appointment_id).first_or_404()
        current_appointment.title = form.appointment_title.data
        current_appointment.appointment_status = form.appointment_status_completed.data
        current_appointment.appointment_date = form.appointment_date.data
        current_appointment.start_time = form.start_time.data
        current_appointment.duration = form.duration.data
        current_appointment.location = form.location.data
        current_appointment.customer_name = form.customer_name.data
        current_appointment.notes = form.notes.data

        db.session.add(current_appointment)
        db.session.commit()

        return redirect(url_for('main.appointmentlist'))

    current_appointment = Appointment.query.filter_by(
        appointment_id=appointment_id).first_or_404()

    form.appointment_title.data = current_appointment.appointment_title
    form.appointment_status_completed.data = current_appointment.appointment_status

    return render_template("main/appointmentlist_edit_view.html",
                           form=form,
                           appointment_id=appointment_id)
Esempio n. 2
0
def appointments():

    form = AppointmentForm()
    searchform = AppointmentSearchForm()

    if searchform.validate_on_submit():
        search = searchform.search.data
        return redirect(url_for('main.search_results'))

    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.
        new_appt = Appointment()
        new_appt.appt_title = form.appt_title.data
        new_appt.appt_date = form.appt_date.data
        new_appt.appt_start_time = form.appt_start_time.data
        new_appt.appt_duration = form.appt_duration.data
        new_appt.appt_location = form.appt_location.data
        new_appt.appt_customer_name = form.appt_customer_name.data
        new_appt.appt_notes = form.appt_notes.data
        new_appt.appt_status = form.appt_status_completed.data
        print(new_appt.appt_title)

        db.session.add(new_appt)
        db.session.commit()
        flash('your appointment has been created')
        # Redirect to this handler - but without form submitted - gets a clear form.
        return redirect(url_for('main.appointments'))

    appointments = db.session.query(Appointment).all()

    return render_template("main/appointment.html",
                           appointments=appointments,
                           searchform=searchform,
                           form=form)
Esempio n. 3
0
def todolist():
    #form = TaskForm()
    form = AppointmentForm()

    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.
        #new_task = Task()
        new_appointment = Appointment()
        #new_task.task_desc =  form.task_desc.data
        new_appointment.appointment_date = form.appointment_date.data
        #new_task.task_status = form.task_status_completed.data
        new_appointment.appointment_dur = form.appointment_dur.data
        new_appointment.appointment_loc = form.appointment_loc.data
        new_appointment.appointment_client = form.appointment_client.data
        new_appointment.appointment_desc = form.appointment_desc.data

        #db.session.add(new_task)
        db.session.add(new_appointment)
        db.session.commit()

        # Redirect to this handler - but without form submitted - gets a clear form.
        return redirect(url_for('main.todolist'))

    #todo_list = db.session.query(Task).all()
    todo_list = db.session.query(Appointment).all()

    return render_template("main/todolist.html",
                           todo_list=todo_list,
                           form=form)
Esempio n. 4
0
def Update_Schedule(appointment_id):
    form = AppointmentForm()
    if form.validate_on_submit():
        current_appointment = Appointment.query.filter_by(appointment_id=appointment_id).first_or_404()
        current_appointment.customer_name = form.customer_name.data
        current_appointment.appointment_title = form.appointment_title.data
        current_appointment.appointment_date = form.appointment_date.data
        current_appointment.appointment_time = form.start_time.data
        current_appointment.appointment_duration = form.duration_of_appointment.data
        current_appointment.appointment_location = form.location.data
        current_appointment.appointment_status = form.appointment_status_completed.data
        current_appointment.notes = form.notes.data

        db.session.add(current_appointment)
        db.session.commit()

        return redirect(url_for('main.view_schedule'))

    current_appointment = Appointment.query.filter_by(appointment_id=appointment_id).first_or_404()

    form.customer_name.data = current_appointment.customer_name
    form.appointment_title.data = current_appointment.appointment_title
    form.appointment_date.data = current_appointment.appointment_date
    form.start_time.data = current_appointment.appointment_time
    form.duration_of_appointment.data = current_appointment.appointment_duration
    form.location.data = current_appointment.appointment_location
    form.appointment_status_completed.data = current_appointment.appointment_status
    form.notes.data = current_appointment.notes

    return render_template('main/schedule_appointment.html', title='Schedule an appointment', form=form)
Esempio n. 5
0
def appointments():
    form = AppointmentForm()

    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.
        new_apointment = List()
        new_apointment.appointment_title = form.appointment_title.data
        new_apointment.appointment_date = form.appointment_date.data
        new_apointment.starting_time = form.starting_time.data
        new_apointment.duration = form.starting_time.data
        new_apointment.appointment_location = form.appointment_location.data
        new_apointment.customer_name = form.customer_name.data
        new_apointment.notes = form.notes.data

        db.session.add(new_apointment)
        db.session.commit()

        # Redirect to this handler - but without form submitted - gets a clear form.
        return redirect(url_for('main.appointment_list'))

    list_appointments = db.session.query(List).all()

    return render_template("main/appointment_list.html",
                           list_appointments=list_appointments,
                           form=form)
Esempio n. 6
0
def appointmentlist():
    form = AppointmentForm()

    if form.validate_on_submit():

        new_appointment = Appointment()
        new_appointment.appointment_title = form.appointment_title.data
        new_appointment.appointment_status = form.appointment_status_completed.data
        new_appointment.appointment_date = form.appointment_date.data
        new_appointment.start_time = form.start_time.data
        new_appointment.duration = form.duration.data
        new_appointment.location = form.location.data
        new_appointment.customer_name = form.customer_name.data
        new_appointment.notes = form.notes.data

        db.session.add(new_appointment)
        db.session.commit()

        return redirect(url_for('main.appointmentlist'))

    appointment_list = db.session.query(Appointment).all()

    return render_template("main/appointmentlist.html",
                           appointment_list=appointment_list,
                           form=form)
Esempio n. 7
0
def edit_appointment(appt_id):

    form = AppointmentForm()
    print(form.validate_on_submit())
    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.

        current_appt = Appointment.query.filter_by(
            appt_id=appt_id).first_or_404()

        current_appt.appt_title = form.appt_title.data
        current_appt.appt_date = form.appt_date.data
        current_appt.appt_start_time = form.appt_start_time.data
        current_appt.appt_duration = form.appt_duration.data
        current_appt.appt_location = form.appt_location.data
        current_appt.appt_customer_name = form.appt_customer_name.data
        current_appt.appt_notes = form.appt_notes.data
        current_appt.appt_status = form.appt_status_completed.data

        #current_appt.appt_desc =  form.appt_desc.data
        #current_appt.appt_status = form.appt_status_completed.data

        db.session.add(current_appt)
        db.session.commit()
        # After editing, redirect to the view page.
        return redirect(url_for('main.appointments'))

    # get task for the database.
    current_appt = Appointment.query.filter_by(appt_id=appt_id).first_or_404()

    # update the form model in order to populate the html form.
    form.appt_title.data = current_appt.appt_title
    form.appt_date.data = current_appt.appt_date
    form.appt_start_time.data = current_appt.appt_start_time
    form.appt_duration.data = current_appt.appt_duration
    form.appt_location.data = current_appt.appt_location
    form.appt_customer_name.data = current_appt.appt_customer_name
    form.appt_notes.data = current_appt.appt_notes
    form.appt_status_completed.data = current_appt.appt_status

    return render_template("main/appointments_edit_view.html",
                           form=form,
                           appt_id=appt_id)
Esempio n. 8
0
def add_appointment():
    form = AppointmentForm()
    if form.validate_on_submit():
        new_appointment = Appointment()
        new_appointment.title = form.title.data
        new_appointment.date_time = datetime.datetime.combine(
            form.start_date.data, form.start_time.data)
        new_appointment.duration = form.duration.data
        new_appointment.location = form.location.data
        new_appointment.customer_name = form.customer_name.data
        new_appointment.notes = form.notes.data
        new_appointment.status = form.status.data

        db.session.add(new_appointment)
        db.session.commit()
        flash("Added the appointment")
        return redirect(url_for('main.add_appointment'))
    return render_template("main/add_appointment.html", form=form)
Esempio n. 9
0
def Schedule():
    form = AppointmentForm()
    if form.validate_on_submit():
        new_appointment = Appointment()

        new_appointment.customer_name = form.customer_name.data
        new_appointment.appointment_title = form.appointment_title.data
        new_appointment.appointment_date = form.appointment_date.data
        new_appointment.appointment_time = form.start_time.data
        new_appointment.appointment_duration = form.duration_of_appointment.data
        new_appointment.appointment_location = form.location.data
        new_appointment.notes = form.notes.data
        new_appointment.appointment_status = form.appointment_status_completed.data

        db.session.add(new_appointment)
        db.session.commit()
        return redirect(url_for('main.view_schedule'))
    return render_template('main/schedule_appointment.html', title='Schedule an appointment', form=form)
def appointmentlist(sortby):
    form = AppointmentForm()

    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.
        new_appointment = Appointment(
            appointment_title=form.appointment_title.data,
            appointment_start_date=form.appointment_start_date.data,
            appointment_duration=form.appointment_duration.data,
            appointment_location=form.appointment_location.data,
            customer_name=form.customer_name.data,
            customer_notes=form.customer_notes.data)

        db.session.add(new_appointment)
        db.session.commit()
        # Redirect to this handler - but without form submitted - gets a clear form.
        return redirect(url_for('main.appointmentlist', sortby=sortby))

    if sortby == 0:
        appointment_list = Appointment.query.order_by(
            Appointment.appointment_title)
    elif sortby == 1:
        appointment_list = Appointment.query.order_by(
            Appointment.appointment_start_date)
    elif sortby == 2:
        appointment_list = Appointment.query.order_by(
            Appointment.appointment_duration)
    elif sortby == 3:
        appointment_list = Appointment.query.order_by(
            Appointment.appointment_location)
    elif sortby == 4:
        appointment_list = Appointment.query.order_by(
            Appointment.customer_name)
    elif sortby == 5:
        appointment_list = Appointment.query.order_by(
            Appointment.customer_notes)
    else:
        appointment_list = db.session.query(Appointment).all()
    return render_template("main/appointmentlist.html",
                           appointment_list=appointment_list,
                           form=form,
                           sortby=sortby)
Esempio n. 11
0
def edit_appointment(id):
    form = AppointmentForm()
    appointment = Appointment.query.get(id)
    if form.validate_on_submit():
        appointment.title = form.title.data
        appointment.date_time = datetime.datetime.combine(
            form.start_date.data, form.start_time.data)
        appointment.duration = form.duration.data
        appointment.location = form.location.data
        appointment.customer_name = form.customer_name.data
        appointment.notes = form.notes.data
        appointment.status = form.status.data

        db.session.add(appointment)
        db.session.commit()
        flash("Added the appointment")
        return redirect(url_for('main.single_appointment', id=id))
    return render_template("main/edit_appointment.html",
                           form=form,
                           appointment=appointment)
Esempio n. 12
0
def AddAppointment():
    form = AppointmentForm()
    if form.validate_on_submit():
        new_Appointment = Appointments()
        new_Appointment.Appointment_title = form.Appointment_title.data
        new_Appointment.Appointment_date = form.Appointment_date.data
        new_Appointment.Appointment_time = form.Appointment_time.data
        new_Appointment.Appointment_duration = form.Appointment_duration.data
        new_Appointment.Appointment_location = form.Appointment_location.data
        new_Appointment.Appointment_Customer = form.Appointment_customer.data
        new_Appointment.Appointment_notes = form.Appointment_notes.data
        print("WENT THROUGH")
        db.session.add(new_Appointment)
        db.session.commit()
        return redirect(url_for('main.AddAppointment'))

    Appointments_added = db.session.query(Appointments).all()

    return render_template("AddAppointment.html",
                           Appointments_added=Appointments_added,
                           form=form)
def appointment(appointment_id):
    form = AppointmentForm()
    if form.validate_on_submit():
        # Get the data from the form, and add it to the database.
        modified_appointment = Appointment(
            appointment_title=form.appointment_title.data,
            appointment_start_date=form.appointment_start_date.data,
            appointment_duration=form.appointment_duration.data,
            appointment_location=form.appointment_location.data,
            customer_name=form.customer_name.data,
            customer_notes=form.customer_notes.data)
        Appointment.query.filter(
            Appointment.appointment_id == appointment_id).delete()
        db.session.commit()
        db.session.add(modified_appointment)
        db.session.commit()

    appointment = Appointment.query.filter(
        Appointment.appointment_id == appointment_id).one()
    return render_template("main/appointment.html",
                           appointment=appointment,
                           form=form,
                           appointment_id=appointment_id)