Exemplo n.º 1
0
def render_create_book(request):
    "Show the create book form"
    # Check permissions
    if not AuthManager.has_permission(request, 'create_book'):
        raise PermissionDenied

    # Handle the request if we're allowed to
    if request.method == 'POST':
        return create_book_action(request)
    else:
        user = AuthManager.get_current_user(request)
        context = Context({"user":user})
        tmpl =  os.path.join(os.path.dirname(__file__), 'template', 'create_book.html')
        response = HttpResponse()
        response.write(render_to_string(request, tmpl, context))
        return response
Exemplo n.º 2
0
def render_create_book(request):
    "Show the create book form"
    # Check permissions
    if not AuthManager.has_permission(request, 'create_book'):
        raise PermissionDenied

    # Handle the request if we're allowed to
    if request.method == 'POST':
        return create_book_action(request)
    else:
        user = AuthManager.get_current_user(request)
        context = Context({"user": user})
        tmpl = os.path.join(os.path.dirname(__file__), 'template',
                            'create_book.html')
        response = HttpResponse()
        response.write(render_to_string(request, tmpl, context))
        return response
Exemplo n.º 3
0
def render_create_listing(request, error = None):
    "Show the create book form"
    # Check permissions
    if not AuthManager.has_permission(request, 'list_book'):
        raise PermissionDenied

    # Handle the request if we're allowed to
    if request.method == 'POST' and error is None:
        return list_book_action(request)
    else:
        user = AuthManager.get_current_user(request)
        context = Context({
                            "error": error,
                            "user": user,
                            "books": lib.BOOK.list_all_books()
                            })
        tmpl =  os.path.join(os.path.dirname(__file__), 'template', 'list_book.html')
        response = HttpResponse()
        response.write(render_to_string(request, tmpl, context))
        return response
Exemplo n.º 4
0
def render_create_listing(request, error=None):
    "Show the create book form"
    # Check permissions
    if not AuthManager.has_permission(request, 'list_book'):
        raise PermissionDenied

    # Handle the request if we're allowed to
    if request.method == 'POST' and error is None:
        return list_book_action(request)
    else:
        user = AuthManager.get_current_user(request)
        context = Context({
            "error": error,
            "user": user,
            "books": lib.BOOK.list_all_books()
        })
        tmpl = os.path.join(os.path.dirname(__file__), 'template',
                            'list_book.html')
        response = HttpResponse()
        response.write(render_to_string(request, tmpl, context))
        return response