當前位置: 首頁>>代碼示例>>Python>>正文


Python Project.all方法代碼示例

本文整理匯總了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)
開發者ID:ecmendenhall,項目名稱:Kicksaver,代碼行數:9,代碼來源:kickparser.py

示例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)
開發者ID:abazad,項目名稱:appengine-bugs,代碼行數:29,代碼來源:main.py

示例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)
開發者ID:abazad,項目名稱:appengine-bugs,代碼行數:30,代碼來源:main.py

示例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 ''
開發者ID:apit,項目名稱:rinjani,代碼行數:9,代碼來源:uimodules.py

示例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>")
開發者ID:realthargor,項目名稱:urlaubsabrechnung,代碼行數:30,代碼來源:CronDeleteProjectsHandler.py

示例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
開發者ID:ecmendenhall,項目名稱:Kicksaver,代碼行數:10,代碼來源:twitterscript.py

示例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")
開發者ID:dillongrove,項目名稱:TheHackers,代碼行數:11,代碼來源:main.py

示例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 )
開發者ID:bmander,項目名稱:proje,代碼行數:11,代碼來源:views.py

示例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
開發者ID:ecmendenhall,項目名稱:Kicksaver,代碼行數:11,代碼來源:main.py

示例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
開發者ID:ecmendenhall,項目名稱:Kicksaver,代碼行數:12,代碼來源:twitterscript.py

示例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 )
    
開發者ID:bmander,項目名稱:proje,代碼行數:12,代碼來源:views.py

示例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)
開發者ID:iwxfer,項目名稱:Gae-Bug,代碼行數:13,代碼來源:main.py

示例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')
開發者ID:datadesk,項目名稱:latimes-document-stacker,代碼行數:13,代碼來源:views.py

示例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} )
開發者ID:bmander,項目名稱:proje,代碼行數:14,代碼來源:views.py

示例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)
開發者ID:git2samus,項目名稱:tamarindo-web,代碼行數:15,代碼來源:dashboard.py


注:本文中的models.Project.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。