本文整理汇总了Python中tasks.models.Task.is_enabled方法的典型用法代码示例。如果您正苦于以下问题:Python Task.is_enabled方法的具体用法?Python Task.is_enabled怎么用?Python Task.is_enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.is_enabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: task_set_view
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_enabled [as 别名]
def task_set_view(request, pk): # zobrazenie sady ako zoznam
task_set = get_object_or_404(TaskSet, pk=pk)
if not TaskSet.can_see(task_set, request.user):
raise Http404
# vytvori sa alebo updatne aktualna sada
act = Active.objects.get_or_create(user=request.user)
a = act[0]
a.task_set = task_set
a.save()
# zoznam uloh v sade; iba tie, ktorym moze vidiet zadania v zozname
q = Task.objects.filter(task_set=task_set)
q_ids = [o.id for o in q if Task.can_see(o, request.user, "t")]
tasks = q.filter(id__in=q_ids)
# zoznam sad do horneho menu; iba tie, ktore user moze vidiet
q = TaskSet.objects.order_by("title")
q_ids = [o.id for o in q if TaskSet.can_see(o, request.user)]
sets = q.filter(id__in=q_ids)
# roztriedenie uloh na kategorie (ci su vyriesene/precitane)
# v tomto poradi sa mu aj zobrazuju
task_cat = []
task_cat.append({"tasks": [], "type": "act_sub"}) # 0
task_cat.append({"tasks": [], "type": "act_read"}) # 1
task_cat.append({"tasks": [], "type": "sol_sub"}) # 2
task_cat.append({"tasks": [], "type": "sol_read"}) # 3
for task in tasks:
if Task.is_solved(task, request.user):
if task.type == Task.SUBMIT:
task_cat[2]["tasks"].append(task)
elif task.type == Task.READ:
task_cat[3]["tasks"].append(task)
elif Task.is_enabled(task, request.user):
if task.type == Task.SUBMIT:
task_cat[0]["tasks"].append(task)
elif task.type == Task.READ:
task_cat[1]["tasks"].append(task)
return render_to_response(
"tasks/task_set.html",
{
"active_app": "tasks", # kvoli havnemu menu
"task_set": task_set, # aktualna sada
"sets": sets, # viditelne sady v taboch
"style": "list", # styl zobrazovania sady
"categories": task_cat, # ulohy podla kategorii
"tasks": tasks, # danej sady
},
context_instance=RequestContext(request),
)
示例2: task_set_graph_view
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import is_enabled [as 别名]
def task_set_graph_view(request, pk=False): # zobrazenie sady ako graf
# ak sme nespecifikovali sadu (menu->Ulohy), zobrazi sa/vytvori sa aktivna
if not pk:
act = Active.objects.get_or_create(user=request.user)
pk = act[0].task_set.id
task_set = get_object_or_404(TaskSet, pk=pk)
if not TaskSet.can_see(task_set, request.user):
raise Http404
# vytvori sa alebo updatne aktualna sada
act = Active.objects.get_or_create(user=request.user)
a = act[0]
a.task_set = task_set
a.save()
# zoznam uloh v sade; iba tie, o ktorych moze vediet
q = Task.objects.filter(task_set=task_set)
q_ids = [o.id for o in q if Task.can_see(o, request.user, "g")]
tasks = q.filter(id__in=q_ids)
# zoznam sad do horneho menu; iba tie, ktore user moze vidiet
q = TaskSet.objects.order_by("title")
q_ids = [o.id for o in q if TaskSet.can_see(o, request.user)]
sets = q.filter(id__in=q_ids)
# roztriedime kvoli vykreslovaniu v grafe
solved_tasks = []
actual_tasks = []
invis_tasks = []
for task in tasks:
if Task.is_solved(task, request.user):
solved_tasks.append(task)
elif Task.is_enabled(task, request.user):
actual_tasks.append(task)
else:
invis_tasks.append(task)
return render_to_response(
"tasks/task_set_graph.html",
{
"active_app": "tasks", # hlavne menu
"task_set": task_set, # aktualna sada
"sets": sets, # vsetky sady
"style": "graph", # styl zobrazovania sady
},
context_instance=RequestContext(request),
)