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


Python Task.is_enabled方法代码示例

本文整理汇总了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),
    )
开发者ID:kackoryba,项目名称:liahen,代码行数:55,代码来源:views.py

示例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),
    )
开发者ID:kackoryba,项目名称:liahen,代码行数:52,代码来源:views.py


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