本文整理汇总了Python中models.Activity.create方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.create方法的具体用法?Python Activity.create怎么用?Python Activity.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_activity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import create [as 别名]
def register_activity(request, time='', data='', client=''):
carrier, created = Carrier.objects.get_or_create(data=data)
if carrier.is_registered():
Activity.create(time, client, carrier)
return HttpResponse(status=200)
else:
return HttpResponse(status=403)
示例2: create_activity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import create [as 别名]
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
示例3: post
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import create [as 别名]
def post(self):
if not self.form.validate():
self.set_message('error', 'Invalid activity info. Please fix errors and try again.',
flash=True, life=10)
return self.get()
activity_id = self.form.activity_id.data
if (activity_id != None and len(activity_id) > 0):
activity = Activity.get_by_key_encoded(activity_id)
# Check ownership
if (activity.owner != self.auth_current_user.username):
self.set_message('error', 'Post your own trip and edit it as much as you like!',
life=10, flash=True)
return redirect('/')
else:
activity
# TODO copy form data to activity
else:
# New Activity
activity = Activity.create(author=self.auth_current_user, **self.form.data)
self.set_message('success', 'Activity saved. Let\'s do it!', flash=True, life=10)
return redirect('/activity?activity=%s' % activity.key())