コード例 #1
0
    def test_root_url_resolves_to_home_page_view(self):
        request = self.factory.get('/')
        request.user = self.user

        with self.assertTemplateUsed(template_name='posts.html'):
            response = PostView.as_view()(request)
            self.assertEqual(response.status_code, 200)
コード例 #2
0
 def test_home_page_returns_correct_html(self):
     request = self.factory.get('/')
     request.user = self.user
     view = PostView.as_view(template_name='posts.html')
     with self.assertTemplateUsed(template_name='posts.html'):
         response = view(request, name='posts')
         html = response.content.decode('utf8')
         expected_html = render_to_string('posts.html')
         self.assertTrue(html.strip().startswith('<!DOCTYPE html>'))
         self.assertIn('<title>Posts | Django Creek</title>', html)
         self.assertTrue(html.strip().endswith('</html>'))
コード例 #3
0
ファイル: urls.py プロジェクト: idie11/instagram
from users.views import UserView, FavoritesView, UserFavoritesView
from django.urls.conf import include
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_auth.views import LoginView
from rest_auth.registration.views import RegisterView
from posts.views import PostView, CommentView, LikesView, PostLikesView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('signin', LoginView.as_view(), name='rest_login'),
    path('signup', RegisterView.as_view(), name='rest_register'),
    path('', PostView.as_view({'get': 'list'})),
    path('silk/', include('silk.urls', namespace='silk')),
    path('posts/create', PostView.as_view({'post': 'create'})),
    path('posts/<int:pk>/likes', PostLikesView.as_view()),
    path('user/<int:pk>', UserView.as_view({
        'get': 'retrieve',
        'put': 'update'
    })),
    path('user/<int:pk>/favorites', UserFavoritesView.as_view()),
    path('comment/', CommentView.as_view({'post': 'create'})),
    path('comment/<int:pk>',
         CommentView.as_view({
             'put': 'update',
             'delete': 'destroy'
         })),
    path('like/<int:pk>', LikesView.as_view()),
    path('favorites/<int:pk>', FavoritesView.as_view()),
コード例 #4
0
ファイル: urls.py プロジェクト: vialekis/apiblog
    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 posts.views import PostsListView, json_list_published_posts, CategoryListView, CategoryPostsListView, CategoryPostsListView, PostView
from posts.api import views as api_views
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', PostsListView.as_view()),
    path('post/<int:pk>', PostView.as_view(), name="postdetail"),
    path("<category>", CategoryPostsListView, name="categoryPosts"),
    path('categories/', CategoryListView.as_view(), name="categories"),
    # path('api/posts/', json_list_published_posts),
    path("api/posts/", api_views.PostListView.as_view(), name="api_post_list"),
    path("api/posts/<pk>",
         api_views.PostDetailView.as_view(),
         name="api_post_detail"),
    path("api/categories/",
         api_views.CategoryListView.as_view(),
         name="api_category_list"),
    path("api/categories/<category>",
         api_views.CategoryPostDetailView.as_view(),
         name="api_categorypost_list"),
]
コード例 #5
0
from django.conf.urls import url

from core.views import test
from posts.views import PostView

urlpatterns = [
    url(r'^$', test, name="all_posts"),
    url(r'^(?P<pk>\d+)/$', PostView.as_view(), name="show_post_by_id"),
]
コード例 #6
0
from posts.views import BlogView, PostView, BlogsList, CreateBlog, UpdateBlog, CreatePost, UpdatePost, DeleteBlog, \
    DeletePost, PostLikeAjaxView, PostCommentsView, PostDislikeAjaxView
from django.contrib.auth.decorators import login_required

