Example #1
0
def delete_appt(max_y, max_x, menu_items, choice):

    # Change to true if this function does everything it needs to do
    success = False

    # Open the database
    con = db_connect()

    # Parse start and end datetime structs from the date strings
    ts = time.strptime(str(menu_items[choice][1]), '%Y-%m-%d %H:%M:%S')
    te = time.strptime(str(menu_items[choice][2]), '%Y-%m-%d %H:%M:%S')

    # Make start and end datetime objects from datetime struct data
    appt_sdt = datetime.datetime(ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec)
    appt_edt = datetime.datetime(te.tm_year, te.tm_mon, te.tm_mday, te.tm_hour, te.tm_min, te.tm_sec)

    # Build ISO date strings (used by iCalendar) from datetime struct
    # data. Format: YYYYMMDDTHHMMSSZ
    iso_start = str(ts.tm_year) + str(ts.tm_mon) + str(ts.tm_mday) + "T" + \
                str(ts.tm_hour) + str(ts.tm_min) + str(ts.tm_sec) + "Z"
    iso_end   = str(te.tm_year) + str(te.tm_mon) + str(te.tm_mday) + "T" + \
                str(te.tm_hour) + str(te.tm_min) + str(te.tm_sec) + "Z"

    # Build appointment date and start/end time strings from datetime objects
    appt_date  = appt_sdt.strftime("%A, %B %-d, %Y")
    appt_stime = appt_sdt.strftime("%-I:%M%p")
    appt_etime = appt_edt.strftime("%-I:%M%p")

    # Declare variables
    # TODO: Grab CAPITALIZED VALUES from a shared config file!
    from_addr = "FROM_ADDR"
    to_addr = "TO_ADDR"
    server = 'smtp.gmail.com'
    server_port = 587
    email_pwd = "FROM_PASS" # TODO: Move this to config.py module
    
    email_subj = "Advising Signup Cancellation"
    email_body = ("Advising Signup CANCELLED\n"
                  "Name: "  + menu_items[choice][3] + "\n"
                  "Email: " + menu_items[choice][4] + "\n"
                  "Date: "  + appt_date + "\n"
                  "Time: "  + appt_stime + " - " + appt_etime
                 )
    appointment_id = str(menu_items[choice][0])
    start_dtim = iso_start
    end_dtim = iso_end
    student_email = menu_items[choice][4]
    
    # Create CalAppt object
    cncl_mail = CalAppt(from_addr, to_addr, server, server_port, email_pwd)
    
    # Send Calendar appt. If no exceptions were encountered during the
    # sending of the email, 'emailed' will be set to True.
    emailed = cncl_mail.sendCncl(email_subj, email_body, appointment_id, start_dtim, end_dtim, student_email)
    
    if emailed:
        # Delete the item from the database
        con.execute("DELETE FROM appointment WHERE id=?", (menu_items[choice][0],))
        con.commit()

        # Make sure one change was made to the database. 
        if con.total_changes == 1:
            success = True

    # Close the database connection
    con.close()

    return success
Example #2
0
# Declare variables
from_addr = "EMAIL ADDRESS"
to_addr = "EMAIL ADDRESS"
server = 'smtp.gmail.com'
server_port = 587
email_pwd = "FROM EMAIL PASSWORD" # TODO: Move this to config.py module

email_subj = "Advising Signup Cancellation"
email_body = ("Advising Signup with McGrath, D Kevin CANCELLED\n"
              "Name: REDACTED\n"
              "Email: [email protected]\n"
              "Date: Wednesday, November 21st, 2012\n"
              "Time: 1:00pm - 1:15pm\n"
             )
appointment_id = "324"
start_dtim = "20160316T153000Z"
end_dtim = "20160316T160000Z"
student_email = "*****@*****.**"

# Create CalAppt object

test1 = CalAppt(from_addr, to_addr, server, server_port, email_pwd)

# Send Calendar appt

test1.sendCncl(email_subj, email_body, appointment_id, start_dtim, end_dtim, student_email)

# Print confirmation

print "Email sucesfully sent."
Example #3
0
# Declare variables
from_addr = "*****@*****.**"
to_addr = "*****@*****.**"
server = 'smtp.gmail.com'
server_port = 587
email_pwd = "COOLEY01acid73rd01BON"  # TODO: Move this to config.py module

email_subj = "Advising Signup Cancellation"
email_body = ("Advising Signup with McGrath, D Kevin confirmed\n"
              "Name: REDACTED\n"
              "Email: [email protected]\n"
              "Date: Wednesday, November 21st, 2012\n"
              "Time: 1:00pm - 1:15pm\n")
appointment_id = "324"
start_dtim = "20160316T153000Z"
end_dtim = "20160316T160000Z"
student_email = "*****@*****.**"

# Create CalAppt object

test1 = CalAppt(from_addr, to_addr, server, server_port, email_pwd)

# Send Calendar appt

test1.sendCncl(email_subj, email_body, appointment_id, start_dtim, end_dtim,
               student_email)

# Print confirmation

print "Email sucesfully sent."
Example #4
0
# Declare variables
from_addr = "FROM EMAIL ADDRESS"
to_addr = "TO EMAIL ADDRESS"
server = 'smtp.gmail.com'
server_port = 587
email_pwd = "FROM EMAIL PASSWORD" # TODO: Move this to config.py module

email_subj = "Advising Signup with McGrath, D Kevin confirmed for REDACTED"
email_body = ("Advising Signup with McGrath, D Kevin confirmed\n"
              "Name: REDACTED\n"
              "Email: [email protected]\n"
              "Date: Wednesday, November 21st, 2012\n"
              "Time: 1:00pm - 1:15pm\n"
             )
start_dtim = "20160315T153000Z"
end_dtim = "20160315T160000Z"
student_email = "*****@*****.**"

# Create CalAppt object

test1 = CalAppt(from_addr, to_addr, server, server_port, email_pwd)

# Send Calendar appt

test1.sendAppt(email_subj, email_body, start_dtim, end_dtim, student_email)

# Print confirmation

print "Email sucesfully sent."
Example #5
0
	unmodifiedTime = matchObject.group(1)

	email_body = ("Advising Appointment with " + advisorLastName + ", " + advisorMiddleName + " " + advisorFirstName+ " confirmed\n"
	              "Name: " + appointeeLastName + ", " + appointeeMiddleName + " " + appointeeFirstName + "\n"
	              "Email: " + appointeeEmail + "\n"
	              "Date: " + dateString + "\n"
	              "Time: "+ unmodifiedTime + "\n\n\n"
  	              "Please contact [email protected] if you experience problems\n"
	             )

	print email_body

	student_email = appointeeEmail
	# Create CalAppt object

	test1 = CalAppt(from_addr, to_addr, server, server_port, email_pwd)

	# Send Calendar appt

	test1.sendAppt(email_subj, email_body, str(insertionID), startDateString, endDateString, student_email)

	# Print confirmation

	print "Appointment Email successfully sent."

if emailType == 'CANCELLED' and sendCancelEmail == 'true':
	# Declare variables
	print "username is " + emailusername
	print "password is " + emailpassword
	print "advisor email is" + advisorEmail
	from_addr = emailusername