当前位置: 首页>>代码示例>>Python>>正文


Python notifications.generate_prr_emails函数代码示例

本文整理汇总了Python中notifications.generate_prr_emails函数的典型用法代码示例。如果您正苦于以下问题:Python generate_prr_emails函数的具体用法?Python generate_prr_emails怎么用?Python generate_prr_emails使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了generate_prr_emails函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_resource

def add_resource(resource, request_body, current_user_id = None):
	fields = request_body.form
	if "extension" in resource:
		return request_extension(int(fields['request_id']), fields.getlist('extend_reason'), current_user_id)
	if "note" in resource:
		return add_note(int(fields['request_id']), fields['note_text'], current_user_id)
	elif "record" in resource:
		if fields['record_description'] == "":
			return "When uploading a record, please fill out the 'summary' field."
		if 'record_access' in fields and fields['record_access'] != "":
			return add_offline_record(int(fields['request_id']), fields['record_description'], fields['record_access'], current_user_id)
		elif 'link_url' in fields and fields['link_url'] != "":
			return add_link(int(fields['request_id']), fields['link_url'], fields['record_description'], current_user_id)
		else:
			return upload_record(int(fields['request_id']), request.files['record'], fields['record_description'], current_user_id)
	elif "qa" in resource:
		return ask_a_question(int(fields['request_id']), current_user_id, fields['question_text'])
	elif "owner" in resource:
		participant_id, new = add_staff_participant(request_id = fields['request_id'], email = fields['owner_email'], reason = fields['owner_reason'])
		if new:
			generate_prr_emails(request_id = fields['request_id'], notification_type = "Staff participant added", user_id = get_attribute("user_id", obj_id = participant_id, obj_type = "Owner"))
		return participant_id
	elif "subscriber" in resource:
		return add_subscriber(request_id=fields['request_id'], email = fields['follow_email'])
	else:
		return False
开发者ID:richaagarwal,项目名称:recordtrac,代码行数:26,代码来源:prr.py

示例2: add_subscriber

def add_subscriber(request_id, email):
	user_id = create_or_return_user(email = email)
	subscriber_id, is_new_subscriber = create_subscriber(request_id = request_id, user_id = user_id)
	if subscriber_id:
		generate_prr_emails(request_id, notification_type = "Request followed", user_id = user_id)
		return subscriber_id
	return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:7,代码来源:prr.py

示例3: make_request

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
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:27,代码来源:prr.py

示例4: add_resource

def add_resource(resource, request_body, current_user_id = None):
	fields = request_body
	if "extension" in resource:
		if not fields.getlist('extend_reason') and not fields.getlist('extend_reasons'):
			return "You must select a reason for the extension."
		return request_extension(int(fields['request_id']), fields.getlist('extend_reason'), current_user_id)
	if "note" in resource:
		return add_note(request_id = int(fields['request_id']), text = fields['note_text'], user_id = current_user_id, passed_spam_filter = True) # Bypass spam filter because they are logged in.
	elif "record" in resource:
		if fields['record_description'] == "":
			return "When uploading a record, please fill out the 'summary' field."
		if 'record_access' in fields and fields['record_access'] != "":
			return add_offline_record(int(fields['request_id']), fields['record_description'], fields['record_access'], current_user_id)
		elif 'link_url' in fields and fields['link_url'] != "":
			return add_link(request_id = int(fields['request_id']), url = fields['link_url'], description = fields['record_description'], user_id = current_user_id)
		# else:
		# 	document = None
		# 	try:
		# 		document = request.files['record']
		# 	except:
		# 		app.logger.info("\n\nNo file passed in")
		# 	return upload_record(request_id = int(fields['request_id']), document = document, description = fields['record_description'], user_id = current_user_id)
	elif "qa" in resource:
		return ask_a_question(request_id = int(fields['request_id']), user_id = current_user_id, question = fields['question_text'])
	elif "owner" in resource:
		participant_id, new = add_staff_participant(request_id = fields['request_id'], email = fields['owner_email'], reason = fields['owner_reason'])
		if new:
			generate_prr_emails(request_id = fields['request_id'], notification_type = "Staff participant added", user_id = get_attribute("user_id", obj_id = participant_id, obj_type = "Owner"))
		return participant_id
	elif "subscriber" in resource:
		return add_subscriber(request_id=fields['request_id'], email = fields['follow_email'])
	else:
		return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:33,代码来源:prr.py

示例5: close_request

def close_request(request_id, reason = "", user_id = None):
	req = get_obj("Request", request_id)
	change_request_status(request_id, "Closed")
	# Create a note to capture closed information:
	create_note(request_id, reason, user_id)
	generate_prr_emails(request_id = request_id, notification_type = "Request closed")
	add_staff_participant(request_id = request_id, user_id = user_id)
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:7,代码来源:prr.py

示例6: make_request

def make_request(
    text,
    email=None,
    assigned_to_name=None,
    assigned_to_email=None,
    assigned_to_reason=None,
    user_id=None,
    phone=None,
    alias=None,
    department=None,
):
    """ Make the request. At minimum you need to communicate which record(s) you want, probably with some text."""
    if is_spam(text):
        return None, False
    request_id = find_request(text)
    if request_id:  # Same request already exists
        return request_id, False
    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
开发者ID:ryanj,项目名称:public-records,代码行数:30,代码来源:prr.py