urlpatterns = [
    url(r'^blogs/$', BlogsList.as_view(), name="allblogs"),
    url(r'^blogs/blogs_mini/$', BlogsList.as_view(), name="allblogsmini"),
    url(r'^blogs/(?P<pk>\d+)/$', BlogView.as_view(), name="blog"),
    url(r'^blogs/(?P<pk>\d+)/delete/$',
        DeleteBlog.as_view(),
        name="deleteblog"),
    url(r'^blogs/new_blog/$',
        login_required(CreateBlog.as_view()),
        name="createblog"),
    url(r'^blogs/(?P<pk>\d+)/edit/$', UpdateBlog.as_view(), name="editblog"),
    url(r'^posts/(?P<pk>\d+)/$', PostView.as_view(), name="post"),
    url(r'^posts/(?P<pk>\d+)/comments/$',
        PostCommentsView.as_view(),
        name="postcomments"),
    url(r'^posts/(?P<pk>\d+)/delete/$',
        DeletePost.as_view(),
        name="deletepost"),
    url(r'^(?P<pk>\d+)/posts/new_post/$',
        login_required(CreatePost.as_view()),
        name="createpost"),
    url(r'^posts/(?P<pk>\d+)/edit/$',
        login_required(UpdatePost.as_view()),
        name="editpost"),
    url(r'^posts/(?P<pk>\d+)/post_like/$',
        login_required(PostLikeAjaxView.as_view()),
        name="postlike"),
コード例 #7
0
ファイル: urls.py プロジェクト: QAM/TFT_project
from django.conf.urls import patterns, url
from posts.views import PostView,ShowPost,PostDetail
from posts import views

urlpatterns = patterns('',
	url(r'^$', PostView.as_view(success_url= "/posts" ), name="create" ),
	url(r'^list/$', ShowPost.as_view()),
	url(r'^list/(?P<pk>\d+)/detail/$', PostDetail.as_view())
 )
コード例 #8
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from posts.views import PostView
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'tft.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
	url(r'^results/$', views.ShowView),
	url(r'^accounts/', include('userena.urls')),
	url(r'^admin/', include(admin.site.urls)),
	url(r'^posts/$', PostView.as_view()),
	url(r'^discuss/$', ShowPost.as_view())

)
コード例 #9
0
from posts.views import PostView, CatList, CatDetail
from django.urls import path  

app_name = 'posts'  
urlpatterns = [  
    # path('', PostList.as_view(), name='post-list'),  
    # path('<int:pk>', PostDetail.as_view(), name='post-detail'), 
    path('categories/', CatList.as_view(), name='post-list'),  
    path('categories/<int:pk>', CatDetail.as_view(), name='post-detail'), 
    path('', PostView.as_view(), name='post-list'),  
    path('<int:pk>', PostView.as_view(), name='post-detail'), 
]
コード例 #10
0
from django.conf.urls import url

from posts.views import PostView, PostsByCat, Like

urlpatterns = [
    url(r'^post/(?P<post_id>[\d]+)/', PostView.as_view(), name="certain_post"),
    url(r'^like/', Like.as_view(), name="like"),
    url(r'^category/(?P<category_id>[\d]+)/',
        PostsByCat.as_view(),
        name="certain_category"),
]
コード例 #11
0
from django.conf.urls import url, include
from rest_framework.routers import DefaultRouter
from posts.api import PostViewSet
from posts.views import HomeView, PostView, CreatePostView

router = DefaultRouter()
router.register('api/1.0/post', PostViewSet, base_name='api_post')

urlpatterns = [

    # WEB URLS
    url(r'^$', HomeView.as_view(), name='posts_home'),
    url(r'^blogs/(?P<pk>[0-9]+)/(?P<id>[0-9]+)$',
        PostView.as_view(),
        name='posts_post_detail'),
    url(r'^create_post$', CreatePostView.as_view(), name='posts_post_create'),

    # API URLS
    url(r'', include(router.urls))
]
コード例 #12
0
ファイル: urls.py プロジェクト: adolabsnet/djangooru
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

from posts.views import PostView, DetailView, TagView, IndexView, upload_view, edit, delete_view

urlpatterns = [
    path('', PostView.as_view(), name="posts"),
    path('upload', upload_view, name='upload'),
    path('edit', edit, name="edit"),
    path('delete', delete_view, name="delete"),
    path('<post_id>', DetailView, name="post_detail"),
]
コード例 #13
0
ファイル: urls.py プロジェクト: mutkan/soundcollective
from django.conf.urls import patterns
from django.conf.urls import include
from django.conf.urls import url
from django.contrib.auth.decorators import login_required

from posts.views import (CreatePostView, EditPostView, PostListView, PostMineView,
    PostView, attend_post_view)

urlpatterns = patterns('',

    url(r'^$',
        PostListView.as_view(),
        name='posts_list'),
    url(r'^create/$',
        login_required(CreatePostView.as_view()),
        name='posts_create'),
    url(r'^mine/$',
        login_required(PostMineView.as_view()),
        name='posts_mine'),
    url(r'^(?P<post>\d+)/$',
        PostView.as_view(),
        name='posts_post'),
    url(r'^(?P<post>\d+)/edit/$',
        EditPostView.as_view(),
        name='posts_edit'),
    url(r'^(?P<post>\d+)/attend/$',
        login_required(attend_post_view),
        name='posts_attend'),
)
コード例 #14
0
ファイル: urls.py プロジェクト: irvanjit/uwcollab
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', LandingView.as_view(), name='login'),
    url(r'^logout/?$', logout, name='logout'),
    url(r'^home/?$', HomeView.as_view(), name='home'),
    url(r'^register/?$', RegistrationView.as_view(), name='register'),
    url("", include('django_socketio.urls')),
    url("", include("chat.urls")),
    url(r'^stats/?$', stats, name='stats'),


    #post urls
    url(r'^posts/(?P<post_id>\d+)/?$', PostView.as_view(), name='post_view')

)

