本文整理汇总了Python中models.Album.title方法的典型用法代码示例。如果您正苦于以下问题:Python Album.title方法的具体用法?Python Album.title怎么用?Python Album.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Album
的用法示例。
在下文中一共展示了Album.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import title [as 别名]
def album(request, album_id = None):
if album_id is not None:
album = request.db_session.query(Album).get(album_id)
else:
album = Album()
if request.method == 'POST':
if 'cancel' in request.POST:
return redirect('index')
form = AlbumForm(request.POST)
if form.is_valid():
# hydrate album object
album.title = form.cleaned_data['title']
album.artist = form.cleaned_data['artist']
# save it
request.db_session.add(album)
request.db_session.commit()
# show flash message to confirm update is OK
messages.success(request, "Album saved successfully")
# redirect to list of albums
return redirect('index')
elif album_id is not None:
form = AlbumForm(album.__dict__)
else:
form = AlbumForm()
return render(request, "album.html", {'form': form, 'album_id': album_id})
示例2: album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import title [as 别名]
def album(request, album_id, lang="en", name=""):
if album_id == "0":
query = request.GET.get("query", " ")
album = Album(query=query)
album.id = 0
else:
album = get_object_or_404(Album, id=album_id)
try:
page = int(request.GET.get("page", "1"))
except ValueError:
page = 1
if request.GET.get("redirect", "") != "":
if album_id == "0" and page == 1:
goto = reverse("wilson:custom_album", kwargs={"lang": translation.get_language(), "query": query})
elif album_id == "0" and page > 1:
goto = reverse(
"wilson:custom_album", kwargs={"lang": translation.get_language(), "page": page, "query": query}
)
elif page == 1:
goto = reverse(
"wilson:album",
kwargs={"lang": translation.get_language(), "album_id": album_id, "name": slugify(album.title())},
)
else:
goto = reverse(
"wilson:album_page",
kwargs={
"lang": translation.get_language(),
"album_id": album_id,
"name": slugify(album.title()),
"page": page,
},
)
return HttpResponseRedirect(goto)
paginator = Paginator(album.pictures_id_list(), 35, 7)
# If page request (9999) is out of range, deliver last page of results.
try:
album_pics = paginator.page(page)
except (EmptyPage, InvalidPage):
album_pics = paginator.page(paginator.num_pages)
album_pics.page_range = paginator.page_range
return render_to_response(
"wilson/album.html",
{
"album": album,
"album_pics": album_pics,
"menu": {
"left": list(MenuPlaceholder.objects.filter(parent=None, position_h="l").order_by("position_v")),
"right": list(MenuPlaceholder.objects.filter(parent=None, position_h="r").order_by("position_v")),
},
},
context_instance=RequestContext(request),
)
示例3: new_album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import title [as 别名]
def new_album(self):
form = NewAlbumForm(request.form or None)
if request.method == 'POST' and form.validate():
album = Album()
album_title = request.form['title']
album_description = request.form['description']
album_path, album_thumb = self.gal_man.create_album(album_title)
album.title = album_title
album.description = album_description
album.album_path = album_path
album.thumb_path = album_thumb
album.save()
return redirect(url_for('.show_album', album_id=album.id))
return self.render('admin/new_album.html', form=form)
示例4: album_picture
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import title [as 别名]
def album_picture(request, album_id, picture_id, lang="en", name="", redirect=False, picture_title=""):
if album_id == "0":
query = request.GET.get("query", " ")
album = Album(query=query)
album.id = 0
else:
album = get_object_or_404(Album, id=album_id)
picture_id = int(picture_id)
picture = album.pictures_list()[picture_id]
album.slice = album.get_slice(picture_id)
if redirect or request.GET.get("redirect", "") != "":
if album_id == "0":
return HttpResponseRedirect(
reverse(
"wilson:custom_album_picture",
kwargs={
"lang": lang,
"query": album.queryurl(),
"picture_title": slugify(picture.title()),
"picture_id": picture_id,
},
)
)
else:
return HttpResponseRedirect(
reverse(
"wilson:album_picture",
kwargs={
"lang": lang,
"name": slugify(album.title()),
"album_id": album_id,
"picture_title": slugify(picture.title()),
"picture_id": picture_id,
},
)
)
prev = next = None
if album.id != 0:
if 0 < picture_id:
prev = reverse(
"wilson:album_picture",
kwargs={
"album_id": album_id,
"picture_id": picture_id - 1,
"lang": lang,
"name": slugify(album.title()),
},
)
if picture_id < len(album.pictures_list()) - 1:
next = reverse(
"wilson:album_picture",
kwargs={
"album_id": album_id,
"picture_id": picture_id + 1,
"lang": lang,
"name": slugify(album.title()),
},
)
else:
if 0 < picture_id:
prev = reverse(
"wilson:custom_album_picture",
kwargs={"picture_id": picture_id - 1, "query": album.queryurl(), "lang": lang},
)
if picture_id < len(album.pictures_list()) - 1:
next = reverse(
"wilson:custom_album_picture",
kwargs={"picture_id": picture_id + 1, "query": album.queryurl(), "lang": lang},
)
album_page = ((picture_id) // 35) + 1
if album.id == 0:
album_url = reverse(
"wilson:custom_album_page", kwargs={"page": album_page, "query": album.queryurl(), "lang": lang}
)
else:
album_url = reverse(
"wilson:album_page",
kwargs={"name": slugify(album.title()), "album_id": album_id, "page": album_page, "lang": lang},
)
return render_to_response(
"wilson/album_picture.html",
{
"album": album,
"obj": picture,
"prev": prev,
"next": next,
"album_url": album_url,
"menu": {
"left": list(MenuPlaceholder.objects.filter(parent=None, position_h="l").order_by("position_v")),
"right": list(MenuPlaceholder.objects.filter(parent=None, position_h="r").order_by("position_v")),
},
},
context_instance=RequestContext(request),
)