def dump(request, dumpAll=False, dumpPersons=False): """dumps either all or selected objects in to a big python file so that things can be re-loaded. also puts relevant /media files in a .tar file.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('dump report') dumpWhere = dsh_dump.init_dump() if not dumpWhere: return HttpResponse('failed to open dump file.') dumpFile,dumpPath,tarPath = dumpWhere response += 'dumping to:<br>' + dumpPath + '<br>\n' success,errorMsg = dsh_dump.dump_selected(dumpFile, dumpPath, tarPath, dumpAll=dumpAll, dumpPersons=dumpPersons) dumpFile.close() if errorMsg: response += '<br>' + errorMsg + '<br>\n' if success: response += '<font color=green><b>dump successful.</b></font>\n' else: response += '<font color=red><b>dump failed.</b></font>\n' response += page_footer() return HttpResponse(response)
def auto_dial_disable(request): """10/03/19: moved from view.py""" if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('disable auto-dial') dsh_db_config.set('auto_dial_disable', True) disabled = dsh_db_config.get('auto_dial_disable') if not disabled: message = 'views.auto_dial_disable: unexpected error.' response += dsh_utils.red_error_break_msg(message) dsh_django_utils.error_event(message, errorLevel='CRT') response += views.page_footer() return HttpResponse(response) response += spool_wipe_status_message() dsh_django_utils.auto_schedule_delete_all() response += dsh_utils.black_break_msg( 'now <font color=red><b>disabled</b></font>. ' +\ 'wanna <a href="/autodialenable">re-enable</a>?') response += views.page_footer() dsh_agi.report_event('auto-dial disabled.') return HttpResponse(response)
def reply_submit(request): """processes a reply form submission.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('process reply') if not 'from_red5' in request.POST or \ not request.POST['from_red5'] or \ not 'dsh_uid' in request.POST or \ not request.POST['dsh_uid']: response += dsh_utils.red_error_break_msg('invalid submission.') response += page_footer() return HttpResponse(response) dshUid = request.POST['dsh_uid'] name = request.POST['from_red5'] success,msgs,mp3Path = dsh_django_utils.convert_red5_flv_to_mp3(name) response += msgs if not success: response += page_footer() dsh_django_utils.cleanup_red5_conversion(success, name) return HttpResponse(response) success,msgs = dsh_django_utils.save_red5_mp3_in_django( mp3Path, originalItemDshUid=dshUid) response += msgs dsh_django_utils.cleanup_red5_conversion(success, name) response += page_footer() return HttpResponse(response)
def red5_save(request): """displays a form for saving a red5 message that's just saved. very much like reply(), only simpler. minus the dsh_uid of the original message.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('save a recorded message in the database') newest_stream = dsh_django_utils.newest_red5_stream() if newest_stream == None: newest_stream = '' newest_stream = newest_stream[:-4] response += """ <FORM ACTION="/savesubmit/" METHOD="post"> <BR> red5 message just recorded:<br> <INPUT TYPE="TEXT" NAME="from_red5" VALUE="%(newest_stream)s" SIZE=40><br> <br> <INPUT TYPE="submit" VALUE="submit"> </FORM> """ % {'newest_stream': newest_stream} response += page_footer() return HttpResponse(response)
def reply(request, dshUid): """displays a form for replying. fills the form with a default red5 message name.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('reply to a message') newest_stream = dsh_django_utils.newest_red5_stream() if newest_stream == None: newest_stream = '' newest_stream = newest_stream[:-4] response += """ <FORM ACTION="/replysubmit/" METHOD="post"> <BR> red5 message just recorded:<br> <INPUT TYPE="HIDDEN" NAME="dsh_uid" VALUE="%(dsh_uid)s"> <INPUT TYPE="TEXT" NAME="from_red5" VALUE="%(newest_stream)s" SIZE=40><br> <br> <INPUT TYPE="submit" VALUE="submit"> </FORM> """ % {'dsh_uid': dshUid, 'newest_stream': newest_stream} response += page_footer() return HttpResponse(response)
def save_submit(request): """processes a red5 save. very much like reply_submit(). only simpler.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('process save') if not 'from_red5' in request.POST or \ not request.POST['from_red5']: response += dsh_utils.red_error_break_msg('invalid submission.') response += page_footer() return HttpResponse(response) name = request.POST['from_red5'] success,msgs,mp3Path = dsh_django_utils.convert_red5_flv_to_mp3(name) response += msgs if not success: response += page_footer() dsh_django_utils.cleanup_red5_conversion(success, name) return HttpResponse(response) success,msgs = dsh_django_utils.save_red5_mp3_in_django(mp3Path) response += msgs dsh_django_utils.cleanup_red5_conversion(success, name) response += page_footer() return HttpResponse(response)
def email_confirm(request): """displays a simple form for confirming emailing the selection. modeled after red5_save().""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('email the selected items?') response += """ <FORM ACTION="/email/" METHOD="post"> email addresses: <INPUT TYPE="TEXT" NAME="email_addresses" SIZE="80" value="%s, "><br><br> comments:<BR> <TEXTAREA NAME="comments" ROWS=5 COLS=70></TEXTAREA><br><br> attach voice? <INPUT TYPE=checkbox NAME=attach_voice> include dsh.cs URLs? <INPUT TYPE=checkbox NAME=dsh_url><br><br> <!-- include pnet1-LAN URLs? <INPUT TYPE=checkbox NAME=lan_url> include pnet1-VPN URLs? <INPUT TYPE=checkbox NAME=vpn_url> <br><br> --> <INPUT TYPE="submit" VALUE="send"> </FORM> """ % (dsh_config.lookup('GMAIL_DEFAULT_RECIPIENT'),) response += page_footer() return HttpResponse(response)
def schedule_one_callee(request, personDshUid): """triggerred by clicking the little clock icon on the Person page. for scheduling auto-dialed call for one person.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('schedule auto-dialed call for one callee') response += '\n' disabled = dsh_db_config.get('auto_dial_disable') if disabled: response += dsh_utils.black_break_msg( 'auto-dial is currently <font color=red><b>disabled</b></font>.') response += page_footer() return HttpResponse(response) persons = dvoice.db.models.Person.objects.filter(dsh_uid=personDshUid) if not persons or len(persons) > 1: message = 'views.schedule_one_callee: bad DshUid: ' + personDshUid response += dsh_utils.red_error_break_msg(message) dsh_django_utils.error_event(message, errorLevel='CRT') response += page_footer() return HttpResponse(response) person = persons[0] dsh_django_utils.check_auto_timed_calls_for_person(person) response += dsh_utils.black_break_msg('done.') response += dsh_utils.black_break_msg( 'see the <a href=/scheduled>schedule</a>.') response += page_footer() return HttpResponse(response)
def keyword_add(request, dshUid): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('add key word to selected items') response += dsh_selection.keyword_add_del(dshUid, action='add') response += page_footer() return HttpResponse(response)
def scheduled_slots(request): """slots taken by people.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('all scheduled slots') response += dsh_django_utils.scheduled_slots() response += page_footer() return HttpResponse(response)
def schedule_del_all(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('delete all auto-dialed outgoing calls') output = dsh_django_utils.auto_schedule_delete_all(force=True) response += output response += page_footer() return HttpResponse(response)
def schedule_del(request, fileName): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('delete an auto-dialed outgoing call') output = dsh_django_utils.auto_schedule_delete(fileName) response += output response += page_footer() return HttpResponse(response)
def schedule_list(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('schedule of auto-dialed outgoing calls') output = dsh_django_utils.auto_schedule_list() response += output response += page_footer() return HttpResponse(response)
def unknown_list(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('list of unknown people') response += dsh_django_utils.unknown_list() response += page_footer() return HttpResponse(response)
def selection_unshare(request): if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('unshare the selected items') response += dsh_selection.process_selection('peer_shared', action='clear') response += views.page_footer() return HttpResponse(response)
def destar_selection(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('remove stars from selected items') response += dsh_selection.star(action='del') response += page_footer() return HttpResponse(response)
def selection_activate(request): if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('activate the selected items') response += dsh_selection.process_selection('active', action='set') response += views.page_footer() return HttpResponse(response)
def star_selection(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('add stars to selected items') response += dsh_selection.star() response += page_footer() return HttpResponse(response)
def phone_number_list(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('phone number list') response += dsh_django_utils.phone_number_list() response += page_footer() return HttpResponse(response)
def deselect_all(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('deselecting objects') response += dsh_dump.deselect_all() response += page_footer() return HttpResponse(response)
def dial_now_confirm(request, dshUid): """triggered by urls.py.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('dialing now...') response += dsh_django_utils.dial_now_confirm(dshUid) response += page_footer() return HttpResponse(response)
def select_starred(request): """triggered by urls.py.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('select starred items') response += dsh_selection.select_starred() response += page_footer() return HttpResponse(response)
def schedule_outgoing_calls(request): if dsh_django_request.deny_it(request): return please_log_in() response = page_header('schedule auto-dialed outgoing calls') #response += dsh_utils.black_break_msg('generating...') dsh_django_utils.check_auto_timed_calls_for_all_persons() response += dsh_utils.black_break_msg('done.') response += dsh_utils.black_break_msg( 'see the <a href=/scheduled>schedule</a>.') response += page_footer() return HttpResponse(response)
def dial_now(request, dshUid): """triggered by urls.py.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('dial a person now?') resStr,callee = dsh_django_utils.dial_now(dshUid) response += resStr response += page_footer() return HttpResponse(response)
def email_selection(request): """emails the selected items.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('email the selected items') if not 'email_addresses' in request.POST or \ not request.POST['email_addresses']: response += dsh_utils.red_error_break_msg('no email address given.') response += page_footer() return HttpResponse(response) response += dsh_utils.black_break_msg_debug( 'emails: ' + repr(request.POST['email_addresses']), 117) if ('comments' in request.POST) and request.POST['comments']: comments = request.POST['comments'] else: comments = '' attachVoice = False if 'attach_voice' in request.POST: response += dsh_utils.black_break_msg_debug( 'attach: ' + repr(request.POST['attach_voice']), 117) if request.POST['attach_voice']: attachVoice = True else: response += dsh_utils.black_break_msg_debug('attach: not found.', 117) fields = {'dsh_url': False, 'lan_url': False, 'vpn_url': False} for varStr,varVal in fields.iteritems(): if varStr in request.POST and request.POST[varStr]: fields[varStr] = True returnMsg,emailAddrs = dsh_django_utils.check_valid_email_addresses( request.POST['email_addresses']) if not emailAddrs: response += returnMsg response += page_footer() return HttpResponse(response) else: response += dsh_utils.black_break_msg_debug( 'email addresses are: ' + repr(emailAddrs), 117) response += dsh_selection.email_selections(emailAddrs, attachVoice, comments, urlFields=fields) response += page_footer() return HttpResponse(response)
def unhear(request, dshUid, eventTable, itemTable): """ 10/04/01: called by views.unhear(). """ if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('unhear') response += dsh_common_db.unhear(dshUid, eventTable, itemTable) response += views.page_footer() return HttpResponse(response)
def check_spoken_names(request): """triggered by urls.py.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('check spoken names', includeMp3Player=True) response += dsh_django_utils.check_spoken_names(kind = 'peer_shared') response += '<BR>' response += dsh_django_utils.check_spoken_names(kind = 'personalized') response += mp3_widget_control() response += page_footer() return HttpResponse(response)
def send_demo_reply_confirmed(request, dshUid, itemTable, keyWordTable, eventTable): """ 10/04/09: called by views.send_demo_reply_confirmed() """ if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('sending a demo reply now') response += dsh_common_db.send_demo_reply_confirmed( dshUid, itemTable, keyWordTable, eventTable) response += views.page_footer() return HttpResponse(response)
def schedule_one_callee(request, personDshUid): """triggerred by clicking the little clock icon on the Person page. for scheduling auto-dialed call for one person.""" if dsh_django_request.deny_it(request): return please_log_in() response = page_header('schedule auto-dialed call for one callee') response += '\n' disabled = dsh_db_config.get('auto_dial_disable') if disabled: response += dsh_utils.black_break_msg( 'auto-dial is currently <font color=red><b>disabled</b></font>.') #response += page_footer() #return HttpResponse(response) # # 10/03/18: # I'm going to schedule a call anyways. # for sending out doctor replies even though global auto-dial # has been turned off. # response += dsh_utils.black_break_msg( "but we are scheduling a call anyhow.") persons = dv2.db.models.Person.objects.filter(dsh_uid=personDshUid) if not persons or len(persons) > 1: message = 'views.schedule_one_callee: bad DshUid: ' + personDshUid response += dsh_utils.red_error_break_msg(message) dsh_django_utils.error_event(message, errorLevel='CRT') response += page_footer() return HttpResponse(response) person = persons[0] scheduled,respStr = dsh_django_utils.check_auto_timed_calls_for_person( person) response += dsh_utils.black_break_msg(respStr) if scheduled: response += dsh_utils.black_break_msg('scheduled.') else: response += dsh_utils.black_break_msg('not scheduled.') response += dsh_utils.black_break_msg('done.') response += dsh_utils.black_break_msg( 'see the <a href=/scheduled>schedule</a>.') response += page_footer() return HttpResponse(response)
def send_demo_reply_now(request, itemTable, keyWordTable, eventTable): """ 10/04/09: called by views.send_demo_reply_now() """ if dsh_django_request.deny_it(request): return views.please_log_in() response = views.page_header('send a demo reply now') sessionID = dsh_common_db.make_dsh_uid() success,msg = dsh_common_agi.demo_reply( itemTable, keyWordTable, eventTable, sessionID=sessionID) response += msg response += views.page_footer() return HttpResponse(response)