# Path to static assets
media_root = {'document_root': settings.MEDIA_ROOT}
urlpatterns += patterns('',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', media_root),
    # (r'^accounts/login/$', 'django_cas.views.login'),
    # (r'^accounts/logout/$', 'django_cas.views.logout'),
)

urlpatterns += staticfiles_urlpatterns()

コード例 #15
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required

from comments.forms import CreateCommentForm
from core.views import test
from posts.views import PostView, CreatePost

urlpatterns = [
    url(r'^$', login_required(test), name="all_posts"),
    # todo : make comment creation correct
    url(r'^(?P<pk>\d+)/$', login_required(PostView.as_view()),
        kwargs={'form': CreateCommentForm()},
        name="show_post_by_id"),
    url(r'^create_post', login_required(CreatePost.as_view()),
        name="create_post")
]
コード例 #16
0
ファイル: urls.py プロジェクト: Wardomir/blog
    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 rest_framework import routers
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from posts.views import PostView, LikeView, LikeStatisticsView
from user_management.views import UserViewSet, HelloView

router = routers.DefaultRouter()
router.register('users', UserViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('api/login/', TokenObtainPairView.as_view(),
         name='token_obtain_pair'),
    path('api/token/refresh/',
         TokenRefreshView.as_view(),
         name='token_refresh'),
    path('posts/', PostView.as_view(), name='posts'),
    path('posts/<int:pk>', PostView.as_view()),
    path('like/', LikeView.as_view()),
    path('likestats/', LikeStatisticsView.as_view()),
    path('hello', HelloView.as_view(), name='hello_view'),
]
コード例 #17
0
from django.contrib import admin
from django.urls import path
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from posts.views import PostView, PostListView

urlpatterns = [
    path('admin/', admin.site.urls),
    # Path to obtain a new access and refresh token
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    # Submit your refresh token to this path to obtain a new access token
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    # Return 'Mods' model objects
    path('posts/', PostView.as_view(), name='post_view'),
    path('posts/list/', PostListView.as_view(), name='post_list_view'),
]
コード例 #18
0
from django.urls import path, include
from posts.views import (
                        PostView,
                        post_list,
                        post_detail,
                        PostMixinView,
                        PostGenericView,
                        PostGenericDestroyView,
                        PostGenericDetailView,
                        OwnerDetailView,
                        CommentDetailView
                        )


urlpatterns = [
    path('admin/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls')),
    path('api/', include('posts.urls')),

    path('api/post-generic/', PostGenericView.as_view(), name="post-list"),
    path('api/post-generic/owner/<int:pk>/', OwnerDetailView.as_view(), name="owner-detail"),
    path('api/post-generic/comment/<int:pk>/', CommentDetailView.as_view(), name="comment-detail"),
    path('api/post-generic/detail/<int:pk>/', PostGenericDetailView.as_view(), name="post-detail"),
    path('api/post-generic/destroy/<int:pk>/', PostGenericDestroyView.as_view(), name="post-destroy"),
    path('api/post-mixin/', PostMixinView.as_view(), name="post-list"),
    path('api/posts/', PostView.as_view(), name="post-list"),
    path('api/posts/<int:pk>', PostView.as_view(), name="post-detail"),
    path('api/post-list/', post_list, name="post-list"),
    path('api/posts/<int:pk>', post_detail, name="post-detail"),
]
コード例 #19
0
from django.conf.urls import url

from posts.views import PostView, EditPostView

urlpatterns = [
    url(r'^edit/(?P<id>[a-zA-Z0-9-]+)', EditPostView.as_view()),
    url(r'^', PostView.as_view()),
]
コード例 #20
0
ファイル: urls.py プロジェクト: khmaker/hw05_final
    PostUpdateView,
    PostView,
    ProfileFollowView,
    ProfileUnfollowView,
    ProfileView,
)

