Esempio n. 1
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.contrib.auth import views as auth_views
from books.views import (AuthorDetail, AuthorList, BookDetail, CreateAuthor,
						 list_books, ReviewList, review_book)

urlpatterns = [
	# Auth
    url(r'^logout/$', auth_views.logout, {'next_page': 'books'}, name='logout'),
    url(r'^login/$', auth_views.login, {'template_name': 'login.html'}, name='login'),
    
    # Admin
    url(r'^admin/', include(admin.site.urls)),
    
    # Custom
    url(r'^$', list_books, name='books'),
    url(r'^authors/$', AuthorList.as_view(), name='authors'),
    url(r'^books/(?P<pk>[-\w]+)/$', BookDetail.as_view(), name='book-detail'),
    url(r'^authors/add/$', login_required(CreateAuthor.as_view()), name='add-author'),
    url(r'^authors/(?P<pk>[-\w]+)/$', AuthorDetail.as_view(), name='author-detail'),
	url(r'^review/$', login_required(ReviewList.as_view()), name='review-books'),
	url(r'^review/(?P<pk>[-\w]+)/$', review_book, name='review-book'),
]
Esempio n. 2
0
from django.conf.urls import url
from books.views import BookList, BookDetail

urlpatterns = [
    url(
        r'^books$',
        BookList.as_view()
    ),
    url(
        r'^books/(?P<pk>[0-9]+)$',
        BookDetail.as_view()
    )
]
Esempio n. 3
0
from django.urls import path
from books.views import BooksView, BookDetail, CreateBook, UpdateBook

app_name = "books"

urlpatterns = [
    path("", BooksView.as_view(), name="books"),
    path("<int:pk>", BookDetail.as_view(), name="book"),
    path("<int:pk>/update", UpdateBook.as_view(), name="update"),
    path("create", CreateBook.as_view(), name="create"),
]
Esempio n. 4
0
from django.conf.urls import url
from books.views import BookList, BookDetail, CommentList, CommentDetail, RatingCreate

urlpatterns = [
    url(r'^books$', BookList.as_view(), name=BookList.name),
    url(r'^books/(?P<pk>[0-9]+)$', BookDetail.as_view(), name=BookDetail.name),
    url(r'^comments$', CommentList.as_view(), name=CommentList.name),
    url(r'^comments/(?P<pk>[0-9]+)$',
        CommentDetail.as_view(),
        name=CommentDetail.name),
    url(r'^ratings$', RatingCreate.as_view())
]
Esempio n. 5
0
from django.urls import path

from books.views import BooksList, BookDetail, AuthorDetail

urlpatterns = [
    path('books/', BooksList.as_view(), name='books-list'),
    path('book/<int:pk>/', BookDetail.as_view(), name='book-detail'),
    path('author/<int:pk>/', AuthorDetail.as_view(), name='author-detail'),
]
Esempio n. 6
0
			auth_views.login, 
			{'template_name': 'login.html'},
			name='login'),

	# Admin
	url(r'^admin/', include(admin.site.urls)),
	
	# Custom
	url(r'^$', 
			list_books, 
			name='books'),
	url(r'^authors/$', 
			AuthorList.as_view(), 
			name='authors'),
	url(r'^books/(?P<pk>[-\w]+)/$',
			BookDetail.as_view(),
			name='book-detail'),
	url(r'^authors/add/$',
			login_required(CreateAuthor.as_view()),
			name='add-author'),
	url(r'^authors/(?P<pk>[-\w]+)/$',
			AuthorDetail.as_view(),
			name='author-detail'),
	url(r'^review/$', 
			login_required(ReviewList.as_view()), 
			name='review-books'),
	url(r'^review/(?P<pk>[-\w]+)/$',
			review_book, 
			name='review-book'),
]
Esempio n. 7
0
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from books.views import (list_books, AuthorList, 
    AuthorDetail, BookDetail, review_book, review_books)

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^authors/$', AuthorList.as_view(), name='authors'),
    url(r'^books/(?P<pk>[\w\-]+)/$', BookDetail.as_view(), name='book'),
    url(r'^authors/add/$', CreateAuthor.as_view(), name='add-author'),
    url(r'^authors/(?P<pk>[\w\-]+)/$', AuthorDetail.as_view(), name='author'),
    url(r'^$', list_books, name='books')
    url(r'^review/$', review_books, name='review-books'),
    url(r'^review/(?P<pk>[\w\-]+)/$', review_book, name='review_book'),
]


