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


Python Album.pictures_list方法代碼示例

本文整理匯總了Python中models.Album.pictures_list方法的典型用法代碼示例。如果您正苦於以下問題:Python Album.pictures_list方法的具體用法?Python Album.pictures_list怎麽用?Python Album.pictures_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Album的用法示例。


在下文中一共展示了Album.pictures_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: album_picture

# 需要導入模塊: from models import Album [as 別名]
# 或者: from models.Album import pictures_list [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),
    )
開發者ID:hwmrocker,項目名稱:gweb,代碼行數:97,代碼來源:views.py


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