Example #1
0
from django.conf.urls import patterns, include, url
from django.views.generic.base import TemplateView

from posts.views import (PostsList, CreatePost, UpdatePost,
                         DeletePost, post_detail, create_comments)



urlpatterns = patterns('',
    # url(r'^(?P<username>\w+)/$', TemplateView.as_view(template_name='posts/user_posts.html'), name='user_posts'),
    # url(r'^(?P<username>\w+)/$', user_posts, name='user_posts'),

    # username Matches alphanumeric and spl char(-._+@)

    url(r'^(?P<username>[\w.@+-]+)/$', PostsList.as_view(), name='user_posts'),
    url(r'^(?P<username>\w+)/create$', CreatePost.as_view(), name='create_post'),
    url(r'^(?P<username>\w+)/update/(?P<slug>[-\w]+)$', UpdatePost.as_view(), name='update_post'),
    url(r'^(?P<username>\w+)/delete/(?P<slug>[-\w]+)$', DeletePost.as_view(), name='delete_post'),
    url(r'^(?P<pk>[0-9]+)/(?P<slug>[-\w]+)/$', post_detail, name='post_detail'),

    #comment
    url(r'^(?P<pk>[0-9]+)/(?P<slug>[-\w]+)/comment$', create_comments, name='create_comment'),
    url(r'^(?P<pk>[0-9]+)/(?P<slug>[-\w]+)/reply/(?P<p_id>[0-9]+)$', create_comments, name='create_reply'),


)
Example #2
0
from django.urls import path
from posts.views import CreatePost, DeletePost, PostDetail, UserPost, PostList

app_name = 'posts'

urlpatterns = [
    path('', PostList.as_view(), name='all'),
    path('new/', CreatePost.as_view(), name='create'),
    path('by/<username>/', UserPost.as_view(), name='for_user'),
    path('by/<username>/<int:pk>/', PostDetail.as_view(), name='single'),
    path('delete/<int:pk>', DeletePost.as_view(), name='delete'),
]
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"),
    url(r'^posts/(?P<pk>\d+)/post_dislike/$',
        login_required(PostDislikeAjaxView.as_view()),
        name="postdislike"),
]
Example #4
0
# coding=utf-8
from django.conf.urls import url
from posts.views import AddPostView, Posts, DeletePost, LikePost, WhoLiked, LikedPosts, \
    Profile, LeaveMessage, MyPost, SaveProfileEditions, DeleteUser, PhotoUploader, PostsFilter, Notifications, CloseAttention, About, Contacts, NotificationsAjax

urlpatterns = [
    url(ur'^$', Posts.as_view(), name='posts'),
    url(ur'^новый$', AddPostView.as_view(), name='add_post'),
    url(ur'^удалить$', DeletePost.as_view(), name='delete_post'),
    url(ur'^нравится$', LikePost.as_view(), name='like_post'),
    url(ur'^послание$', LeaveMessage.as_view(), name='leave_message'),
    url(ur'^понравилось$', WhoLiked.as_view(), name='who_liked'),
    url(ur'^закладки$', LikedPosts.as_view(), name='liked'),
    url(ur'^изменить$', SaveProfileEditions.as_view(), name='save_profile_editions'),
    url(ur'^профиль$', Profile.as_view(), name='profile'),
    url(ur'^мой$', MyPost.as_view(), name='my_posts'),
    url(ur'^профиль/удалить$', DeleteUser.as_view(), name='delete_user'),
    url(ur'^загрузить$', PhotoUploader.as_view(), name='upload_photo'),
    url(ur'^удалить_фото(?:/(?P<qquuid>\S+))?', PhotoUploader.as_view(), name='delete_photo'),
    url(ur'^фильтр$', PostsFilter.as_view(), name='posts_filter'),
    url(ur'^уведомления$', Notifications.as_view(), name='notifications'),
    url(ur'^уведомления/еще$', NotificationsAjax.as_view(), name='notifications_ajax'),
    url(ur'^предупрежден$', CloseAttention.as_view(), name='close_attention'),
]
Example #5
0
# encoding: utf-8
"""
@desc: 帖子路由
"""

from django.urls import path

from . import views
from posts.views import PostDetail, LikePost, AddPost, TopicDetail, StickyPost, DeletePost

app_name = 'posts'

urlpatterns = [
    path('detail/<int:post_id>/', PostDetail.as_view(), name='post-detail'),
    path('like/', LikePost.as_view(), name='like-post'),
    path('add/', AddPost.as_view(), name='add-post'),
    path('delete/<int:post_id>/', DeletePost.as_view(), name='post-delete'),
    # url中使用了as_view()方法后,返回的闭包会根据请求的方式到对应的视图函数中
    # 找以请求方式命名的函数进行执行。
    path('topic/detail/<int:topic_id>/',
         TopicDetail.as_view(),
         name='topic-detail'),
    path('sticky/', StickyPost.as_view()),
]
Example #6
0
from django.urls import path
from posts.views import AddComment, CommentsList, AddEditPostRank, PostRankers, AddPostView, Create, EditPost, \
    DeletePost

app_name = "posts"
urlpatterns = [
    path("add-comment/", view=AddComment.as_view(), name="add-comment"),
    path("comments-list/", view=CommentsList.as_view(), name="comments-list"),
    path("add-edit-post-rank/",
         view=AddEditPostRank.as_view(),
         name="add-edit-post-rank"),
    path("post-rankers/", view=PostRankers.as_view(), name="post-rankers"),
    path("add-post-view/", view=AddPostView.as_view(), name="add-post-view"),
    path("create/", view=Create.as_view(), name="create"),
    path("edit/", view=EditPost.as_view(), name="edit"),
    path("delete/", view=DeletePost.as_view(), name="delete"),
]
Example #7
0
from django.urls import path,re_path
from posts.views import PostList,UserPosts,PostDetail,CreatePost,DeletePost,UpdatePost,AddComment,DeleteComment

app_name='posts'

urlpatterns = [
    path('',PostList.as_view(),name='all'),
    path('new/',CreatePost.as_view(),name='create'),
    re_path(r'by/(?P<username>[-\w]+)/$',UserPosts.as_view(),name='for_user'),
    re_path(r'by/(?P<username>[-\w]+)/(?P<pk>\d+)/$',PostDetail.as_view(),name='single'),
    re_path(r'delete/(?P<pk>\d+)/$',DeletePost.as_view(),name='delete'),
    re_path(r'edit/(?P<pk>\d+)/$',UpdatePost.as_view(),name='edit'),
    re_path(r'by/(?P<username>[-\w]+)/(?P<pk>\d+)/comment/$',AddComment.as_view(),name='addcomment'),
    re_path(r'by/(?P<username>[-\w]+)/(?P<postpk>\d+)/comment/(?P<pk>\d+)/delete/$',DeleteComment.as_view(),name='deletecomment'),
]