本文整理汇总了Python中jobs.models.Job.job_id方法的典型用法代码示例。如果您正苦于以下问题:Python Job.job_id方法的具体用法?Python Job.job_id怎么用?Python Job.job_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jobs.models.Job
的用法示例。
在下文中一共展示了Job.job_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: publish
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import job_id [as 别名]
def publish(self, request, pk=None):
"""
use for draft job publish
"""
draft_job = self.get_object()
serializer = ActionSerializer(data=request.data)
if serializer.is_valid():
if serializer.data.pop('action') == AVAILABLE_ACTIONS['JOB_PUBLISH']:
now = datetime.now().strftime('%Y%m%d%H%M%S%f') + '%s' % pk
job_to_publish = Job()
job_to_publish.owner = draft_job.owner
job_to_publish.time_of_publish = timezone.now()
job_to_publish.job_id = now
job_to_publish.job_list_type = draft_job.job_list_type
job_to_publish.status = Job.STATUS.active
job_to_publish.job_rate = draft_job.job_rate
job_to_publish.promotion_banner = draft_job.promotion_banner
job_to_publish.title = draft_job.title
job_to_publish.detail = draft_job.detail
job_to_publish.time_of_release = draft_job.time_of_release
job_to_publish.short_description = draft_job.short_description
# if job_to_publish.support_image.all():
# for image in draft_job.support_image:
# SupportImage.objects.create(job=draft_job, image=image.image)
support_image = SupportImage.objects.get(pk=draft_job.support_image.pk)
support_image.pk = None
support_image.save()
job_to_publish.support_image = support_image
job_to_publish.postal_code = draft_job.postal_code
job_to_publish.keywords = draft_job.keywords
job_to_publish.multiple_job_rates = draft_job.multiple_job_rates
job_to_publish.save()
return Response({'status': 'job published'})
else:
return Response({'status': 'action not supported'})
else:
return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST)