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


Python Task.objects方法代码示例

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


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

示例1: completetask

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def completetask(taskid):

    rPath = urlparse.urlparse(request.referrer).path
    Task.objects(id = taskid).update_one(pull__people = ObjectId(g.user.id))
    Task.objects(id = taskid).update_one(add_to_set__completed = ObjectId(g.user.id))
    
    task = Task.objects(id = taskid).first()
    if rPath == '/':
        return redirect(url_for('index')) 
    else:
        return redirect(url_for('goaltree',goalid = task.goal.id))
开发者ID:akosel,项目名称:mesh,代码行数:13,代码来源:views.py

示例2: tasks_list

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def tasks_list(project_id):
    pro = Project.objects.get(pk=project_id)
    tasks = Task.objects(project=pro)
    u = User.objects.get(pk = session['user_id'])
    project_list = Project.objects(user =u)

    return render_template('tasks/list.html',project=pro,tasks=tasks,pro=project_list)
开发者ID:btomashvili,项目名称:vsmart,代码行数:9,代码来源:project_view.py

示例3: taskcomment

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def taskcomment(taskid):
    me = User.objects(id = g.user.id).first()
    comment = Comment(user = me, message = request.form['message'])

    Task.objects(id = taskid).update_one(push__comments = comment)

    task = Task.objects(id = taskid).first()

    feeditem = TaskRequest(message='Your friend just commented on your task',user=me,task=task,goal=task.goal)

    for person in task.people:
        if person != me:
            person.feed.append(feeditem)
            person.save()


    return redirect(url_for('goaltree',goalid = task.goal.id))
开发者ID:akosel,项目名称:mesh,代码行数:19,代码来源:views.py

示例4: index

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def index():
    username = session.get('username', '')
    if username == '':
        return redirect(url_for('todolist.login'))

    now = datetime.datetime.now().replace(microsecond=0)
    err_msg = ''

    if request.method == 'POST':
        task_id = username + now.strftime('%Y%m%e%H%M%S')
        detail = request.form.get('task_detail', '')

        try:
            Task.objects.get({'task_id': task_id})
        except Task.DoesNotExist:
            Task(task_id=task_id,
                 detail=detail,
                 add_time=now,
                 username=username).save()
        else:
            flash(u'任务id有相同')
        return redirect(url_for('todolist.index'))

    begin = datetime.datetime.combine(datetime.date.today(),
                                      datetime.time.min)
    end = datetime.datetime.combine(datetime.date.today(),
                                    datetime.time.max)

    list_task = Task.objects(
        Q(username=username, add_time__gte=begin, add_time__lte=end) |
        Q(username=username, add_time__lt=begin, complete=0)
    ).order_by('-add_time', 'complete')
    # list_task = Task.objects({
    #     '$or': [{
    #         'user_name': user_name,
    #         'add_time': {'$gte': begin, '$lte': end}},
    #         {'user_name': user_name,
    #          'add_time': {'$lt': begin},
    #          'complete': 0
    #     }]}).sort(
    #         'add_time', pymongo.DESCENDING).sort(
    #         'complete', pymongo.ASCENDING)

    g.list_task = list_task
    g.err_msg = err_msg
    g.str_date = now.strftime('%Y-%m-%d')
    return render_template('main.html')
开发者ID:junjielee,项目名称:welsh_cor,代码行数:49,代码来源:views.py

示例5: jointask

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def jointask(taskid):
    task = Task.objects(id = taskid).first()
    me = User.objects(id = g.user.id).first()

    feeditem = TaskRequest(message=g.user.name+" just joined a task you are working on",user = me,task = task, goal = task.goal)
    
    for person in task.people:
        if person != me:
            person.feed.append(feeditem)
            person.save()

    if me not in task.people:
        task.people.append(me)
        task.save()
    else:
        flash( "Person in task already")
    print task.goal.id
 
    return redirect(url_for('goaltree',goalid = task.goal.id))
开发者ID:akosel,项目名称:mesh,代码行数:21,代码来源:views.py

示例6: goaltree

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def goaltree(goalid):

    me = User.objects(id = g.user.id).first()
    goal = Goal.objects(id = goalid).first()
    tasks = Task.objects(goal = goalid).order_by('-end')

    form = TaskForm()
    if form.validate_on_submit():
        task = Task(goal=goal,name = form.name.data, description = form.description.data, end = form.end.data, people = [me])
        task.save()
    
        feeditem = TaskRequest(message='A task was added to a goal you are working on',user=me,task=task,goal=goal) 

        for person in goal.people:
            if person != me:
                person.feed.append(feeditem)
                person.save()

        return redirect(url_for('goaltree',goalid=goalid))

    megacounts = {}
    for person in goal.people:
        counts = {'active':[],'completed':[],'missed':[]}

        for task in tasks:
            if person in task.people:
                counts['active'].append(task)
            if person in task.completed:
                counts['completed'].append(task)
            if person in task.missed:
                counts['missed'].append(task)

        megacounts[person.id] = counts


    return render_template('goaltreelite.html',me = me, goal = goal, tasks = tasks, today = datetime.datetime.now(), form = form, allCounts=megacounts) 
开发者ID:akosel,项目名称:mesh,代码行数:38,代码来源:views.py

示例7: complete

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def complete(_id):
    now = datetime.datetime.now().replace(microsecond=0)
    Task.objects(task_id=_id).update_one(complete=1, end_time=now)

    return redirect(url_for('todolist.index'))
开发者ID:junjielee,项目名称:welsh_cor,代码行数:7,代码来源:views.py

示例8: edittask

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def edittask(taskid):
    task = Task.objects(id = taskid).first()
    Task.objects(id = taskid).update_one(set__name = request.form['name'])
    Task.objects(id = taskid).update_one(set__description = request.form['description'])
    return redirect(url_for('goaltree',goalid = task.goal.id))
开发者ID:akosel,项目名称:mesh,代码行数:7,代码来源:views.py

示例9: removetask

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def removetask(taskid):
    goalid = Task.objects(id=taskid).first().goal.id
    Task.objects(id=taskid).delete()

    return redirect(url_for('goaltree',goalid=goalid))
开发者ID:akosel,项目名称:mesh,代码行数:7,代码来源:views.py

示例10: index

# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import objects [as 别名]
def index():
    user = User.objects(id = g.user.id).first()
    tasks = Task.objects(people=g.user.id)
    return render_template('dashboard.html',
        title = 'Home',user=user,todo=tasks)
开发者ID:akosel,项目名称:mesh,代码行数:7,代码来源:views.py


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