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


Python Project.get_by_slug方法代码示例

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


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

示例1: tasks

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def tasks(request, project_slug):
    project = Project.get_by_slug(request.user, project_slug)
        
    query_filter = dict(creator=request.user)
    tasks_filter = dict()
        
    if 'tag' in request.GET:
        tag = request.GET['tag']
        query_filter['title__icontains'] = '#%s' % tag
        tasks_filter['class'] = 'tag'
        tasks_filter['value'] = '#%s' % tag
    if 'due' in request.GET:
        due = request.GET['due']
        query_filter['due_date'] = '%s' % due
        tasks_filter['class'] = 'due-date'
        tasks_filter['value'] = '#%s' % due
    
    tasks = project.task_set.filter(**query_filter).exclude(
        removed=True).exclude(archived=True)
        
    children = {}
    for t in tasks:
        children[t.id] = [c.id for c in t.children]
    children_json = dumps(children)
        
    # We can't call a methods with parameters (request.user) in django templates
    # so do the counts here
    for task in tasks:
        task.started = TaskInterval.objects.filter(task=task, doer=request.user,
            duration=None).count() > 0
            
    return direct_to_template(request, 'tasks/index.html', dict(
        project=project, project_slug=project_slug, tasks=tasks,
        children=children_json, tasks_filter=tasks_filter))
开发者ID:idiles,项目名称:taskapp,代码行数:36,代码来源:views.py

示例2: mark_undone

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def mark_undone(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    task.mark_completed(False)
    if task.archived:
        task.mark_archived(False)
        request.notifications.add(_(u'Task has been moved back to list'))
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:10,代码来源:views.py

示例3: archive_completed

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def archive_completed(request, project_slug):
    project = Project.get_by_slug(request.user, project_slug)
    counter = 0
    for task in Task.objects.filter(project=project, creator=request.user, 
        completed=True).exclude(archived=True):
        task.archived = True
        task.save()
        counter += 1
    return HttpResponse(dumps(dict(archived=counter)))
开发者ID:idiles,项目名称:taskapp,代码行数:11,代码来源:views.py

示例4: remove

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def remove(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    task.mark_removed(True)
    for item in TaskInterval.objects.filter(doer=request.user,
        duration=None):
        item.stop()
        item.save()
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:11,代码来源:views.py

示例5: indent

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def indent(request, project_slug, task_id, direction):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    
    if direction == 'left' and task.indent > 0:
        task.increase_indent(-1)
    elif direction == 'right':
        task.increase_indent(1)
        
    return HttpResponse('', status=204)
开发者ID:idiles,项目名称:taskapp,代码行数:12,代码来源:views.py

示例6: update

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def update(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    form = TaskForm(request.POST, instance=task)
    if form.is_valid():
        task = form.save()
        tre = TaskRegexp()
        due_date = tre.get_date(task.title)
        task.due_date = due_date
        task.save()
        return HttpResponse(dumps(dict(html=task.html)))
开发者ID:idiles,项目名称:taskapp,代码行数:13,代码来源:views.py

示例7: sort

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def sort(request, project_slug):
    if request.method == 'POST':
        project = Project.get_by_slug(request.user, project_slug)
        ids = loads(request.POST['ids'])
        ids = [int(i.replace('task-', '')) for i in ids]
        
        for pos, task_id in enumerate(ids):
            task = get_object_or_404(Task, pk=task_id, project=project)
            task.position = pos
            task.save()
        
    return HttpResponse('', status=204)
开发者ID:idiles,项目名称:taskapp,代码行数:14,代码来源:views.py

示例8: get

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
 def get(self, id_or_slug):
     from models import Project
     completed_projects = Project.get_all_complete()
     ongoing_projects = Project.get_all_ongoing()
     try:
         id = int(id_or_slug, 10)
         project = Project.get_by_id(id)
     except ValueError:
         project = Project.get_by_slug(id_or_slug)
     self.render('project_information.html', 
         project=project,
         completed_projects=completed_projects,
         ongoing_projects=ongoing_projects)
开发者ID:aswadrangnekar,项目名称:khandelwal,代码行数:15,代码来源:handlers.py

示例9: archive

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def archive(request, project_slug):
    project = Project.get_by_slug(request.user, project_slug)
    tasks = Task.objects.filter(creator=request.user,
        archived=True).exclude(removed=True)
        
    children = {}
    for t in tasks:
        children[t.id] = [c.id for c in t.children]
    children_json = dumps(children)
        
    return direct_to_template(request, 'tasks/archive.html', dict(
        project=project, project_slug=project_slug, tasks=tasks,
        children=children_json))
开发者ID:idiles,项目名称:taskapp,代码行数:15,代码来源:views.py

示例10: trash

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def trash(request, project_slug):
    project = Project.get_by_slug(request.user, project_slug)
    if request.method == 'POST' and 'empty' in request.POST:
        Task.objects.filter(creator=request.user, 
            removed=True).delete()
        request.notifications.add(_(u'Trash is now empty'))
        return redirect(reverse('tasks:tasks', args=(project_slug, )))
    
    tasks = Task.objects.filter(creator=request.user,
        removed=True)
        
    children = {}
    for t in tasks:
        children[t.id] = [c.id for c in t.children]
    children_json = dumps(children)
        
    return direct_to_template(request, 'tasks/trash.html', dict(
        project=project, project_slug=project_slug, tasks=tasks,
        children=children_json))
开发者ID:idiles,项目名称:taskapp,代码行数:21,代码来源:views.py

示例11: manage

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def manage(request, project_slug):
    project = Project.get_by_slug(request.user, project_slug)
    
    if request.method == 'POST':
        if 'save' in request.POST:
            form = ProjectForm(request.POST, instance=project)
            if form.is_valid():
                form.user = request.user
                project = form.save()
                request.notifications.add(_(u'Project information updated'))
                return redirect(reverse('tasks:manage', args=(project.slug,)))
        elif 'delete' in request.POST:
            project_title = project.title
            project.task_set.all().delete()
            project.delete()
            request.notifications.add(_(u'Project "%s" has been deleted') \
                % project_title)
            return redirect(reverse('tasks:index'))
        
    form = ProjectForm(instance=project)

    return direct_to_template(request, 'tasks/manage_project.html', dict(
        project_slug=project_slug, project=project, form=form))
开发者ID:idiles,项目名称:taskapp,代码行数:25,代码来源:views.py

示例12: create

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def create(request, project_slug):
    if request.method == 'POST':
        title = request.POST['title']
        project = Project.get_by_slug(request.user, project_slug)
        
        tre = TaskRegexp()
        due_date = tre.get_date(title)
        
        position = (Task.objects.filter(
            project=project).aggregate(Max('position'))['position__max'] \
            or 0) + 1
        task = Task(project=project,
            creator=request.user,
            title=title,
            position=position,
            due_date=due_date)
        task.save()
        
        resp = dict(id=task.id, time='0.00', html=task.html)
        resp_json = dumps(resp)
    
        return HttpResponse(resp_json)
        
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:26,代码来源:views.py

示例13: stop

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def stop(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    task.stop(doer=request.user)
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:7,代码来源:views.py

示例14: mark_done

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def mark_done(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id)
    task.mark_completed(True)
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:7,代码来源:views.py

示例15: restore

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_by_slug [as 别名]
def restore(request, project_slug, task_id):
    project = Project.get_by_slug(request.user, project_slug)
    task = get_object_or_404(Task, pk=task_id, project=project)
    task.mark_removed(False)
    return HttpResponse('', status=204)     # No content
开发者ID:idiles,项目名称:taskapp,代码行数:7,代码来源:views.py


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