本文整理汇总了Python中models.Project.all方法的典型用法代码示例。如果您正苦于以下问题:Python Project.all方法的具体用法?Python Project.all怎么用?Python Project.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_old_projects
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def remove_old_projects():
p = Project.all()
old_project = p.order('-saved').get()
if old_project:
old_date = old_project.saved
p = Project.all().filter('saved = ', old_date)
db.delete(p)
示例2: post
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def post(self):
# if we don't have a user then throw
# an unauthorised error
user = users.get_current_user()
if not user:
self.render_403()
return
name = self.request.get("name")
# check we have a value
if name:
# then check we have a value which isn't just spaces
if name.strip():
if Project.all().filter('name =', name).count() == 0:
# we also need to check if we have something with the same slug
if Project.all().filter('slug =', slugify(unicode(name))).count() == 0:
try:
project = Project(
name=name,
user=users.get_current_user(),
)
project.put()
logging.info("project added: %s" % project.name)
except db.BadValueError, e:
logging.error("error adding project: %s" % e)
示例3: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get(self, slug):
# make sure we have a trailing slash
if self.request.path[-1] != "/":
self.redirect("%s/" % self.request.path, True)
return
try:
project = Project.all().filter('slug =', slug).fetch(1)[0]
except IndexError:
self.render_404()
return
user = users.get_current_user()
# check we have the permissions to be looking at settings
if project.user == user or users.is_current_user_admin():
owner = True
else:
self.render_403()
return
context = {
'project': project,
'owner': owner,
}
# calculate the template path
output = self.render("project_settings.html", context)
self.response.out.write(output)
示例4: render
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def render(self, **kwargs):
projects = Project.all({'type':CONTENT_TYPE.PROJECT, \
'status':'published'})\
.sort([('created_at', -1)]).limit(5)
if projects:
return self.render_string('modules/project-latest', projects=projects)
else: return ''
示例5: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get(self):
self.response.out.write("<html><body><h1>deleting abandoned projects</h1><ol>")
# iterate over list of projects no one has access rights anymore
for p in [p for p in Project.all() if len([r for r in p.projectrights_set])==0]:
self.response.out.write("<li>Project: %s<ul>" % p.name)
for t in p.transaction_set:
self.response.out.write("<li>transaction</li>")
t.delete()
for a in p.person_set:
self.response.out.write("<li>Account: %s<ul>" % a.name)
for m in a.member_set:
if m.group.key()!=a.key():
self.response.out.write("<li>Membership: %s</li>" % m.group.name)
m.delete()
a.delete()
self.response.out.write("</ul></li>")
for c in p.currency_set:
self.response.out.write("<li>Currency: %s</li>" % c.name)
c.delete()
for t in p.ticket_set:
self.response.out.write("<li>Ticket: %s</li>" % t.user)
t.delete()
for i in p.invitation_set:
self.response.out.write("<li>Invitation: %s</li>" % i.user)
i.delete()
self.response.out.write("</ul></li>")
p.delete()
self.response.out.write("</ol></body></html>")
示例6: get_close_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get_close_project(budget, last_projects):
""" Get a new project to tweet, but don't repeat the last. """
p = Project.all()
projects = p.filter('left < ', budget).fetch(10)
project = projects.pop()
while project.link in last_projects:
project = projects.pop()
return project
示例7: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get(self):
#Wipe datastore of all projects
projs = Project.all().fetch(1000)
for proj in projs:
proj.delete()
Project(name="Sendery", graph_json = "asdf", mvp_effect = "lasers").put()
self.response.out.write("done")
示例8: update_project_counts
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def update_project_counts( request, user ):
n = 0
for nickname in Nickname.all():
nickname.project_count = Project.all().filter("user =", nickname.user).count()
nickname.put()
n += 1
return HttpResponse( "Projects counted for %d nicknames"%n )
示例9: get_projects
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get_projects(budget, update=False):
key = str(budget)
all_projects = memcache.get(key)
if all_projects is None or update:
p = Project.all()
all_projects = p.filter('left <= ', budget)
all_projects = list(all_projects)
memcache.set(key, all_projects)
return all_projects
示例10: get_soon_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get_soon_project(budget, last_projects):
""" Get a new project to tweet, but don't repeat the last. """
p = Project.all()
projects = [project for project in p.filter('left < ', budget)]
timeleft = lambda i: i.end - datetime.now() + timedelta(0, 14400)
projects.sort(key=timeleft, reverse=True)
project = projects.pop()
while project.link in last_projects:
project = projects.pop()
return project
示例11: set_project_updated
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def set_project_updated( request, user ):
n = 0
for project in Project.all():
if project.updated is None:
project.updated = datetime.datetime.now()
project.put()
n += 1
return HttpResponse( "Set the Project.updated on %d records"%n )
示例12: post
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def post(self, slug):
project = Project.all().filter('slug =', slug).fetch(1)[0]
try:
file = self.request.POST['file']
f = DatastoreFile(data=file.value, mimetype=file.type, project=project, name=file.filename)
f.put()
url = "http://%s/file/%s/%d/%s" % (self.request.host, slug, f.key().id(), f.name)
except Exception, e:
logging.error("error uploading file: %s" % e)
示例13: sitemap
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def sitemap(request):
"""
A sitemap for Google.
"""
document_list = Document.all().filter("is_published =", True).order("-publication_date")
project_list = Project.all().filter("is_published =", True)
context = {
'document_list': document_list,
'project_list': project_list,
}
return direct_to_template(request, 'sitemap.xml', context, mimetype='text/xml')
示例14: welcome
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def welcome(request):
user = users.get_current_user()
if user:
enter_url="/"
else:
enter_url=users.create_login_url("/")
user_count = Nickname.all().count()
project_count = Project.all().count()
return render_to_response( "welcome.html", {'enter_url':enter_url, 'user_count':user_count, 'project_count':project_count} )
示例15: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import all [as 别名]
def get(self):
user = users.get_current_user()
projects = Project.all()
projects.filter("owner =", user.user_id())
projects.order("title")
projects = tuple(projects) # prevent re-execution when iterating
context = context_dict(locals(), 'user', 'projects')
context['logout_url'] = users.create_logout_url('/')
page = template.render('templates/dashboard.html', context)
self.response.out.write(page)