当前位置: 首页>>代码示例>>Python>>正文


Python Book.query方法代码示例

本文整理汇总了Python中books.models.Book.query方法的典型用法代码示例。如果您正苦于以下问题:Python Book.query方法的具体用法?Python Book.query怎么用?Python Book.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在books.models.Book的用法示例。


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

示例1: book_form

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def book_form(request, name):
  book = Book.query(Book.name==name).get()
  if request.method == 'POST':
    form = BookForm(request.POST, instance=book)
    if form.is_valid():
      form.save()
      return redirect('/books/')
  else:
    form = BookForm(instance=book)
  return render(request, 'book_form.html', {'form': form})
开发者ID:danielroseman,项目名称:gaemeta,代码行数:12,代码来源:views.py

示例2: view_library

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def view_library():
	useraccount = flaskext.login.current_user
	if not useraccount:
		return jsonify({"Error":"User not signed in"})

	books = {}
	i = 0
	for copy in useraccount.get_library():
		book = Book.query(Book.key == copy.book).get()
		books[i] = book.to_dict()
		i += 1
	return jsonify(JsonIterable.dict_of_dict(books))
开发者ID:byu-osl,项目名称:bookout,代码行数:14,代码来源:api.py

示例3: get_my_book_list

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def get_my_book_list():
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "<a href='%s' >Login</a>" %users.create_login_url(dest_url=url_for('manage_library'))

	books = {}
	counter = 0
	for copy in cur_user.get_library():
		book = Book.query(Book.key == copy.book).get()
		books[counter] = book.to_dict()
		counter += 1
	return jsonify(JsonIterable.dict_of_dict(books))
开发者ID:byu-osl,项目名称:bookout,代码行数:15,代码来源:views.py

示例4: discover

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def discover():
	user = current_user()
	booklist = []
	string = ""
	for connection in user.get_connections():
		u = UserAccount.getuser(connection.id())
		for copy in u.get_library():
			book = Book.query(Book.key == copy.book).get()
			booklist.append(book)
	#Sort booklist alphabetically, with title as the primary sort key and author as secondary
	booklist.sort(key=lambda book: book.author.lower())
	booklist.sort(key=lambda book: book.title.lower())
	
	return render_response('discover.html',books=booklist)
开发者ID:byu-osl,项目名称:bookout,代码行数:16,代码来源:views.py

示例5: book_due_reminders

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def book_due_reminders():
	count = 0
	"""find all the books due tomorrow and send reminder emails"""
	books = BookCopy.query(BookCopy.due_date==date.today() + timedelta(days=1)).fetch()
	for book in books:
		count += 1
		owner = UserAccount.query(UserAccount.key==book.owner).get()
		mail.send_mail(sender=owner.email,
			to=UserAccount.query(UserAccount.key==book.borrower).get().email,
			subject="Book Due Soon",
			body="""Hey, remember that book you borrowed on Bookout from me, '%s'? Please get it back to me by tomorrow.
			
Thanks!
%s"""%(Book.query(Book.key==book.book).get().title,owner.name))
	return "%s reminders were sent out" %count
开发者ID:byu-osl,项目名称:bookout,代码行数:17,代码来源:views.py

示例6: library

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def library():
	booklist = []
	useraccount = current_user()
	for copy in useraccount.get_library():
		book = Book.query(Book.key == copy.book).get()
		book.title = book.title
		book.escapedtitle = re.escape(book.title)
		if copy.borrower is None:
			book.available = True
		else:
			book.available = False
		booklist.append(book)
	#Sort booklist alphabetically, with title as the primary sort key and author as secondary
	booklist.sort(key=lambda book: book.author.lower())
	booklist.sort(key=lambda book: book.title.lower())
		
	return render_response('managelibrary.html', myBooks=booklist)
开发者ID:byu-osl,项目名称:bookout,代码行数:19,代码来源:views.py

示例7: profile

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def profile(userID):
	profile_user = UserAccount.get_by_id(int(userID))
	user = current_user()
	if not profile_user:
		return render_response('invalidprofile.html')
	if user.is_connected(profile_user):
		library = []
		for copy in profile_user.get_library():
			book = Book.query(Book.key == copy.book).get()
			library.append(book)
			if copy.borrower is None:
				book.available = True
			else:
				book.available = False
			book.copyid = copy.key.id()
		return render_response('profile.html',profile_user=profile_user,library=library)
	return render_response('invalidprofile.html')
开发者ID:byu-osl,项目名称:bookout,代码行数:19,代码来源:views.py

示例8: books

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import query [as 别名]
def books(request):
  return render(request, 'books.html', {'books': Book.query()})
开发者ID:danielroseman,项目名称:gaemeta,代码行数:4,代码来源:views.py


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