• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: post

    def post(self):
        try:
            naloga = self.request.get('naloga')
            prioriteta = self.request.get('prioriteta')
            opis = self.request.get('opis')
            datum = self.request.get('termin')
            izvajalec = self.request.get('izvajalec')
# preveri obliko zapisa datuma ce je prazen doda trenutni datum in cas
            if datum == "":
                danes = datetime.datetime.now()
                termin_d = datetime.datetime.strftime(danes,'%d.%m.%Y %H:%M:%S')
                termin = datetime.datetime.strptime(termin_d, '%d.%m.%Y %H:%M:%S')
            else:
                termin = datetime.datetime.strptime(datum,'%d.%m.%Y %H:%M:%S')

            # kreiranje objekta opravilo in shranjevanje v bazo
            opravilo = Task(naloga=naloga, prioriteta=prioriteta, opis=opis, termin=termin, izvajalec=izvajalec)
            opravilo.put()
            # VSE OK vrne na seznam opravil
            return self.redirect_to('osnovna-stran')

        # V primerru napake javi opozoirilo in uporabnik mora napako odpraviti
        except ValueError:
            err = "Datum in ura obezno v formatu d.m.YYYY H:M:S Lahko pa je prazno"
            params = {'err': err}
            return self.render_template('vnos_opravila.html', params=params)
开发者ID:uroscokl,项目名称:PythonGAE,代码行数:26,代码来源:handlers.py


示例2: test_add_articles

def test_add_articles():
  author_id = 'chenqin'
  author_id = 'du-ke'
  author_id = 'flood-sung'
  author_id = 'hmonkey'
  Task.add_articles(author_id=author_id, limit=3000, min_voteup=1,
                    stop_at_existed=300)
开发者ID:probe301,项目名称:the-north-remembers,代码行数:7,代码来源:loop_watch.py


示例3: run

    def run(self):
        prev_time = int(time.time())
        cnt = 0
        _pid = os.getpid()
        while 1:
            _task_json = self._task_client.get(self._redis_key_in, block=False)
            if _task_json is None:
                continue
 
            _task = Task(**_task_json)

            _uid = _task.get_id()
            _script = _task.get_script()
            _script_args =  _task.get_script_args()
            _ignore_result = _task.is_ignore_result()
            _task_args = _task.get_task_args()

            _dispatcher = Dispatcher.get(_script)

            _result = None
            if _dispatcher is None:
                continue
            try:
                _task.set_status(Task.STATUS_RUNNING)
                self._execing_client.set(_uid, TaskMapper(_task).as_dict(), self._redis_key_execing)
                _result = _dispatcher(**_script_args)
                if _ignore_result:
                    continue
                _task.set_result(_result)
                self._result_client.set(_uid, TaskMapper(_task).as_dict(), self._redis_key_out)          
            except BaseException, e:
	        print e
                self._task_client.put(TaskMapper(_task).as_dict(), self._redis_key_in)
            finally:
开发者ID:imsilence,项目名称:asynctask,代码行数:34,代码来源:execute.py


示例4: task_add_subtask

