def make_request(text, email = None, user_id = None, phone = None, alias = None, department = None, passed_recaptcha = False): """ Make the request. At minimum you need to communicate which record(s) you want, probably with some text.""" if (app.config['ENVIRONMENT'] == 'PRODUCTION') and (not passed_recaptcha) and is_spam(text): return None, False request_id = find_request(text) if request_id: # Same request already exists return request_id, False assigned_to_email = app.config['DEFAULT_OWNER_EMAIL'] assigned_to_reason = app.config['DEFAULT_OWNER_REASON'] if department: prr_email = db_helpers.get_contact_by_dept(department) if prr_email: assigned_to_email = prr_email assigned_to_reason = "PRR Liaison for %s" %(department) else: print "%s is not a valid department" %(department) department = None request_id = create_request(text = text, user_id = user_id, department = department) # Actually create the Request object new_owner_id = assign_owner(request_id = request_id, reason = assigned_to_reason, email = assigned_to_email) # Assign someone to the request open_request(request_id) # Set the status of the incoming request to "Open" if email or phone or alias: # If the user provided an e-mail address, add them as a subscriber to the request. subscriber_user_id = create_or_return_user(email = email, alias = alias, phone = phone) subscriber_id, is_new_subscriber = create_subscriber(request_id = request_id, user_id = subscriber_user_id) if subscriber_id: generate_prr_emails(request_id, notification_type = "Request made", user_id = subscriber_user_id) # Send them an e-mail notification return request_id, True
def make_request(text, email = None, user_id = None, phone = None, alias = None, department = None, passed_spam_filter = False, offline_submission_type = None, date_received = None): """ Make the request. At minimum you need to communicate which record(s) you want, probably with some text.""" if not passed_spam_filter: return None, False request_id = find_request(text) if request_id: # Same request already exists return request_id, False assigned_to_email = app.config['DEFAULT_OWNER_EMAIL'] assigned_to_reason = app.config['DEFAULT_OWNER_REASON'] if department: app.logger.info("\n\nDepartment chosen: %s" %department) prr_email = db_helpers.get_contact_by_dept(department) if prr_email: assigned_to_email = prr_email assigned_to_reason = "PRR Liaison for %s" %(department) else: app.logger.info("%s is not a valid department" %(department)) department = None request_id = create_request(text = text, user_id = user_id, offline_submission_type = offline_submission_type, date_received = date_received) # Actually create the Request object new_owner_id = assign_owner(request_id = request_id, reason = assigned_to_reason, email = assigned_to_email) # Assign someone to the request open_request(request_id) # Set the status of the incoming request to "Open" if email or alias or phone: subscriber_user_id = create_or_return_user(email = email, alias = alias, phone = phone) subscriber_id, is_new_subscriber = create_subscriber(request_id = request_id, user_id = subscriber_user_id) if subscriber_id: generate_prr_emails(request_id, notification_type = "Request made", user_id = subscriber_user_id) # Send them an e-mail notification return request_id, True
def make_request(text, email=None, user_id=None, phone=None, alias=None, department=None, passed_recaptcha=False): """ Make the request. At minimum you need to communicate which record(s) you want, probably with some text.""" if (app.config['ENVIRONMENT'] == 'PRODUCTION') and (not passed_recaptcha) and is_spam(text): return None, False request_id = find_request(text) if request_id: # Same request already exists return request_id, False assigned_to_email = app.config['DEFAULT_OWNER_EMAIL'] assigned_to_reason = app.config['DEFAULT_OWNER_REASON'] if department: prr_email = db_helpers.get_contact_by_dept(department) if prr_email: assigned_to_email = prr_email assigned_to_reason = "PRR Liaison for %s" % (department) else: print "%s is not a valid department" % (department) department = None request_id = create_request( text=text, user_id=user_id, department=department) # Actually create the Request object new_owner_id = assign_owner( request_id=request_id, reason=assigned_to_reason, email=assigned_to_email) # Assign someone to the request open_request( request_id) # Set the status of the incoming request to "Open" if email or phone or alias: # If the user provided an e-mail address, add them as a subscriber to the request. subscriber_user_id = create_or_return_user(email=email, alias=alias, phone=phone) subscriber_id, is_new_subscriber = create_subscriber( request_id=request_id, user_id=subscriber_user_id) if subscriber_id: generate_prr_emails( request_id, notification_type="Request made", user_id=subscriber_user_id) # Send them an e-mail notification return request_id, True