def process_survey (request): # write information contained in request.form to a results file import sys from mail_file import mail_file from mx import DateTime import ThreadExSurvey_io if request.form: try: contact_name = request.form['contact_name'] if contact_name == '': contact_name = 'name not given' contact_office = request.form['contact_office'] if contact_office == '': contact_office = 'office not given' contact_email = request.form['contact_email'] if contact_email == '': contact_email = 'email not given' now = DateTime.now() stacnt = 0 while request.form.has_key('station%d'%stacnt): station = request.form['station%d'%stacnt] if request.form.has_key('accept%d'%stacnt) and request.form['accept%d'%stacnt] != 'na': accept = request.form['accept%d'%stacnt] else: accept = 'no accept response' comments = request.form['comments%d'%stacnt] if comments == '' or comments == 'na': comments = 'no comments' if request.form.has_key('adddata%d'%stacnt) and request.form['adddata%d'%stacnt] != 'na': adddata = request.form['adddata%d'%stacnt] else: adddata = 'no adddata response' addcomments = request.form['addcomments%d'%stacnt] if addcomments == '' or addcomments == 'na': addcomments = 'no addcomments' survey_file = open('/Users/keith/Sites/data/ThreadExSurvey.txt', 'a') survey_file.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % (now,station,accept,comments,adddata,addcomments,contact_name,contact_office,contact_email)) survey_file.close() stacnt = stacnt+1 except: print_exception() else: print_exception() mail_file ('*****@*****.**','ThreadEx survey submitted',None) return ThreadExSurvey_io.thankyou()
def get_cwa (request): from threads_dict import threads_dict import ThreadExSurvey_io cwa = '' cwa_name = '' cwa_list = [] cwa_threads = [] cwa_comments = {} if request.form: try: cwa = request.form['cwa'] cwa_name,cwa_list = cwa_dict[cwa] for (call,name,state) in cwa_list: cwa_comments[call] = read_old_comments(call) cwa_threads.append(threads_dict[call]) except: print_exception() else: print_exception() return ThreadExSurvey_io.display_form(cwa,cwa_name,cwa_list,cwa_threads,cwa_comments)