urlpatterns = [
    path('', IndexView.as_view(), name='index'),
    path('group/<slug:slug>/', GroupView.as_view(), name='group_posts'),
    path('new/', CreatePostView.as_view(), name='new_post'),
    path('follow/', FollowIndexView.as_view(), name='follow_index'),
    path('<str:username>/follow/',
         ProfileFollowView.as_view(),
         name='profile_follow'),
    path('<str:username>/unfollow/',
         ProfileUnfollowView.as_view(),
         name='profile_unfollow'),
    path('<str:username>/', ProfileView.as_view(), name='profile'),
    path('<str:username>/<int:post_id>/', PostView.as_view(), name='post'),
    path('<str:username>/<int:post_id>/edit/',
         PostUpdateView.as_view(),
         name='post_edit'),
    path('<str:username>/<int:post_id>/delete/',
         PostDeleteView.as_view(),
         name='post_delete'),
    path('<str:username>/<int:post_id>/comment',
         AddCommentView.as_view(),
         name='add_comment'),
]
コード例 #21
0
    # Examples:
    # url(r'^$', 'lunchify.views.home', name='home'),
    # url(r'^lunchify/', include('lunchify.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', LandingView.as_view(), name='login'),
    url(r'^logout/?$', logout, name='logout'),
    url(r'^home/?$', HomeView.as_view(), name='home'),
    url(r'^register/?$', RegistrationView.as_view(), name='register'),
    url("", include('django_socketio.urls')),
    url("", include("chat.urls")),
    url(r'^stats/?$', stats, name='stats'),

    #post urls
    url(r'^posts/(?P<post_id>\d+)/?$', PostView.as_view(), name='post_view'))

# Path to static assets
media_root = {'document_root': settings.MEDIA_ROOT}
urlpatterns += patterns(
    '',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', media_root),
    # (r'^accounts/login/$', 'django_cas.views.login'),
    # (r'^accounts/logout/$', 'django_cas.views.logout'),
)

urlpatterns += staticfiles_urlpatterns()
コード例 #22
0
ファイル: urls.py プロジェクト: ovr1/blok_Test
"""blog_Test URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/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 posts.views import PostView, json_list_published_posts
from posts.api.views import PostListView, PostDetailView, CategoryPostView, CategoryDetailView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', PostView.as_view()),
    # path('api/posts/', json_list_published_posts),
    path('api/posts/', PostListView.as_view()),
    path('api/posts/<int:pk>', PostDetailView.as_view()),
    path('api/posts/category/', CategoryPostView.as_view()),
    path('api/posts/category/<int:pk>', CategoryDetailView.as_view()),
]
コード例 #23
0
ファイル: urls.py プロジェクト: ericleong/ideashout
 url(r'^admin/', include(admin.site.urls)),
 
 # Posts
 url(r'^$', ListView.as_view(model=Post, queryset=Post.objects.order_by("-created"), context_object_name="posts",), name="home"),
 url(r'^events$', ListView.as_view(model=Post, queryset=Post.objects.filter(start_time__isnull=False, start_time__gte=now()).order_by("start_time"), 
                             template_name="posts/event_list.html", context_object_name="posts",), name="events"),
 url(r'^events/map$', MapView.as_view(), name="events-map"),
 url(r'^events/map/(?P<year>\d{4})/(?P<month>\d{1,2}?)/$', MapView.as_view(), name="events-map"),
 url(r'^events/(?P<year>\d{4})/$', YearView.as_view(), name="events-year"),
 url(r'^events/(?P<year>\d{4})/(?P<month>\d{1,2}?)/$', MonthView.as_view(), name="events-month"),
 url(r'^events/(?P<year>\d{4})/(?P<month>\d{1,2}?)/(?P<day>\d{1,2}?)/$', DayView.as_view(), name="events-day"),
 url(r'^links$', ListView.as_view(model=Post, queryset=Post.objects.filter(start_time__isnull=True, link__isnull=False).order_by("-created"), 
                             template_name="posts/link_list.html", context_object_name="posts",), name="links"),
 url(r'^ideas$', ListView.as_view(model=Post, queryset=Post.objects.filter(start_time__isnull=True, link__exact="").order_by("-responses__created"), 
                             template_name="posts/idea_list.html", context_object_name="posts",), name="ideas"), 
 url(r'^post/(?P<slug>.+)/$', PostView.as_view(model=Post, ), name="post"),
 #url(r'^post/(?P<slug>.+)/$', PostView.as_view(model=Post, )),
 
 url(r'^post/$', RedirectView.as_view(url="create/link")),
 url(r'^create/idea$', CreateIdeaView.as_view(success_url="/"), name="create-idea"),
 url(r'^create/link$', CreateLinkView.as_view(success_url="/"), name="create-link"),
 url(r'^create/event$', CreateEventView.as_view(success_url="/"), name="create-event"),
 
 # Tags
 url(r'^tag/(?P<tag>.+)/$', TagView.as_view(model=Post, context_object_name="posts",), name="tag"),
 url(r'^tag/(?P<tag>.+)/events$', TagEventView.as_view(model=Post, context_object_name="posts"), name="tag-events"),
 
 # Locations
 url(r'^location/(?P<slug>.+)/$', LocationView.as_view(), name="location"),
 
 # Accounts