本文整理汇总了Python中models.Task类的典型用法代码示例。如果您正苦于以下问题:Python Task类的具体用法?Python Task怎么用?Python Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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:
示例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)
示例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
示例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())
示例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
示例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} )
示例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 )
示例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
示例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)
示例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)
示例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}
示例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[:])
示例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)