本文整理匯總了Python中tasks.models.Tasks.priority方法的典型用法代碼示例。如果您正苦於以下問題:Python Tasks.priority方法的具體用法?Python Tasks.priority怎麽用?Python Tasks.priority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tasks.models.Tasks
的用法示例。
在下文中一共展示了Tasks.priority方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_task
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import priority [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)