本文整理汇总了Python中models.Task.all方法的典型用法代码示例。如果您正苦于以下问题:Python Task.all方法的具体用法?Python Task.all怎么用?Python Task.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Task
的用法示例。
在下文中一共展示了Task.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
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} )
示例2: RefreshTasks
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def RefreshTasks(self):
from models import Class, Task, Book
from datetime import date
user = users.get_current_user()
inline = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate >', date.today())
urgent = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate <=', date.today())
template_values = {
'tasks': inline,
'urgent': urgent,
}
path = os.path.join(os.path.dirname(__file__), "templates", "tasklist.html")
code = template.render(path, template_values).decode('utf-8')
return code
示例3: DeleteClass
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def DeleteClass(self, *args):
from google.appengine.ext import db
from models import Task, Class, Book, Chapter
from google.appengine.api import users
user = users.get_current_user()
classname = args[0].replace('%20', ' ')
#Deleting all Tasks for this Module
q = Task.all().filter('user ==',user).filter('classname ==',classname)
results = q.fetch(10)
for result in results:
result.delete()
#Deleting all the Scripts and Chapters from this Module
qq = Book.all().filter('user ==',user).filter('classname ==',classname)
books = qq.fetch(10)
for book in books:
qqq = Chapter.all().filter('book ==', book.title).filter('user ==',user)
for chapter in qqq:
chapter.delete()
book.delete()
#Deleting the Module itself
qqqq = Class.all().filter('user ==',user).filter('name ==',classname)
results = qqqq.fetch(10)
for result in results:
result.delete()
return self.RefreshClasses()
示例4: test
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def test():
menuItems = ['test', 'clear/all', 'new']
## menuItems = ['<a href="/%s">%s</a><br>'% (item, item) for item in menuItems]
menu = menuItems
texto = 'Esto es un mensaje '
cssurl = url_for('static', filename='style.css')
tasks = Task.all()
return render_template('borrame.html', menu=menu, texto=texto, cssurl=cssurl, tasks=tasks)
示例5: ShowTask
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def ShowTask(self, *args):
from models import Task
user = users.get_current_user()
tasks = Task.all().filter('user ==',user).filter('title ==', args[0]).filter('classname ==', args[1])
path = os.path.join(os.path.dirname(__file__), "templates","showtask.html")
template_values = { 'tasks': tasks }
code = template.render(path, template_values).decode('utf-8')
return code
示例6: get
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def get(self):
#imports
from models import Class, Task, Book
from datetime import date
#get current User
user = users.get_current_user()
#Check if user wants to change the language
cookie_django_language = self.request.get('language', '')
if cookie_django_language:
if cookie_django_language == 'unset':
del self.request.COOKIES['django_language']
else:
self.request.COOKIES['django_language'] = cookie_django_language
self.reset_language()
if user:
classes = Class.all().order("exam").filter('user ==',user).filter('exam >', date.today())
logoutlink = users.create_logout_url(self.request.uri)
books = Book.all().filter('user ==',user)
inline = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate >', date.today())
urgent = Task.all().order("enddate").filter('state ==','Offen').filter('user ==',user).filter('enddate <=', date.today())
template_values = {
'books' : books,
'title':'Task Management',
'user' : user.email(),
'tasks': inline,
'urgent': urgent,
'logout' : logoutlink,
'classes': classes
}
path = os.path.join(os.path.dirname(__file__), 'templates', "index.html")
self.response.out.write(template.render(path, template_values).decode('utf-8'))
else:
providers = []
for p in openIdProviders:
p_name = p.split('.')[0].lower()
p_url = p.lower()
providers.append([users.create_login_url(federated_identity=p_url), p_name])
template_values = {
'providers' : providers,
}
path = os.path.join(os.path.dirname(__file__), 'templates', "login.html")
self.response.out.write(template.render(path, template_values).decode('utf-8'))
示例7: clear
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def clear(arg=None):
if arg == 'all':
tasks = Task.all()
for task in tasks:
## print task.description
task.delete()
return redirect(url_for('test'))
else:
return redirect(url_for('test'))
示例8: read_tasks
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def read_tasks():
q=Task.all()
tasks = {}
for task in q:
r=task.referrer
if r not in tasks:
tasks[r]=[]
tasks[r].append({'i' : task.key().id(), 't' : task.todo, 'a' : task.accomplished})
return current_app.response_class(json.dumps(tasks, indent=None if request.is_xhr else 2), mimetype='application/json')
示例9: CheckTask
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def CheckTask(self, *args):
from google.appengine.ext import db
from models import Task, Book
user = users.get_current_user()
name = args[0].replace('%20', ' ')
classname = args[1].replace('%20', ' ')
q = Task.all().filter('user ==',user).filter('title ==',name).filter('classname ==',classname)
results = q.fetch(10)
for result in results:
result.state = "Fertig"
result.put()
return self.RefreshTasks()
示例10: DeleteTask
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def DeleteTask(self, *args):
from google.appengine.ext import db
from models import Task
from google.appengine.api import users
classname = args[0].replace('%20', ' ')
taskname = args[1].replace('%20', ' ')
user = users.get_current_user()
q = Task.all().filter('user ==',user).filter('title ==',taskname).filter('classname ==',classname)
results = q.fetch(1)
for result in results:
result.delete()
return self.RefreshTasks()
示例11: switch
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def switch(command_args, account):
uuid = command_args.strip()
task = Task.all().filter("uuid =", uuid)[0]
task.status = db.Category("underway")
account.task = task
account.put()
command = Command(user=account.user,
created=datetime.datetime.now(),
root="SWITCH",
args=command_args,
task=task)
command.put()
示例12: purpose
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def purpose(command_args, account):
if not account.task:
return
uuids = command_args.strip().split()
child_uuid = uuids[0]
task_purpose = Task.all().filter("uuid =", child_uuid)[0]
if len(uuids)==2:
parent_uuid = uuids[1]
task = Task.all().filter("uuid =", parent_uuid)[0]
else:
task = account.task
task.blocks = task_purpose
task.put()
command = Command(user=account.user,
created=datetime.datetime.now(),
root="PURPOSE",
args=command_args,
task=task)
command.put()
示例13: get
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def get(self):
# collect saved tasks
tasks_json = []
for task in Task.all():
task_json = { "id": "%s" % task.key().id_or_name(),
"name": task.name, "priority": task.priority,
"projectId": task.projectId,
"effort": task.effort, "submitterId": task.submitterId,
"assigneeId": task.assigneeId, "type": task.type, "developmentStatus": task.developmentStatus,
"validation": task.validation, "description": task.description,
"createdAt": task.createdAt if task.createdAt != None else 0,
"updatedAt": task.updatedAt if task.updatedAt != None else 0 }
tasks_json.append(task_json)
# Set the response content type and dump the json
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(simplejson.dumps(tasks_json))
示例14: get
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def get(self):
if helpers.authorized(self.request.params['UUID'], self.request.params['authToken'], self.request.params['action']):
currentUserId = int(self.request.params['UUID'])
users = User.all()
projects = Project.all()
tasks = Task.all()
watches = Watch.all()
comments = Comment.all()
# If lastRetrievedAt is '', get full list of non-soft-deleted records (invoked at GUI startup - first time it is run or if local storage is not used)
# else get incremental list of records updated since last refresh
if len(self.request.params) > 0:
try:
lastRetrievedAt = self.request.params['lastRetrievedAt']
except:
lastRetrievedAt = ''
try:
loadDoneProjectData = self.request.params['loadDoneProjectData']
except:
loadDoneProjectData = 'false'
if lastRetrievedAt != '':
query = 'updatedAt >'
timestamp = int(lastRetrievedAt)
users.filter(query, timestamp)
users = users.fetch(helpers.MAX_RESULTS)
projects.filter(query, timestamp)
projects = projects.fetch(helpers.MAX_RESULTS)
tasks.filter(query, timestamp)
tasks = tasks.fetch(helpers.MAX_RESULTS)
watches.filter(query, timestamp)
watches = watches.fetch(helpers.MAX_RESULTS)
comments.filter(query, timestamp)
comments = comments.fetch(helpers.MAX_RESULTS)
notDoneProjects = []
doneProjectIds = []
tasksInNotDoneProjects = []
tasksInDoneProjectIds = []
watchesOnTasksInNotDoneProjects = []
commentsOnTasksInNotDoneProjects = []
if loadDoneProjectData == 'false':
for project in projects:
if project.developmentStatus == '_Done':
doneProjectIds.append(project.key().id_or_name());
else:
notDoneProjects.append(project);
for task in tasks:
try:
idx = doneProjectIds.index(task.projectId)
except:
idx = -1
if idx == -1:
tasksInNotDoneProjects.append(task);
else:
tasksInDoneProjectIds.append(task.key().id_or_name());
for watch in watches:
try:
idx = tasksInDoneProjectIds.index(watch.taskId)
except:
idx = -1
if idx == -1:
watchesOnTasksInNotDoneProjects.append(watch);
for comment in comments:
try:
idx = tasksInDoneProjectIds.index(comment.taskId)
except:
idx = -1
if idx == -1:
commentsOnTasksInNotDoneProjects.append(comment);
users_json = helpers.build_user_list_json(helpers.extract_non_deleted_records(users), currentUserId)
projects_json = helpers.build_project_list_json(helpers.extract_non_deleted_records(projects if loadDoneProjectData == 'true' else notDoneProjects))
tasks_json = helpers.build_task_list_json(helpers.extract_non_deleted_records(tasks if loadDoneProjectData == 'true' else tasksInNotDoneProjects))
watches_json = helpers.build_watch_list_json(helpers.extract_non_deleted_records(watches if loadDoneProjectData == 'true' else watchesOnTasksInNotDoneProjects))
comments_json = helpers.build_comment_list_json(helpers.extract_non_deleted_records(comments if loadDoneProjectData == 'true' else commentsOnTasksInNotDoneProjects))
records_json = {
"result": {
"users": users_json,
"projects": projects_json,
"tasks": tasks_json,
"watches": watches_json,
"comments": comments_json
}
}
# Set the response content type and dump the json
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(simplejson.dumps(records_json))
else:
helpers.report_unauthorized_access(self.response)
示例15: task
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import all [as 别名]
def task(request, uuid):
task = Task.all().filter("uuid =",uuid)[0]
subtasks = Task.all().filter("blocks =",task)
comments = Comment.all().filter("task =",task).order("-created")
return render_to_response( "task.html", {'task':task,'subtasks':subtasks,'comments':comments} )