def test_read_mark(self): request = self.factory.post(self.path, { 'read': 'Read', 'post_id': self.post.id, }) request.user = self.user response = PostsView().post(request=request) assert response.status_code == 302 assert response.url == reverse('blog:posts_view') assert self.user not in self.post.read_by.all() self.subscription = mixer.blend('blog.Subscription', author=self.author_user, subscriber=self.user) response = PostsView().post(request=request) assert response.status_code == 302 assert response.url == reverse('blog:posts_view') assert self.user in self.post.read_by.all()
# -*- coding: utf-8 -*- from django.conf.urls import url from blog.views import PostsView urlpatterns = [url(r"^posts/$", PostsView.as_view(), name="posts")]
from zoomit.urls import router router.register(r'posts', PostViewSet) router.register(r'comments', CommentViewSet) router.register(r'categories', CategoryViewSet) router.register(r'post_settings', PostSettingViewSet) # router.register(r'my-model/', ExampleView) urlpatterns = [ path('posts/<slug:slug>/', SinglePost.as_view(), name='single_post'), path('categories/<slug:slug>/', CategoryPosts.as_view(), name="category_posts"), path('categories/', Categories.as_view(), name='show_categories'), path('', main_page, name="main_page"), path('like_comment/', comment_like, name='like_comment'), path('posts/', PostsView.as_view(), name='posts_archive'), path('comment/', create_comment, name='comment_create'), path('authors/<slug:slug>/', AuthorsPosts.as_view(), name="authors_posts"), path('latest/', ArchiveIndexView.as_view(model=Post, date_field='create_at', template_name='blog/posts.html', context_object_name='post_list'), name="latest_posts"), path('monthly/<int:year>/<int:month>/', ArticleMonthArchiveView.as_view(month_format='%m'), name="archive_month_numeric"), path('<int:year>/week/<int:week>/', ArticleWeekArchiveView.as_view(), name="archive_week"), path('show_month/', ShowMonthly.as_view(), name='show_month'),
from django.urls import path from blog.views import (PostView, PostsView, CategoryView, AddPostView, EditPostView, add_comment, like_comment, get_comments) from .api import PostViewSet, CategoryViewSet, CommentViewSet from core.urls import router router.register(r'post_viewset', PostViewSet) router.register(r'category_viewset', CategoryViewSet) router.register(r'comment_viewset', CommentViewSet) app_name = 'blog' urlpatterns = [ path('', PostsView.as_view(), name='home'), path('post/<slug:slug>/', PostView.as_view(), name='post'), path('category/<str:cat>/', CategoryView.as_view(), name='category'), path('add_post/', AddPostView.as_view(), name='add_post'), path('edit_post/<slug:slug>/', EditPostView.as_view(), name='edit_post'), path('add_comment/', add_comment, name='add_comment'), path('comment_like/', like_comment, name='like_comment'), path('get_comments/<slug:slug>/', get_comments, name='comments'), ]
from settings import MEDIA_ROOT from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() from blog.views import PostsView, PostDetailView, EditPostView, CreatePostView, LoginView urlpatterns = patterns('', url(r"^admin/doc/", include("django.contrib.admindocs.urls")), url(r"^admin/", include(admin.site.urls)), url(r"^static/(?P<path>.*)$", "django.views.static.serve", { "document_root": MEDIA_ROOT }), url(r"^$", PostsView.as_view(), name='main'), url(r"^post/(?P<slug>[-\w]+)/$", PostDetailView.as_view(), name='post'), url(r"^update/(?P<slug>[-\w]+)/$", EditPostView.as_view(), name='update'), url(r"^create/$", CreatePostView.as_view(), name='create'), url(r'^login/$', LoginView.as_view(), name="login"), )
from django.conf.urls import url from blog.views import PostsView urlpatterns = [ url(r'^post/$', PostsView.as_view(), name='posts'), url(r'^post/(?P<pk>[0-9]+|)/$', PostsView.as_view(), name='posts'), ]
def test_get_posts_view_authenticated(self): request = self.factory.get(self.path) request.user = self.user response = PostsView().get(request=request) assert response.status_code == 200
from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from blog.views import PostsView urlpatterns = [ url(r'^$', PostsView.as_view(), name='home'), url(r'^admin/', include(admin.site.urls)), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\ + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)