Exemplo n.º 1
0
    def test_delete(self):
        book = mixer.blend('books.Book', name='Two Scoops Of DJANGO')
        req = RequestFactory().post('/books/two_scoops_of_django/delete')
        req.user = mixer.blend(User)
        resp = BookDeleteView.as_view()(req, slug=book.slug)

        assert Book.objects.filter(slug=book.slug).exists() == False
        assert resp.url + '/' == reverse(
            'books:list'), 'Should have deleted the book'
Exemplo n.º 2
0
# this is provided by django for login and logout
from django.contrib.auth import views as auth_views

# for adding the roots for media url
from django.conf import settings
from django.conf.urls.static import static

from books.views import BookListView, BookDetailView, BookCreateView, BookUpdateView, BookDeleteView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', BookListView.as_view(), name='home'),
    path('book/<int:pk>', BookDetailView.as_view(), name='book-detail'),
    #path('book/<int:pk>', book_detail, name='book-detail'),
    path('book/<int:pk>/update', BookUpdateView.as_view(), name='book-update'),
    path('book/<int:pk>/delete', BookDeleteView.as_view(), name='book-delete'),
    path('book/new/', BookCreateView.as_view(), name='book-create'),
    #path('', user_views.home, name='home'),
    path('register/', user_views.register, name='register'),
    path('login/',
         auth_views.LoginView.as_view(template_name='login.html'),
         name='login'),
    path('logout/',
         auth_views.LogoutView.as_view(template_name='logout.html'),
         name='logout'),
    path('profile/', user_views.profile, name='profile'),
    path('search/', books_views.search, name='search'),
    path('favorite/<int:pk>', books_views.favorite_book, name='favorite_book'),
    path('removefavorite/<int:pk>',
         books_views.remove_favorite_book,
         name='remove_favorite_book'),
Exemplo n.º 3
0
from books.views import (
    BookListView,
    BookDetailView,
    BookCreateView,
    BookUpdateView,
    BookDeleteView,
    SearchResultsView,
    ReviewCreateView,
    ReviewUpdateView,
    ReviewDeleteView,
)

urlpatterns = [
    path('', BookListView.as_view(), name='book_list'),
    path('<uuid:pk>/', BookDetailView.as_view(), name='book_detail'),
    path('create/', BookCreateView.as_view(), name='book_create'),
    path('<uuid:pk>/edit', BookUpdateView.as_view(), name='book_update_view'),
    path('<uuid:pk>/delete/',
         BookDeleteView.as_view(),
         name='book_delete_view'),
    path('search/', SearchResultsView.as_view(), name='search_results'),
    path('<uuid:pk>/review/', ReviewCreateView.as_view(), name='book_review'),
    path('<uuid:book_pk>/review/<uuid:pk>/update/',
         ReviewUpdateView.as_view(),
         name='book_review_edit'),
    path('<uuid:book_pk>/review/<uuid:pk>/delete/',
         ReviewDeleteView.as_view(),
         name='book_review_delete'),
]
Exemplo n.º 4
0
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path

from books.views import (
    BookCreateView,
    BookDeleteView,
    BookListView,
    BookSearchResultsImportView,
    BookSearchView,
    BookUpdateView,
    IndexView,
    RESTBookListView,
)

urlpatterns = [
    path("", IndexView.as_view(), name="index"),
    path("api/books/", RESTBookListView.as_view(), name="rest_book_list"),
    path("books/", BookListView.as_view(), name="book_list"),
    path("books/add/", BookCreateView.as_view(), name="book_create"),
    path("books/<pk>/update/", BookUpdateView.as_view(), name="book_update"),
    path("books/<pk>/delete/", BookDeleteView.as_view(), name="book_delete"),
    path("books/search/", BookSearchView.as_view(), name="book_search"),
    path(
        "books/search-result/<isbn>/add/",
        BookSearchResultsImportView.as_view(),
        name="book_search_results_import",
    ),
]
Exemplo n.º 5
0
"""crudCBV URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/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, include
from books.views import BookListView, BookCreateView, BookDetailView, BookUpdateView, BookDeleteView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', BookListView.as_view(), name='home'),
    path('create/', BookCreateView.as_view(), name='create'),
    path('detail/<int:pk>', BookDetailView.as_view(), name='detail'),
    path('update/<int:pk>', BookUpdateView.as_view(), name='update'),
    path('delete/<int:pk>', BookDeleteView.as_view(), name='delete'),
]
Exemplo n.º 6
0
from django.urls import path
from books.views import BookListView, BookDetailView, BookDeleteView


urlpatterns = [
    path('', BookListView.as_view(), name="books_list"),
    path('detail/<int:pk>', BookDetailView.as_view(), name="book_detail"),
    path('delete/<int:pk>', BookDeleteView.as_view(), name="book_delete"),
]
Exemplo n.º 7
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'),
]
Exemplo n.º 8
0
from django.urls import path

from books.views import BookCreateView, CategoriesListView, BookListView, CategoryCreateView, \
    CategoryUpdateView, BookUpdateView, CategoryDeleteView, BookDeleteView

urlpatterns = [
    path('categories/', CategoriesListView.as_view()),
    path('categories/create/', CategoryCreateView.as_view()),
    path('categories/update/<int:pk>/', CategoryUpdateView.as_view()),
    path('categories/delete/<int:pk>/', CategoryDeleteView.as_view()),
    path('create/', BookCreateView.as_view()),
    path('update/<int:pk>/', BookUpdateView.as_view()),
    path('delete/<int:pk>/', BookDeleteView.as_view()),
    path('', BookListView.as_view()),
]
Exemplo n.º 9
0
    path('update-series/<int:series_id>',
         book_view.book_update_series,
         name='update-series'),
    path('delete-series/<int:series_id>',
         book_view.book_delete_series,
         name='delete-series'),
    path('create-genre/', book_view.book_create_genre, name='create-genre'),
    path('update-genre/<int:genre_id>',
         book_view.book_update_genre,
         name='update-genre'),
    path('delete-genre/<int:genre_id>',
         book_view.book_delete_genre,
         name='delete-genre'),
    path('create-publisher/',
         book_view.book_create_publisher,
         name='create-publisher'),
    path('update-publisher/<int:publisher_id>',
         book_view.book_update_publisher,
         name='update-publisher'),
    path('delete-publisher/<int:publisher_id>',
         book_view.book_delete_publisher,
         name='delete-publisher'),
    path('', BookListView.as_view(), name='books-view'),
    path('authors-view/', AuthorListView.as_view(), name='authors-view'),
    path('book-view/<int:pk>/', BookDetailView.as_view(), name='book-view'),
    path('book-create-view/', BookCreateView.as_view(), name='book_create'),
    path('book-update/<int:pk>/', BookUpdateView.as_view(),
         name='book_update'),
    path('book-delete/<int:pk>/', BookDeleteView.as_view(),
         name='book_delete'),
]