コード例 #1
0
ファイル: activity_helper.py プロジェクト: jesse1983/pymay
def create_activity(activity_type, lead=None, job=None):
	description = None
	lead_key = None
	job_key = None

	if job is not None and job.key is not None:
		job_key = job.key

	if lead is not None and lead.key is not None:
		lead_key = lead.key
	else:
		if job is not None and job.lead is not None:
			lead_key = job.lead


	if activity_type == 'LEAD_SENT':
		description = _build_lead_sent_description(lead.to_json())
	elif activity_type == 'LEAD_READ':
		description = _build_lead_read_description(lead)
	elif activity_type == 'LEAD_CLICKED':
		description = _build_lead_clicked_description(lead)
	elif activity_type == 'LEAD_PENDING_PAYMENT':
		description = _build_lead_pending_payment_description(lead)
	elif activity_type == 'LEAD_CONVERTED':
		description = _build_lead_converted_description(lead)
	elif activity_type == 'JOB_CREATED':
		Activity.set_job_in_all_lead_activities(job)
		description = _build_job_created_description(job)
	elif activity_type == 'JOB_ASSIGNED':
		description = 'The job has been taken by a Flixer'
	elif activity_type == 'JOB_CANCELLED_BY_FLIXER':
		description = 'The job has been cancelled by the flixer'
	elif activity_type == 'JOB_CANCELLED_BY_PROPERTY_OWNER':
		description = 'The job has been cancelled by the property owner'
	elif activity_type == 'JOB_RESCHEDULED':
		description = 'The job has been rescheduled by the property owner'
	elif activity_type == 'JOB_PUBLISHING_STARTED':
		description = 'The job publishing has been started'
	elif activity_type == 'JOB_PUBLISHING_DONE':
		description = 'The job publishing has been done'
	elif activity_type == 'JOB_PUBLISHING_REDO_DONE':
		description = 'The job fixes publishing has been done'
	elif activity_type == 'JOB_REPROVED':
		description = 'The property owner has reproved the job'
	elif activity_type == 'JOB_APPROVED':
		description = 'The property owner has approved the job'
	elif activity_type == 'JOB_PUBLISHED_AT_VALUEGAIA':
		description = 'The job has been published at ValueGaia'
	elif activity_type == 'JOB_FINISHED':
		description = 'The job has been finished'


	if description is not None:
		Activity.create(description, activity_type, lead_key=lead_key, job_key=job_key)

	return True