def task_add_subtask(request, task_id=None, response_format='html'):
    """New subtask form"""

    parent = None
    if task_id:
        parent = get_object_or_404(Task, pk=task_id)
        if not request.user.profile.has_permission(parent, mode='x'):
            parent = None

    if request.POST:
        if 'cancel' not in request.POST:
            task = Task()
            form = TaskForm(
                request.user.profile, parent, None, None, request.POST, instance=task)
            if form.is_valid():
                task = form.save()
                task.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id]))
        else:
            return HttpResponseRedirect(reverse('projects_task_view', args=[parent.id]))
    else:
        form = TaskForm(request.user.profile, parent, None, None)

    context = _get_default_context(request)
    context.update({'form': form,
                    'task': parent})

    return render_to_response('projects/task_add_subtask', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:29,代码来源:views.py


示例5: task_process

def task_process():

    query = Task.gql("WHERE expire = :1 ORDER BY created_at", None)

    task_ref = None
    task_more = None

    for fake_task_ref in query.fetch(1):
        task_ref = task_get(fake_task_ref.action, fake_task_ref.action_id)

    if not task_ref:
        raise exceptions.ApiNoTasks

    method_ref = PublicApi.get_method(task_ref.action)

    rv = method_ref(*task_ref.args, **task_ref.kw)

    task_remove(task_ref.action, task_ref.action_id)

    query = Task.gql("WHERE expire < :1", datetime.utcnow())
    t_ref = query.fetch(1)
    if t_ref:
        task_more = True

    return task_more
开发者ID:garethr,项目名称:appengine-queue,代码行数:25,代码来源:__init__.py


示例6: add_task

def add_task(list_id):
    '''Add task for the current user'''

    ws = existing_web_session()
    dbs = db_session(close=True)
    form = forms.AddTask()
    post = request.POST.decode()

    if not dbs.query(Todo).filter(Todo.id==list_id).all():
        return {
            'message':'This is not the list you are looking for.',
            'ws':ws
        }

    task_name = cgi.escape(post['task'])

    task = Task(name=task_name,description='',todo_list_id=list_id, creator=ws['user_id'],reviewer=ws['user_id'])


    dbs.add(task)

    try:
        dbs.commit()
    except:
        dbs.rollback()
        return "-1"

    #tasks = dbs.query(Task).filter(Task.user_created_id == ws['user_id']).all()

    return json.dumps(task.get_details())
开发者ID:hackteam,项目名称:hackagong,代码行数:30,代码来源:user_stuff.py


示例7: generate_task

    def generate_task(self, sp_id, name):
        subprocess = SubProcess.objects.get(id=sp_id)

        task = Task(subprocess=subprocess, name=name)
        task.save()

        return task
开发者ID:PDI-DGS-Protolab,项目名称:backoffice_process_manager,代码行数:7,代码来源:task_manager.py


示例8: index

def index(request):
    if 'offset' in request.GET:
        offset = int(request.GET['offset'])
    else:
        offset = 0
    
    # use Users API to get current user
    user = users.get_current_user()
    
    # if a user is logged in, redirect to their workstack page
    if not user:
      greeting = ("<a href=\"%s\">Sign in or register</a>." %
                  users.create_login_url("/"))
      return HttpResponse("<html><body><h1>Workstack</h1>%s</body></html>"%greeting)
    
    logout_url = users.create_logout_url("/")
    
    commands = Command.all().filter("user =", user).order('-created').fetch(50,offset=offset)
    account = get_or_init_account( user )
    todos = Task.all().filter("blocks =",account.task).filter("status =",db.Category("todo"))
    slushtasks = Task.all().filter("proposer =", user).filter("blocks =", None).filter("status =",db.Category("todo"))
    
    stack = []
    tt = account.task
    while tt is not None:
        stack.append( tt )
        tt = tt.blocks
        
    for i, task in enumerate(reversed(stack)):
        task.level = i

    return render_to_response( "index.html", {'account':account, 'commands':commands, 'user':user, 'logout_url':logout_url,'todos':todos,'stack':stack,'offset':offset+50,'slushtasks':slushtasks} )
开发者ID:bmander,项目名称:amaurot,代码行数:32,代码来源:views.py


示例9: test_object_deletion

    def test_object_deletion(self):
        """
        Test that tasks are created and deleted correctly by being given an object and a list
        """
        
        # test objects
        normal_object    = self.test_object
        deletable_object = test_object = Site(name='foo', domain='foo.com')
        deletable_object.save()
        
        # check that there are none at the start
        self.assertEqual( Task.objects.count(), 0 )

        # create a couple of tasks
        for obj in [ normal_object, deletable_object ]:
            Task.update_for_object( obj, ['foo'] )

        # check that a task exists
        self.assertEqual( Task.objects.count(), 2 )
        self.assertEqual( Task.objects_for(deletable_object).count(), 1 )

        test_object.delete()
        
        # check that a task exists
        self.assertEqual( Task.objects.count(), 1 )
        self.assertEqual( Task.objects_for(deletable_object).count(), 0 )
开发者ID:Code4SA,项目名称:pombola,代码行数:26,代码来源:tests.py


示例10: make_task

def make_task(content=None):
    from sqlalchemy import func
    size = len(Task.query.all())+1
    access_token = session['access_token']
    content = request.form['content']
    if access_token:
        me = fb_call('me', args={'access_token': access_token})
        user_id = me['id']
        task = Task(size,
                    datetime.datetime.today(),
                    str(me['id']),
                    request.form['title'],
                    content,
                    False)

        assignees = parse_message_content(content)
        for assignee_name in assignees:
            task.add_assignee(fbuser_from_name(assignee_name))
#         task.add_assignee(Fbuser.query.filter_by(
#                 facebook_id=str(me['id'])).first_or_404())

        db.session.add(task)
        db.session.commit()

        return "Success"

    raise Exception
开发者ID:anirudhtodi,项目名称:social-tasks,代码行数:27,代码来源:socialtasks.py


示例11: task_add_to_milestone

def task_add_to_milestone(request, milestone_id=None, response_format='html'):
    """Task add to preselected project"""

    milestone = None
    if milestone_id:
        milestone = get_object_or_404(Milestone, pk=milestone_id)
        if not request.user.profile.has_permission(milestone, mode='x'):
            milestone = None

    project = milestone.project
    project_id = milestone.project.id

    if request.POST:
        if 'cancel' not in request.POST:
            task = Task()
            form = TaskForm(request.user.profile, None,
                            project_id, milestone_id, request.POST, instance=task)
            if form.is_valid():
                task = form.save()
                task.set_user_from_request(request)
                return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
        else:
            return HttpResponseRedirect(reverse('projects_milestone_view', args=[milestone.id]))
    else:
        form = TaskForm(
            request.user.profile, None, project_id, milestone_id)

    context = _get_default_context(request)
    context.update({'form': form,
                    'project': project,
                    'milestone': milestone})

    return render_to_response('projects/task_add_to_milestone', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:34,代码来源:views.py


示例12: addTask

def addTask(request):
    """Add a task"""
    d = {}

    pagename = request.POST["pagename"]
    page = TaskPage.objects.get(name__iexact=pagename)

    if "taskid" not in request.POST.keys():
        t = Task()
        t.text = request.POST["taskcontent"]
        t.page = page
        t.save()
        d["message"] = "Successfully added the task"
        d["text"] = t.text
        d["taskid"] = t.id
        d["update"] = 0
    else:
        taskid = int(request.POST["taskid"])
        giventask = Task.objects.get(pk=taskid)
        giventask.text = request.POST["taskcontent"]
        giventask.save()
        d["message"] = "Successfully updated  the task"
        d["text"] = urlize(giventask.text)
        d["taskid"] = giventask.id
        d["update"] = 1
    # return all the tasks
    d["error"] = "0"
    json = simplejson.dumps(d)
    return HttpResponse(json)
开发者ID:ramavadakattu,项目名称:sharedtasks,代码行数:29,代码来源:views.py


示例13: project

def project(request, project_id):
    project = get_object_or_404(Project, id=project_id)

    if request.method == 'POST':
        form = UploadFabFileForm(request.POST, request.FILES)
        if form.is_valid():
            fabfile = request.FILES['file']
            content = fabfile.readlines()
            import_block, tasks = get_source(content)

            project.import_block = import_block
            project.save()

            stage = Stage(name="Imported", project=project)
            stage.save()
            stage_user = StageUser(user=request.user, stage=stage)
            stage_user.save()

            for task in tasks:
                task_obj = Task(name=task['name'], body=task['body'])
                task_obj.save()
                stage_task = StageTask(task=task_obj, stage=stage)
                stage_task.save()

    else:
        form = UploadFabFileForm()

    stages = project.stage_set.order_by('name',)
    deployments = Deploy.objects.filter(stage__in=stages).order_by('-finished_at',)[:3]
    return {'p': project, 'stages': stages, 'deps': deployments, 'form': form}
开发者ID:dkron,项目名称:aurora,代码行数:30,代码来源:views.py


示例14: p_task_def

def p_task_def(p):
    '''task_def : TASK id IMPLEMENTS id LPAREN impl_params RPAREN
                | TASK id task_contents
    '''
    if p[3] != 'implements':
        task = Task(p[2], script_accumulator[:])
        task.requirements = requirement_accumulator[:]
        task.roles = role_accumulator[:]
        if len(description_accumulator) == 1:
            task.description = description_accumulator[0]
        del(description_accumulator[:])
        del(script_accumulator[:])
        del(role_accumulator[:])
        del(requirement_accumulator[:])
    else: 
        # get the task template from p[4]
        template = TaskTemplate.lookup.get(p[4])
        param_names = template.template_parameters
        implementation_params_accumulator.reverse()
        key = 0
        for param in param_names:
            template.set_parameter(param, implementation_params_accumulator[key])
            key += 1
        template.render_task(p[2])
        del(implementation_params_accumulator[:])
开发者ID:Manduka,项目名称:magma,代码行数:25,代码来源:parse.py


示例15: create_new_task

 def create_new_task(self, project_id):
     Task.create_task(
         name=self.task_name_input.get(), external_task_id=self.external_task_id_input.get(), project_id=project_id
     )
     self.update_tasks_list(project_id)
     self.popup.destroy()
     self.refresh_project_screen(project_id)
开发者ID:sasha0,项目名称:timetracker,代码行数:7,代码来源:timetracker.py


示例16: addtask

def addtask(request):
    # email = request.POST.get('owner', '')
    title = request.POST.get('title', '')
    description = request.POST.get('description', '')
    collaborator1 = request.POST.get('collaborator1', '')
    collaborator2 = request.POST.get('collaborator2', '')
    collaborator3 = request.POST.get('collaborator3', '')

    uid = request.session['mid']
    userobj = User.objects.get(id=uid)
    # because collaborators is a multi entry field, you have to add collaborators after creating the new task
    # I'm not sure why save goes above adding collaborators, but the code broke when the save was not above
    new_Task = Task(owner=userobj, title=title, description=description)
    new_Task.save()
    if collaborator1 != '':
        
        collaboratored = User.objects.filter(email = collaborator1)
        coll = collaboratored[0]
        new_Task.collaborators.add(coll)
        
    if collaborator2 != '':
        
        collaboratored = User.objects.filter(email = collaborator2)
        coll = collaboratored[0]
        new_Task.collaborators.add(coll)
        
    if collaborator3 != '':
        
        collaboratored = User.objects.filter(email = collaborator3)
        coll = collaboratored[0]
        new_Task.collaborators.add(coll)
    # new_Task.save()
    return HttpResponseRedirect ('/tasks/')
开发者ID:warrenbuhler,项目名称:djangosocialtodo,代码行数:33,代码来源:views.py


示例17: toggleComplete

  def toggleComplete(self, *args):
    user = users.get_current_user()
    task = db.GqlQuery('SELECT * FROM Task WHERE ANCESTOR IS :1',db.Key(args[0])).get()
    if task and task.who == user:
        if task.complete:
            task.complete = False
        else:
            task.complete = True
            task.complete_date = datetime.datetime.today()
        task.put()
        if task.complete == True and task.repeat == True:
            # verify that we haven't repeated this already
            repeatTask = db.GqlQuery('SELECT * FROM Task WHERE who = :1 AND name = :2 AND complete = False', task.who, task.name)
            if hasattr(repeatTask, "name") == False:
                repeatTask = Task(name=task.name,
                            who=task.who,
                            tags=task.tags,
                            nudge=task.nudge,
                            nudge_value=task.nudge_value,
                            repeat=task.repeat,
                            last_nudge=task.last_nudge,
			    last_complete=datetime.datetime.today())
                repeatTask.put()
        return True
    else:
        return False
开发者ID:xeb,项目名称:flowdle,代码行数:26,代码来源:rpc.py


示例18: tasks

def tasks(request):
    # tasks supports GET and POST
    if request.method == "GET":
        # GET should return all of the tasks
        # first, create a list of tasks
        raw_tasks = []
        for task in Task.objects.all():
            raw_tasks.append(task_to_raw(task))

            # now, create and return json (remember, front-end wants it in "contents")
        return_data = {"content": raw_tasks}

        return HttpResponse(json.dumps(return_data), mimetype="application/json")

    elif request.method == "POST":
        # Create a Task
        task = Task()

        # Load data
        raw = json.loads(request.raw_post_data)
        raw_to_task(raw, task)

        # attempt to save
        task.save()

        # return just the plain hash
        # returning Location header causes problems
        response = HttpResponse(json.dumps({"content": task_to_raw(task)}))
        response.status = 201
        return response
开发者ID:ialexi,项目名称:samples-todos,代码行数:30,代码来源:views.py


示例19: process

def process(request):
  current_epoch = datetime.now().strftime('%s')
  request.session['response'] = {'code':integers.CODE_SUCCESS,
  'message':strings.MESSAGE_SUCCESS, 'created':current_epoch}

  if request.method != 'POST':
    request.session['response'] = {'code':integers.CODE_INVALID_REQUEST_METHOD,
    'message':strings.MESSAGE_INVALID_REQUEST_METHOD, 'created':current_epoch}
    return HttpResponseRedirect('/')
  try:
    company_name = request.POST['company']
    task_description = request.POST['task']

    print task_description

    company = Company.objects.filter(name=company_name)
    if not company.exists():
      request.session['response'] = {'code':integers.CODE_INVALID_COMPANY_NAME,
      'message':strings.MESSAGE_INVALID_COMPANY_NAME, 'created':current_epoch}
      return HttpResponseRedirect('/')

    new_task = Task(description=task_description, company_id=company['id'])
    new_task_id = new_task.save()
    print new_task_id
    if not new_task_id:
      request.session['response'] = {'code':integers.CODE_SAVE_ERROR_TASK,
      'message':strings.MESSAGE_SAVE_ERROR_TASK, 'created':current_epoch}
      return HttpResponseRedirect('/')

  except Exception, e:
    print 'Exception occured: ' + str(e)
开发者ID:alioral,项目名称:foundationdb,代码行数:31,代码来源:views.py


示例20: download_datasets

def download_datasets(request):
    ds = request.GET.get('dataset')
    task_id = str(uuid.uuid4())
    job = Task(task_id=task_id, task_type='download_dataset', data_input=ds)
    job.save()
    download.apply_async(args=(ds, job), task_id=task_id)
    context = {'task_id': task_id, 'dataset': ds}
    return render_to_response('main/datasets.html', context)
开发者ID:cognitronz,项目名称:neuraltalk,代码行数:8,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Team类代码示例发布时间:2022-05-27
下一篇:
Python models.Tags类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap