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


Python Job.job_rate方法代码示例

本文整理汇总了Python中jobs.models.Job.job_rate方法的典型用法代码示例。如果您正苦于以下问题:Python Job.job_rate方法的具体用法?Python Job.job_rate怎么用?Python Job.job_rate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jobs.models.Job的用法示例。


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

示例1: publish

# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import job_rate [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)
开发者ID:frusciante,项目名称:RestAPI,代码行数:42,代码来源:views.py


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