if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]
Esempio n. 8
0
from django.contrib.auth.decorators import login_required
from django.urls import path

from books.views import books_list, book_details, BookList, BookDetail, book_comment, books_to_excel

app_name = "books"
urlpatterns = [
    # path("", BookList.as_view(), name="list"),
    path("", books_list, name="list"),
    path("<int:pk>", book_details, name="details"),
    path("generic/<int:pk>",
         login_required(BookDetail.as_view()),
         name="details_generic"),
    path("<int:pk>/comment", book_comment, name='comment'),
    path("report/", books_to_excel, name='report'),
]
Esempio n. 9
0
"""books URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

from books.views import BookViewSet, BookDetail, BookDelete, BookUpdate, BookSearch

urlpatterns = [

    path(r'list/', BookViewSet.as_view({'get': 'list'}), name='book_lists'),
    path(r'<int:id>/detail', BookDetail.as_view(), name='detail'),
    path(r'<int:id>/delete/', BookDelete.as_view(), name='delete'),
    path(r'<int:id>/edit/', BookUpdate.as_view(), name='update'),
    path(r'search/', BookSearch.as_view(), name='search'),
]
Esempio n. 10
0
    name="update-book"),
    url(r"^publisher/book/edit/(?P<pk>\d+)/$", permission_required('books.add_book')(ShowMyBook.as_view()), 
    name="my-books-show"),
    url(r"^publisher/page/preview/$", permission_required('books.add_book')(PagePreview.as_view()), 
    name="page-preview"),
    url(r"^publisher/page/edit/$", permission_required('books.add_book')(EditPage.as_view()), 
    name="edit-page"),
    url(r"^publisher/page/edit/(?P<pk>\d+)/$", permission_required('books.add_book')(EditPageContent.as_view()), 
    name="edit-page-content"),
    url(r"^publisher/author/create/$", permission_required('books.add_book')(CreateAuthor.as_view()), 
    name="create-author"),
)

# reading through books, rating etc...
urlpatterns += patterns("", 
    url(r"^book/(?P<pk>\d+)/$", BookDetail.as_view(),
    name="book-detail"),
    url(r"^book/(?P<pk>\d+)/toc/$", login_required(BookTOC.as_view()),
    name="book-toc"),
    url(r"^book/(?P<pk>\d+)/read/$", login_required(ReadPage.as_view()),
    name="read-page"),
    url(r"^book/(?P<object_id>\d+)/rate/(?P<score>\d+)/$", AddRating.as_view(), 
    name="book-rate"),
)

# downloading
urlpatterns += patterns("",
    url(r"download/(?P<pk>\d+)/$", login_required(DownloadPage.as_view()),
    name='download-page'),
    url(r"download/book/(?P<pk>\d+)/$", login_required(DownloadBook.as_view()),
    name='download-book'),
Esempio n. 11
0
from django.urls import path

from books.views import BookList, BookDetail, BookCreateView, BookUpdateView, BookDeleteView

urlpatterns = [
    path('', BookList.as_view(), name='book_list_view'),
    path('<int:pk>', BookDetail.as_view(), name='book_detail_view'),
    path('create/', BookCreateView.as_view(), name="book_create_view"),
    path('update/<int:pk>', BookUpdateView.as_view(), name="book_update_view"),
    path('delete/<int:pk>', BookDeleteView.as_view(), name='book_delete_view'),
]
Esempio n. 12
0
from django.conf.urls import url
from books.views import BookList, BookDetail

urlpatterns = [
    url(r'^books$', BookList.as_view()),
    url(r'^books/(?P<pk>[0-9]+)$', BookDetail.as_view())
]
Esempio n. 13
0
from django.conf.urls import url

from books.views import BooksList
from books.views import BookDetail

urlpatterns = [
    url(r'^$', BooksList.as_view(), name='books-index'),
    url(r'^(?P<slug>[-\w]+)$', BookDetail.as_view(), name='books-details'),
]
Esempio n. 14
0
from books.views import (list_books, AuthorList, AuthorDetail, BookDetail,
                         CreateAuthor, review_book, ReviewList)

urlpatterns = [
    # Auth
    # path('logout/', auth_views.logout_then_login(), name="logout"),
    path('accounts/', include('django.contrib.auth.urls')),

    # Admin
    path('admin/', admin.site.urls),

    # Custom
    path('', list_books, name='books'),
    path('authors/', AuthorList.as_view(), name="authors"),
    path('books/<int:pk>', BookDetail.as_view(), name="book-detail"),
    path('authors/add',
         login_required(CreateAuthor.as_view()),
         name="add-author"),
    path('authors/<int:pk>', AuthorDetail.as_view(), name="author-detail"),
    path('review/', login_required(ReviewList.as_view()), name='review-books'),
    path('review/<int:pk>', review_book, name='review-book'),
]

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]
Esempio n. 15
0
        name="page-preview"),
    url(r"^publisher/page/edit/$",
        permission_required('books.add_book')(EditPage.as_view()),
        name="edit-page"),
    url(r"^publisher/page/edit/(?P<pk>\d+)/$",
        permission_required('books.add_book')(EditPageContent.as_view()),
        name="edit-page-content"),
    url(r"^publisher/author/create/$",
        permission_required('books.add_book')(CreateAuthor.as_view()),
        name="create-author"),
)

# reading through books, rating etc...
urlpatterns += patterns(
    "",
    url(r"^book/(?P<pk>\d+)/$", BookDetail.as_view(), name="book-detail"),
    url(r"^book/(?P<pk>\d+)/toc/$",
        login_required(BookTOC.as_view()),
        name="book-toc"),
    url(r"^book/(?P<pk>\d+)/read/$",
        login_required(ReadPage.as_view()),
        name="read-page"),
    url(r"^book/(?P<object_id>\d+)/rate/(?P<score>\d+)/$",
        AddRating.as_view(),
        name="book-rate"),
)

# downloading
urlpatterns += patterns(
    "",
    url(r"download/(?P<pk>\d+)/$",
Esempio n. 16
0
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.conf.urls import include, url
from django.contrib.auth.decorators import login_required
from django.contrib.auth import views as auth_views
from books.views import (AuthorDetail, AuthorList, BookDetail, CreateAuthor,
                         list_books, ReviewList, review_book)

urlpatterns = [
    url(r'^logout/$', auth_views.logout, {'next_page': 'books'},
        name='logout'),
    url(r'^login/$',
        auth_views.login, {'template_name': 'login.html'},
        name='login'),
    url('^admin/', admin.site.urls),
    url(r'^$', list_books, name='books'),
    url(r'^authors/$', AuthorList.as_view(), name='authors'),
    url(r'^books/(?P<pk>[-\w]+)/$', BookDetail.as_view(), name='book-detail'),
    url(r'^authors/add/$',
        login_required(CreateAuthor.as_view()),
        name='add-author'),
    url(r'^authors/(?P<pk>[-\w]+)/$',
        AuthorDetail.as_view(),
        name='author-detail'),
    url(r'^review/$',
        login_required(ReviewList.as_view()),
        name='review-books'),
    url(r'^review/(?P<pk>[-\w]+)/$', review_book, name='review-book'),
]
Esempio n. 17
0
from django.conf.urls import patterns, include, url
from django.contrib import admin

from books.views import ListView, BookDetail, Home, About

admin.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += patterns(
    '',
    url(r'^$', Home.as_view(), name='home'),
    url(r'^about/$', About.as_view(), name='About'),
    url(r'^books/$', ListView.as_view()),
    url(r'^books/erotica/$', ListView.as_view(), {'filter': 'erotica'}),
    url(r'^books/romance/$', ListView.as_view(), {'filter': 'romance'}),
    url(r'^books/(?P<slug>.+)/$', BookDetail.as_view(), name='book-detail'),
)

# For dev
# from django.conf.urls.static import static
# from django.conf import settings
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)