def test_get(self):
        BlogPost.objects.count()
        G(BlogPost,
          status=BlogPost.Status.DRAFT,
          published=None,
          fill_nullable_fields=False)
        G(BlogPost,
          status=BlogPost.Status.DRAFT,
          published=now(),
          fill_nullable_fields=False)
        G(BlogPost,
          status=BlogPost.Status.PUBLISHED,
          published=None,
          fill_nullable_fields=False)
        post = G(BlogPost,
                 status=BlogPost.Status.PUBLISHED,
                 published=now(),
                 fill_nullable_fields=False)

        rf = RequestFactory()
        request = rf.get('/blogs/')

        view = BlogPostListView()
        setattr(view, 'request', request)
        result = view.get(request)

        self.assertEqual(BlogPost.objects.count(), 4)
        self.assertListEqual(list(result.context_data['blogs']), [post])
Exemplo n.º 2
0
from django.urls import path
from blog.views import BlogPostListView, BlogPostDetailView, BlogPostFeaturedView, BlogPostCategoryView
from .models import BlogPost

urlpatterns = [
    path('', BlogPostListView.as_view()),
    path('featured', BlogPostFeaturedView.as_view()),
    path('category', BlogPostCategoryView.as_view()),
    path('<slug>', BlogPostDetailView.as_view()),
]
Exemplo n.º 3
0
from django.urls import path
from blog.views import (
    BlogPostListView,
    BlogPostDetailView,
    BlogPostFeaturedView,
    BlogPostCategoryView,
)

urlpatterns = [
    path("", BlogPostListView.as_view()),
    path("featured", BlogPostFeaturedView.as_view()),
    path("category", BlogPostCategoryView.as_view()),
    path("<slug>", BlogPostDetailView.as_view()),
]
Exemplo n.º 4
0
# coding=utf-8

from django.conf.urls import patterns, url, include
from django.views.generic import TemplateView
from blog.views import BlogPostListView, BlogPostDetailView, BlogPostListViewTag
from banner import views

urlpatterns = patterns('blog.views',
	url(r'^$', views.home, name='home'),
	url(r'^news/(?P<pk>\d+)/$', BlogPostDetailView.as_view()),
	url(r'^news/$', BlogPostListView.as_view()),
	url(r'^blog/category/(?P<category_id>\d+)/$', BlogPostListViewTag.as_view()),
	url(r'^blog_edit/(?P<blog_id>\w+)/$', 'blog_edit', name="blog_edit"),
	url(r'^contact-us/$', TemplateView.as_view(template_name="contact-us.html")),
	url(r'^contact-only/$', TemplateView.as_view(template_name="contact-only.html")),
	url(r'^motors/$', TemplateView.as_view(template_name="motors.html")),
	url(r'^motor_item/$', TemplateView.as_view(template_name="motor_item.html")),
	url(r'^motor_item/portfolio_detail/$', TemplateView.as_view(template_name="portfolio_detail.html")),
)
Exemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
  :synopsis: urls for the blog app.

.. module: blog.urls
.. author: Chris Bartlett <*****@*****.**>
"""
from django.urls import path, re_path

from blog.views import BlogPostView, BlogPostListView

urlpatterns = [
    path('', BlogPostListView.as_view(), name='list'),
    re_path(r'(?P<slug>[\w-]+)/$', BlogPostView.as_view(), name='post'),
]
Exemplo n.º 6
0
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls import include
from django.contrib import admin
from django.urls import path

from blog import views
from blog.models import BlogPost, Project
from blog.views import BlogPostDetailView, BlogPostListView, ProjectListView

urlpatterns = [
    path('grappelli/', include('grappelli.urls')),
    path('admin/', admin.site.urls),
    path('', views.home, name='home'),
    path('blog/',
         BlogPostListView.as_view(model=BlogPost,
                                  paginate_by=7,
                                  context_object_name="blog_post"),
         name='blog_post'),
    path('blog/<slug:slug>/',
         BlogPostDetailView.as_view(model=BlogPost,
                                    context_object_name="blog_post"),
         name='blog_post'),
    path('projects/',
         ProjectListView.as_view(model=Project,
                                 context_object_name="projects"),
         name='projects'),
    path('writing/', views.writing, name='writing'),
    path('about/', views.about, name='about'),
]
Exemplo n.º 7
0
    BlogPostTagListView, BlogPostDetailView, CatListView
from shop.views import OrderFormView, OrderView, NewOrderView, UpdateOrderView


admin.autodiscover()

urlpatterns = patterns('',

    url(r'^$', HomePageView.as_view()),
    #url(r'^orders/$', NewOrderView.as_view(template_name='photo_buy.html')),
    url(r'^shop/orders/(?P<id>\w+)/edit$', UpdateOrderView.as_view(template_name='photo_buy.html')),
    url(r'^shop/orders/(?P<id>\w+)/(?P<action>\w+)$', NewOrderView.as_view(template_name='order.html')),
    url(r'^shop/orders/(?P<id>\w+)/$', NewOrderView.as_view(template_name='order.html')),
    url(r'^shop/orders/$', NewOrderView.as_view(template_name='order.html')),
    url(r'^home/$', HomePageView.as_view()),
    url(r'^blog/$', BlogPostListView.as_view()),
    url(r'^blog/page(?P<page>[0-9]+)/$', BlogPostListView.as_view()),
    url(r'^blog/(?P<pk>\d+)$', BlogPostDetailView.as_view()),
    url(r'^purchase/$', SinglePageView.as_view(template_name='singlepage.html', kw='purchase')),
    url(r'^thanks/$', SinglePageView.as_view(template_name='singlepage.html', kw='thanks')),
    url(r'^fail/$', SinglePageView.as_view(template_name='singlepage.html', kw='fail')),    
    url(r'^blog/tag/(?P<tag>\D+)/$', BlogPostTagListView.as_view(template_name='blogpost_list.html')),
    url(r'^blog/posts/(?P<pk>\d+)/$', BlogPostDetailView.as_view(template_name='blogpost_detail.html')),
    url(r'^photoalbum/$', PhotoAlbumView.as_view()),
    url(r'^photoalbum/tag/(?P<tag>\D+)/$', PhotoAlbumTagView.as_view()),
    url(r'^gallery/', include('photologue.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^(?P<slug>\w+)/page/$', SinglePageSidebarView.as_view()),
    url(r'^(?P<cat>\w+)/(?P<pk>\d+)$', PostDetailView.as_view()),
    #url(r'^\w+/(?P<pk>\d+)/$', PostDetailView.as_view()),
    url(r'^(?P<cat>\S+)/list/$',  PostListView.as_view(template_name='newpost_list.html')),