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


Python Tasks.state方法代码示例

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


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

示例1: create_task

# 需要导入模块: from tasks.models import Tasks [as 别名]
# 或者: from tasks.models.Tasks import state [as 别名]
def create_task(request):
    json_value = {}
    module_code = "04"
    module_status = ""
    if request.method == 'POST':
        if request.user.is_authenticated():
            if all(key in request.POST for key in ('name', 'description', 'priority', 'state', 'due_date')):
                name = request.POST['name']
                description = request.POST['description']
                priority = request.POST['priority']
                state = request.POST['state']
                due_date = request.POST['due_date']
                if priority and state and name and description and due_date:
                    if 1 <= int(priority) <= 5 and 1 <= int(state) <= 3:
                        task_object = Tasks()
                        task_object.name = name
                        task_object.description = description
                        task_object.priority = priority
                        task_object.state = state
                        task_object.due_date = due_date
                        task_object.user = request.user
                        try:
                            task_object.save()
                            module_status = "01"  # success
                        except ValidationError:
                            module_status = "00"  # post data; date field format not correct yyyy-mm-dd
                    else:
                        module_status = "00"  # post data error
                else:
                    module_status = "00"  # post data error
            else:
                module_status = "00"  # post data error
        else:
            module_status = "02"  # user not logged in
    else:
        module_status = "00"  # method not post
    json_value['status_code'] = module_code + module_status
    return_value = json.dumps(json_value)
    return HttpResponse(return_value)
开发者ID:anupsabraham,项目名称:simple-to-do-list,代码行数:41,代码来源:views.py


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