示例7: make_request

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
开发者ID:vzvenyach,项目名称:recordtrac,代码行数:26,代码来源:prr.py

示例8: add_offline_record

def add_offline_record(request_id, description, access, user_id):
	""" Creates a record with offline attributes """
	record_id = create_record(request_id = request_id, user_id = user_id, access = access, description = description) # To create an offline record, we need to know the request ID to which it will be added, the user ID for the person adding the record, how it can be accessed, and a description/title of the record.
	if record_id:
		change_request_status(request_id, "A response has been added.")
		generate_prr_emails(request_id = request_id, notification_type = "City response added")
		add_staff_participant(request_id = request_id, user_id = user_id)
		return record_id
	return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:9,代码来源:prr.py

示例9: ask_a_question

def ask_a_question(request_id, owner_id, question):
	""" City staff can ask a question about a request they are confused about."""
	qa_id = create_QA(request_id = request_id, question = question, owner_id = owner_id)
	if qa_id:
		change_request_status(request_id, "Pending")
		generate_prr_emails(request_id, notification_type = "Question asked", user_id = get_requester(request_id))
		add_staff_participant(request_id = request_id, user_id = get_attribute(attribute = "user_id", obj_id = owner_id, obj_type = "Owner"))
		return qa_id
	return False
开发者ID:SheilaLDugan,项目名称:public-records,代码行数:9,代码来源:prr.py

示例10: add_link

def add_link(request_id, url, description, user_id):
	""" Creates a record with link attributes """
	record_id = create_record(url = url, request_id = request_id, user_id = user_id, description = description)
	if record_id:
		change_request_status(request_id, "A response has been added.")
		generate_prr_emails(request_id = request_id, notification_type = "City response added")
		add_staff_participant(request_id = request_id, user_id = user_id)
		return record_id
	return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:9,代码来源:prr.py

示例11: answer_a_question

def answer_a_question(qa_id, answer, subscriber_id = None, passed_spam_filter = False):
	""" A requester can answer a question city staff asked them about their request."""
	if (not answer) or (answer == "") or (not passed_spam_filter):
		return False
	else:
		request_id = create_answer(qa_id, subscriber_id, answer)
		# We aren't changing the request status if someone's answered a question anymore, but we could change_request_status(request_id, "Pending")
		generate_prr_emails(request_id = request_id, notification_type = "Question answered")
		return True
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:9,代码来源:prr.py

示例12: assign_owner

def assign_owner(request_id, reason, email = None): 
	""" Called any time a new owner is assigned. This will overwrite the current owner."""
	owner_id, is_new_owner = add_staff_participant(request_id = request_id, reason = reason, email = email)
	req = get_obj("Request", request_id)
	if req.current_owner == owner_id: # Already the current owner
		return owner_id
	update_obj(attribute = "current_owner", val = owner_id, obj = req)
	user_id = get_attribute(attribute = "user_id", obj_id = owner_id, obj_type = "Owner")
	if is_new_owner:
		generate_prr_emails(request_id = request_id, notification_type = "Request assigned", user_id = user_id)
	return owner_id
开发者ID:SheilaLDugan,项目名称:public-records,代码行数:11,代码来源:prr.py

示例13: ask_a_question

def ask_a_question(request_id, user_id, question):
	""" City staff can ask a question about a request they are confused about."""
	req = get_obj("Request", request_id)
	qa_id = create_QA(request_id = request_id, question = question, user_id = user_id)
	if qa_id:
		change_request_status(request_id, "Pending")
		requester = req.requester()
		if requester:
			generate_prr_emails(request_id, notification_type = "Question asked", user_id = requester.user_id)
		add_staff_participant(request_id = request_id, user_id = user_id)
		return qa_id
	return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:12,代码来源:prr.py

示例14: add_note

def add_note(request_id, text, user_id = None, passed_spam_filter = False):
	if not text or text == "" or (not passed_spam_filter):
		return False
	note_id = create_note(request_id = request_id, text = text, user_id = user_id)
	if note_id:
		change_request_status(request_id, "A response has been added.")
		if user_id:
			add_staff_participant(request_id = request_id, user_id = user_id)
			generate_prr_emails(request_id = request_id, notification_type = "City response added")
		else:
			generate_prr_emails(request_id = request_id, notification_type = "Public note added")
		return note_id
	return False
开发者ID:codeforamerica,项目名称:recordtrac,代码行数:13,代码来源:prr.py

示例15: upload_record

def upload_record(request_id, file, description, user_id):
	""" Creates a record with upload/download attributes """
	try:
		doc_id, filename = scribd_helpers.upload_file(file = file, request_id = request_id)
	except:
		return "The upload timed out, please try again."
	if doc_id == False:
		return "Extension type '%s' is not allowed." % filename
	else:
		if str(doc_id).isdigit():
			record_id = create_record(doc_id = doc_id, request_id = request_id, user_id = user_id, description = description, filename = filename, url = app.config['HOST_URL'] + doc_id)
			change_request_status(request_id, "A response has been added.")
			generate_prr_emails(request_id = request_id, notification_type = "City response added")
			add_staff_participant(request_id = request_id, user_id = user_id)
			return record_id
	return "There was an issue with your upload."
开发者ID:richaagarwal,项目名称:recordtrac,代码行数:16,代码来源:prr.py


注:本文中的notifications.generate_prr_emails函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。