# Path: fbone/appointment/forms.py
# class MakeAppointmentForm(Form):
#     next = HiddenField()
# 
#     name = TextField(u'Name',
#                      [Required(),
#                       Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)])
#     time_range = TimeRangeSliderField(u'Time Range')
#     start_time = HiddenField(u'start_time')
#     end_time = HiddenField(u'end_time')
#     email = EmailField(u'Email',
#                        [Email(),
#                         Length(EMAIL_LEN_MIN, EMAIL_LEN_MAX)])
#     date = DateField(u'Date',
#                      [Required()],
#                      default=datetime.date.today())
#     timezone = SelectOptgroupField(u'Timezone',
#                                    [Required(),
#                                     Length(TIMEZONE_LEN_MIN,
#                                            TIMEZONE_LEN_MAX)],
#                                    choices=TIMEZONES)
#     message = TextAreaField(u'Message',
#                             [Required(),
#                              Length(MESSAGE_LEN_MIN, MESSAGE_LEN_MAX)],
#                             description={'placeholder': MESSAGE_PLACEHOLDER})
#     submit = SubmitField('OK')
# 
# Path: fbone/appointment/models.py
# class Appointment(db.Model):
# 
#     __tablename__ = 'appointments'
# 
#     id = db.Column(db.Integer, primary_key=True)
#     name = db.Column(db.String(USERNAME_LEN_MAX), nullable=False)
#     email = db.Column(db.String(EMAIL_LEN_MAX), nullable=False)
#     start_time = db.Column(db.Integer, nullable=False)
#     end_time = db.Column(db.Integer, nullable=False)
#     timezone = db.Column(db.String(TIMEZONE_LEN_MAX), nullable=False)
#     message = db.Column(db.String(MESSAGE_LEN_MAX), nullable=False)


from datetime import datetime, date
from flask import (Blueprint, render_template, request, abort, flash, url_for,
                   redirect, session, current_app, jsonify)
from flask.ext.mail import Message
from sqlalchemy.sql import select, and_, or_
from ..extensions import db, mail
from .forms import MakeAppointmentForm
from .models import Appointment
import smtplib
        date_obj = datetime.strptime(request.args.get('date'),
                                     "%Y-%m-%d").date()
    timezone = float(str(request.args.get('timezone', 0.00)))
    start_time = get_utc_seconds(date_obj, 0, timezone)
    end_time = get_utc_seconds(date_obj, 1440, timezone)

    conn = db.engine.connect()
    query = select([Appointment],
                   or_(and_(Appointment.start_time >= start_time,
                            Appointment.start_time <= end_time),
                       and_(Appointment.end_time >= start_time,
                            Appointment.end_time <= end_time))).\
        order_by(Appointment.start_time)
    result = conn.execute(query).fetchall()

    apt_time_utc_seconds = [[a.start_time, a.end_time] for a in result]
    apt_time_slider_minutes = [[get_local_minutes(a[0], date_obj, timezone),
                                get_local_minutes(a[1], date_obj, timezone)]
                               for a in apt_time_utc_seconds]

    return jsonify(apt_time_utc_seconds=apt_time_utc_seconds,
                   apt_time_slider_minutes=apt_time_slider_minutes,
                   date=str(date_obj),
                   timezone=timezone)


@appointment.route('/create', methods=['GET', 'POST'])
def create():
    if request.method == 'POST':
        wpic_no_send_email = u"wpic-no-send-anonymous@wpic.com"

# Path: fbone/appointment/forms.py
# class MakeAppointmentForm(Form):
#     next = HiddenField()
# 
#     name = TextField(u'Name',
#                      [Required(),
#                       Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)])
#     time_range = TimeRangeSliderField(u'Time Range')
#     start_time = HiddenField(u'start_time')
#     end_time = HiddenField(u'end_time')
#     email = EmailField(u'Email',
#                        [Email(),
#                         Length(EMAIL_LEN_MIN, EMAIL_LEN_MAX)])
#     date = DateField(u'Date',
#                      [Required()],
#                      default=datetime.date.today())
#     timezone = SelectOptgroupField(u'Timezone',
#                                    [Required(),
#                                     Length(TIMEZONE_LEN_MIN,
#                                            TIMEZONE_LEN_MAX)],
#                                    choices=TIMEZONES)
#     message = TextAreaField(u'Message',
#                             [Required(),
#                              Length(MESSAGE_LEN_MIN, MESSAGE_LEN_MAX)],
#                             description={'placeholder': MESSAGE_PLACEHOLDER})
#     submit = SubmitField('OK')
# 
# Path: fbone/appointment/models.py
# class Appointment(db.Model):
# 
#     __tablename__ = 'appointments'
# 
#     id = db.Column(db.Integer, primary_key=True)
#     name = db.Column(db.String(USERNAME_LEN_MAX), nullable=False)
#     email = db.Column(db.String(EMAIL_LEN_MAX), nullable=False)
#     start_time = db.Column(db.Integer, nullable=False)
#     end_time = db.Column(db.Integer, nullable=False)
#     timezone = db.Column(db.String(TIMEZONE_LEN_MAX), nullable=False)
#     message = db.Column(db.String(MESSAGE_LEN_MAX), nullable=False)


# Path: fbone/appointment/views.py
from datetime import datetime, date
from flask import (Blueprint, render_template, request, abort, flash, url_for,
                   redirect, session, current_app, jsonify)
from flask.ext.mail import Message
from sqlalchemy.sql import select, and_, or_
from ..extensions import db, mail
from .forms import MakeAppointmentForm
from .models import Appointment
import smtplib

        date_obj = datetime.strptime(request.args.get('date'),
                                     "%Y-%m-%d").date()
    timezone = float(str(request.args.get('timezone', 0.00)))
    start_time = get_utc_seconds(date_obj, 0, timezone)
    end_time = get_utc_seconds(date_obj, 1440, timezone)

    conn = db.engine.connect()
    query = select([Appointment],
                   or_(and_(Appointment.start_time >= start_time,
                            Appointment.start_time <= end_time),
                       and_(Appointment.end_time >= start_time,
                            Appointment.end_time <= end_time))).\
        order_by(Appointment.start_time)
    result = conn.execute(query).fetchall()

    apt_time_utc_seconds = [[a.start_time, a.end_time] for a in result]
    apt_time_slider_minutes = [[get_local_minutes(a[0], date_obj, timezone),
                                get_local_minutes(a[1], date_obj, timezone)]
                               for a in apt_time_utc_seconds]

    return jsonify(apt_time_utc_seconds=apt_time_utc_seconds,
                   apt_time_slider_minutes=apt_time_slider_minutes,
                   date=str(date_obj),
                   timezone=timezone)


@appointment.route('/create', methods=['GET', 'POST'])
def create():
    if request.method == 'POST':
        wpic_no_send_email = u"wpic-no-send-anonymous@wpic.com"

        form = MakeAppointmentForm(next=request.args.get('next'))