예제 #1
0
파일: views.py 프로젝트: tuukka/Booki
def view_group(request, groupid):
    try:
        group = models.BookiGroup.objects.get(url_name=groupid)
    except models.BookiGroup.DoesNotExist:
        return pages.ErrorPage(request, "errors/group_does_not_exist.html", {"group_name": groupid})
        
    books = models.Book.objects.filter(group=group, hidden=False)
    members = group.members.all()

    isMember = request.user in members
    if request.user.is_authenticated():
        yourBooks = models.Book.objects.filter(owner=request.user)
    else:
        yourBooks = []

    bs = security.getUserSecurityForGroup(request.user, group)

    history = models.BookHistory.objects.filter(book__group=group)[:20]
    n_members = len(members)
    n_books = len(books)

    return render_to_response('portal/group.html', {"request":    request, 
                                                    "title":      "Ovo je neki naslov",
                                                    "group":      group,
                                                    "books":      books,
                                                    "n_books":    n_books,
                                                    "your_books": yourBooks,
                                                    "members":    members,
                                                    "n_members": n_members,
                                                    "security":   bs,
                                                    "history": history,
                                                    "is_member":  isMember})
예제 #2
0
def view_group(request, groupid):
    """
    Django View. This is main Booki Groups page.

    @type request: C{django.http.HttpRequest}
    @param request: Client Request object
    @type groupid: C{string}
    @param groupid: Unique group name
    """

    try:
        group = models.BookiGroup.objects.get(url_name=groupid)
    except models.BookiGroup.DoesNotExist:
        return pages.ErrorPage(request, "errors/group_does_not_exist.html",
                               {"group_name": groupid})
    except models.BookiGroup.MultipleObjectsReturned:
        return pages.ErrorPage(request, "errors/group_does_not_exist.html",
                               {"group_name": groupid})

    books = models.Book.objects.filter(group=group, hidden=False)
    members = group.members.all()

    isMember = request.user in members
    if request.user.is_authenticated():
        yourBooks = models.Book.objects.filter(owner=request.user)
    else:
        yourBooks = []

    bs = security.getUserSecurityForGroup(request.user, group)

    history = models.BookHistory.objects.filter(book__group=group)[:20]
    n_members = len(members)
    n_books = len(books)

    return render_to_response(
        'portal/group.html', {
            "request": request,
            "title": "Ovo je neki naslov",
            "group": group,
            "books": books,
            "n_books": n_books,
            "your_books": yourBooks,
            "members": members,
            "n_members": n_members,
            "security": bs,
            "history": history,
            "is_member": isMember
        })
예제 #3
0
파일: views.py 프로젝트: MechanisM/Booktype
def view_group(request, groupid):
    """
    Django View. This is main Booki Groups page.

    @type request: C{django.http.HttpRequest}
    @param request: Client Request object
    @type groupid: C{string}
    @param groupid: Unique group name
    """

    try:
        group = models.BookiGroup.objects.get(url_name=groupid)
    except models.BookiGroup.DoesNotExist:
        return pages.ErrorPage(request, "errors/group_does_not_exist.html", {"group_name": groupid})
    except models.BookiGroup.MultipleObjectsReturned:
        return pages.ErrorPage(request, "errors/group_does_not_exist.html", {"group_name": groupid})
        
    books = models.Book.objects.filter(group=group, hidden=False)
    members = group.members.all()

    isMember = request.user in members
    if request.user.is_authenticated():
        yourBooks = models.Book.objects.filter(owner=request.user)
    else:
        yourBooks = []

    bs = security.getUserSecurityForGroup(request.user, group)

    history = models.BookHistory.objects.filter(book__group=group)[:20]
    n_members = len(members)
    n_books = len(books)

    return render_to_response('portal/group.html', {"request":    request, 
                                                    "title":      "Ovo je neki naslov",
                                                    "group":      group,
                                                    "books":      books,
                                                    "n_books":    n_books,
                                                    "your_books": yourBooks,
                                                    "members":    members,
                                                    "n_members": n_members,
                                                    "security":   bs,
                                                    "history": history,
                                                    "is_member":  isMember})