コード例 #1
0
 def test_detail_permitted(self):
     request = self.factory.get('/foo/')
     request.user = self.user
     assign_perm('articles.view_article', self.user, self.article)
     view = ArticleDetailView.as_view()
     response = view(request, slug='foo-slug')
     self.assertEqual(response.status_code, 200)
コード例 #2
0
 def test_detail_permitted(self):
     request = self.factory.get('/foo/')
     request.user = self.user
     assign_perm('articles.view_article', self.user, self.article)
     view = ArticleDetailView.as_view()
     response = view(request, slug='foo-slug')
     self.assertEqual(response.status_code, 200)
コード例 #3
0
ファイル: urls.py プロジェクト: park-insci/insci
from django.conf.urls import url

from articles.views import ArticleListView, CategoryListView, CategoryDetailView, ArticleDetailView
from articles.views import article_list

urlpatterns = [

    url(r'^$', article_list,  name='home'),
    #url(r'^$', CategoryListView.as_view(), name='base_categories'),
    url(r'^category/(?P<slug>[-\w]+)/$', CategoryDetailView.as_view(), name='category-detail'),
    url(r'^(?P<category>[-\w]+)/(?P<slug>[-\w]+)/$', ArticleDetailView.as_view(), name='article-detail'),
]
コード例 #4
0
 def test_detail_denied(self):
     request = self.factory.get('/foo/')
     request.user = self.user
     view = ArticleDetailView.as_view()
     response = view(request, slug='foo-slug')
     self.assertEqual(response.status_code, 302)
コード例 #5
0
# coding: utf-8
'''
Created on 2016年5月4日

@author: likun
'''
from django.conf.urls import url
from django.conf import settings
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
from articles.views import ArticleIndexView, ArticleListView, ArticleDetailView\
, ArticleListForBigvView, ArticleJsonDataForTitleView, JudgementView, JudgementCreateView\
, JudgementDeleteView, MineJudgementListView
from common.decorators import openid_exempt


urlpatterns = (
    url(r'^list/$', ArticleIndexView.as_view(), name='article_index'),
    url(r'^judge/$', openid_exempt(JudgementView.as_view()), name='article_judge'),
    url(r'^judge/add/$', openid_exempt(JudgementCreateView.as_view()), name='article_judge_add'),
    url(r'^judge/delete/$', csrf_exempt(openid_exempt(JudgementDeleteView.as_view())), name='article_judge_delete'),
    url(r'^list/judge/$', openid_exempt(MineJudgementListView.as_view()), name='article_judge_list'),
    url(r'^list/(?P<token>\w+)/$', cache_page(settings.SITE_REDIS_TIMEOUT)(openid_exempt(ArticleListView.as_view())), name='article_list'),
    url(r'^article_jsondata_for_title/$', openid_exempt(ArticleJsonDataForTitleView.as_view()), name='article_jsondata_for_title'),
    url(r'^(?P<pk>[\w-]+)/$', ArticleDetailView.as_view(), name='article_item'),
    url(r'^bigv/list/(?P<v_id>[\w-]+)/$', cache_page(settings.SITE_REDIS_TIMEOUT)(openid_exempt(ArticleListForBigvView.as_view())), name='article_bigv_list'),
    
)
コード例 #6
0
ファイル: urls.py プロジェクト: Coder-Chandler/webwebcfxpc
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from users.views import IndexView
from articles.views import GfwArticleListView, TruthArticleListView, WumaoArticleListView, \
    SinccpArticleListView, NanJmassArticleListView, ArticleDetailView
from django.views.static import serve
from settings import MEDIA_ROOT

import xadmin

urlpatterns = [
    url(r'^sinccpxxx0-=/', admin.site.urls),
    url('^$', IndexView.as_view(), name='index'),
    url('^gfw', GfwArticleListView.as_view(), name='gfw'),
    url('^truth', TruthArticleListView.as_view(), name='truth'),
    url('^wumao', WumaoArticleListView.as_view(), name='wumao'),
    url('^sinccp', SinccpArticleListView.as_view(), name='sinccp'),
    url('^nanjmass', NanJmassArticleListView.as_view(), name='nanjmass'),
    url('^ ', ArticleDetailView.as_view(), name=''),
    url(r'^article/', include('articles.urls', namespace='article')),
    url(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}),
    #url(r'^static/(?P<path>.*)$', serve, {'document_root': STATIC_ROOT}),
    url(r'ueditor/', include("DjangoUeditor.urls")),
]

handler404 = 'users.views.page_not_found'
handler500 = 'users.views.page_error'
コード例 #7
0
 def test_detail_denied(self):
     request = self.factory.get('/foo/')
     request.user = self.user
     view = ArticleDetailView.as_view()
     response = view(request, slug='foo-slug')
     self.assertEqual(response.status_code, 302)
コード例 #8
0
ファイル: urls.py プロジェクト: rafrasenberg/newsbot
from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static

from articles.views import ArticleDetailView, ArticleListView

urlpatterns = [
    path('', ArticleListView.as_view(), name="article-list"),
    path('admin/', admin.site.urls),
    path('article/<int:pk>',
         ArticleDetailView.as_view(),
         name="article-detail"),
]
コード例 #9
0
ファイル: urls.py プロジェクト: jorgeluis11/proyecto
admin.autodiscover()

# URLS of the proyect, the Django urls use regular 
# expressions to find the view methods 

urlpatterns = patterns('',
    url(r'^$', 'pages.views.home', name='home'),
    url(r'^register$', register ,name='user_validation' ),
    url(r'^logout$', logout_user ,name='logout' ),

    url(r'^quotes/', quotes, name="quotes"),
    url(r'^movies/', movies, name="movies"),
    
    url(
        regex=r'^article/(?P<pk>\d+)',
        view=ArticleDetailView.as_view(),
        name='article',
    ),

    url(r'^noticias/', noticias, name="noticias") ,

    url(
        regex=r'^article/(?P<pk>\d+)',
        view=ArticleDetailView.as_view(),
        name='article',
    ),
    
    url(
        regex=r'^category/(?P<pk>\d+)',
        view=CategoryDetailView.as_view(),
        name='category',
コード例 #10
0
 def test_event_uses_view_as_class_based_view(self):
     """тест: использование представления Event как Class-Based view"""
     self.assertEqual(
         self.response.resolver_match.func.__name__,
         ArticleDetailView.as_view().__name__)
コード例 #11
0
    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.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import (
    include,
    path,
)

from articles.views import ArticleDetailView

urlpatterns = [
    path('markdownx/', include('markdownx.urls')),
    path(
        'articles/<slug:slug>/',
        ArticleDetailView.as_view(), name='article_detail'),
    path('admin/', admin.site.urls),
]

if settings.DEBUG:  # local development
    urlpatterns = urlpatterns + static(
        settings.STATIC_URL, document_root=settings.STATIC_ROOT)
コード例 #12
0
ファイル: urls.py プロジェクト: matthijsotterloo/devcharm
from articles.feeds import ArticleFeedByTag, ArticleFeedGlobal, RevisionFeed
from articles.views import ArticleDetailView, ArticleCreateView, ArticleUpdateView, ArticleListByTagView, \
    ArticleRevisionListView, ArticlePublishView, give_kudos, ArticleSetDeletedView, ArticleRevisionDiffView


urlpatterns = patterns(
    '',
    url(r'^(?P<pk>\d+)/give_kudos/$', 'articles.views.give_kudos', name='articles_give_kudos_to_article'),
    url(r'^(?P<pk>\d+)/revisions/$', ArticleRevisionListView.as_view(), name='articles_article_revision_list'),
    url(r'^(?P<pk>\d+)-(?P<slug>[-a-z0-9]+)/revisions/$', ArticleRevisionListView.as_view(),
        name='articles_article_revision_list'),
    url(r'^(?P<pk>\d+)-(?P<slug>[-a-z0-9]+)/revisions/feed/$', RevisionFeed(), name='articles_article_revision_feed'),
    url(r'^(?P<pk>\d+)/revisions/feed/$', RevisionFeed(), name='articles_article_revision_feed'),


    url(r'^(?P<pk>\d+)/revisions/(?P<revision_id>\d+)$', ArticleDetailView.as_view(),
        name='articles_article_revision_detail'),
    url(r'^(?P<pk>\d+)/diff_with/(?P<revision_id>\d+)$', ArticleRevisionDiffView.as_view(),
        name='articles_article_revision_diff'),
    url(r'^(?P<pk>\d+)/$', ArticleDetailView.as_view(), name='articles_article_detail'),
    url(r'^(?P<pk>\d+)/(?P<slug>[-a-z0-9]+)/$', ArticleDetailView.as_view(), name='articles_article_detail'),
    url(r'^(?P<pk>\d+)\.md$', ArticleDetailView.as_view(as_source=True), name='articles_article_source'),
    url(r'^edit/(?P<pk>\d+)/$', ArticleUpdateView.as_view(), name='articles_article_edit'),
    url(r'^create/$', ArticleCreateView.as_view(), name='articles_article_create'),
    url(r'^create/(?P<tag>[-a-z0-9]+)/$', ArticleCreateView.as_view(), name='articles_article_create'),
    url(r'^tag/(?P<tag>[-a-z0-9]+)/$', ArticleListByTagView.as_view(), name='articles_list_by_tag'),
    url(r'^feeds/(?P<tag>[-a-z0-9]+)/$', ArticleFeedByTag(), name='articles_feed_by_tag'),
    url(r'^feeds/$', ArticleFeedGlobal(), name='articles_feed_global'),

    url(r'^save/$', csrf_exempt(ArticleCreateView.as_view(restlike=True)), name='articles_article_rest_save'),
    url(r'^save/(?P<pk>\d+)/$',
コード例 #13
0
ファイル: urls.py プロジェクト: DanielVillalbaD/DjangoTime
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path

from articles.views import NewArticleView, ArticleDetailView, HomeView, UserView
from blog.views import BlogsView

urlpatterns = [
    path('', HomeView.as_view(), name='home'),
    path('blog/<str:username>/<int:pk>', ArticleDetailView.as_view(), name='article_detail'),
    path('admin/', admin.site.urls),
    path('blogs', BlogsView.as_view(), name='blogs'),
    path('blog/<str:username>', UserView.as_view(), name='user_blog'),
    path('article/new', NewArticleView.as_view(), name='new_article'),
    patch('blog/new', NewBlogView.as_view(), name='new_blog'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
コード例 #14
0
ファイル: urls.py プロジェクト: IvanSimeyko/blog
from django.conf.urls import patterns, url
from articles.views import ArticleDetailView, add_like, add_comment

urlpatterns = patterns('',
                       url(r'^(?P<pk>\d+)/$', ArticleDetailView.as_view(), name='article_detail'),
                       url(r'^addlike/(?P<pk>\d+)/$', add_like, name='add_like'),
                       url(r'^addcomment/(?P<pk>\d+)/$', add_comment, name='add_comment'),
                       )
コード例 #15
0
ファイル: urls.py プロジェクト: RainLeave/RainBlog
         views.article_detail,
         name='article_detail'),

    # 写文章
    path('article-create/', views.article_create, name='article_create'),

    # 删除文章
    path('article-delete/<int:id>/',
         views.article_safe_delete,
         name='article_safe_delete'),

    # 安全删除文章
    path('article-safe-delete/<int:id>/',
         views.article_safe_delete,
         name='article_safe_delete'),
    # 更新文章
    path('article-update/<int:id>/',
         views.article_update,
         name='article_update'),
    # 点赞 +1
    path('increase-likes/<int:id>/',
         views.IncreaseLikesView.as_view(),
         name='increase_likes'),
]

urlpatterns += [

    # test for DetailView
    path('<slug:slug>/', ArticleDetailView.as_view(), name='article-detail'),
]
コード例 #16
0
ファイル: urls.py プロジェクト: lazokin/Django_Newspaper
from django.urls import path

from articles.views import ArticleListView, ArticleUpdateView, ArticleDetailView, ArticleDeleteView, ArticleCreateView

urlpatterns = [
    path('<int:pk>/edit/', ArticleUpdateView.as_view(), name='article_edit'),
    path('<int:pk>/', ArticleDetailView.as_view(), name='article_detail'),
    path('<int:pk>/delete/',
         ArticleDeleteView.as_view(),
         name='article_delete'),
    path('new/', ArticleCreateView.as_view(), name='article_new'),
    path('', ArticleListView.as_view(), name='article_list')
]
コード例 #17
0
ファイル: urls.py プロジェクト: kmwenja/mucene
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

from articles.views import ArticleListView, ArticleAddView
from articles.views import ArticleDetailView
from articles.views import ArticleEditView, ArticleDeleteView
from profiles.views import UserProfileView, UserProfileEditView

from django.contrib.auth.decorators import login_required

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),

    url(r'^$', ArticleListView.as_view(), name="home"),
    url(r'^articles/add/$', login_required(ArticleAddView.as_view()), name='article_add'),
    url(r'^articles/(?P<slug>.+)/edit/$', login_required(ArticleEditView.as_view()), name='article_edit'),
    url(r'^articles/(?P<slug>.+)/delete/$', login_required(ArticleDeleteView.as_view()), name='article_delete'),
    url(r'^articles/(?P<slug>.+)/$', ArticleDetailView.as_view(), name='article_detail'),

    url(r'^login/$', "django.contrib.auth.views.login", { "template_name": "login.html" },
        name="login"),
    url(r'^logout/$', "django.contrib.auth.views.logout_then_login", name="logout"),
    url(r'^accounts/', include("registration.backends.simple.urls")),

    url(r'^users/(?P<slug>\w+)/$', UserProfileView.as_view(), name="profile"),
    url(r'^edit_profile/$', login_required(UserProfileEditView.as_view()), name="edit_profile"),
)
コード例 #18
0
    # # api
    # swagger
    re_path(
        r"^swagger(?P<format>\.json|\.yaml)$",
        schema_view.without_ui(cache_timeout=0),
        name="schema-json",
    ),
    re_path(
        r"^swagger/$",
        schema_view.with_ui("swagger", cache_timeout=0),
        name="schema-swagger-ui",
    ),
    re_path(r"^redoc/$",
            schema_view.with_ui("redoc", cache_timeout=0),
            name="schema-redoc"),
    # auth
    re_path(r"^api/auth/", include("auth.urls")),
    # users
    re_path(r"^api/users/", include(("users.urls", "users"),
                                    namespace="users")),
    re_path(r"^standings/", LeagueViews.as_view()),
    re_path(r"^matchups/", ResultViews.as_view()),
    re_path(r"^stats/", TeamViews.as_view()),
    re_path(r"^roto/", RotoTeamViews.as_view()),
    re_path(r"^news/$", ArticleListView.as_view()),
    path("news/<slug:slug>/", ArticleDetailView.as_view()),
    re_path(r'^.*$',
            RedirectView.as_view(url='/standings/', permanent=False),
            name='index')
]
コード例 #19
0
ファイル: urls.py プロジェクト: Nova7Dawn/portblog
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.urls import path
from django.contrib import admin
from articles.views import ArticleListView, ArticleDetailView, ArticleCreateView, ArticleUpdateView, ArticleDeleteView, CategoryListView, CategoryCreateView
from django.conf import settings  # 増えた
from django.conf.urls.static import static  # 増えた

urlpatterns = [
    path('categorycreate', CategoryCreateView.as_view(),
         name='categorycreate'),
    path('category', CategoryListView.as_view(), name='category'),
    path('delete/<int:pk>', ArticleDeleteView.as_view(), name="delete"),
    path('create', ArticleCreateView.as_view(), name="create"),
    path('update/<int:pk>', ArticleUpdateView.as_view(), name="update"),
    path('<int:pk>', ArticleDetailView.as_view(), name="detail"),
    path('', ArticleListView.as_view(), name="index"),
    path('admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
コード例 #20
0
# -*- coding: utf-8 -*-
from rest_framework.routers import DefaultRouter
from django.conf.urls import url, include

from articles.api import BlogDetailViewSet
from articles.views import HomeView, BlogsView, BlogDetailView, ArticleDetailView, ArticleCreationView

articles=BlogDetailViewSet.as_view({
    'get': 'list'
})

router = DefaultRouter()
router.register('api/1.0/blog/(?P<username>\w+)', BlogDetailViewSet, base_name='api_blogs_detail')



urlpatterns = [
    url(r'^$', HomeView.as_view(), name='article_home'),
    url(r'^new-post$', ArticleCreationView.as_view(), name='article_creation'),
    url(r'^blogs/$', BlogsView.as_view(), name='blogs_list'),
    url(r'^blogs/(?P<username>\w+)/$', BlogDetailView.as_view(), name='blog_detail'),
    url(r'^blogs/(?P<username>\w+)/(?P<pk>[0-9]+)$$', ArticleDetailView.as_view(), name='article_detail'),
    url(r'', include(router.urls))
]
コード例 #21
0
from django.conf.urls import url

from articles.views import (ArticleListView, TaggedArticleListView,
                            ArticleDetailView, SearchView)

app_name = 'articles'
urlpatterns = [
    url(r'^$', ArticleListView.as_view(), name='list'),
    url(r'^tagged/(?P<tags_with_plus>[\w\+-]+)/$',
        TaggedArticleListView.as_view(),
        name='tagged-list'),
    url(r'^(?P<pk>[0-9]+)/$', ArticleDetailView.as_view(), name='detail'),
    url(r'^search/$', SearchView.as_view(), name='search'),
]
コード例 #22
0
     'articles.views.give_kudos',
     name='articles_give_kudos_to_article'),
 url(r'^(?P<pk>\d+)/revisions/$',
     ArticleRevisionListView.as_view(),
     name='articles_article_revision_list'),
 url(r'^(?P<pk>\d+)-(?P<slug>[-a-z0-9]+)/revisions/$',
     ArticleRevisionListView.as_view(),
     name='articles_article_revision_list'),
 url(r'^(?P<pk>\d+)-(?P<slug>[-a-z0-9]+)/revisions/feed/$',
     RevisionFeed(),
     name='articles_article_revision_feed'),
 url(r'^(?P<pk>\d+)/revisions/feed/$',
     RevisionFeed(),
     name='articles_article_revision_feed'),
 url(r'^(?P<pk>\d+)/revisions/(?P<revision_id>\d+)$',
     ArticleDetailView.as_view(),
     name='articles_article_revision_detail'),
 url(r'^(?P<pk>\d+)/diff_with/(?P<revision_id>\d+)$',
     ArticleRevisionDiffView.as_view(),
     name='articles_article_revision_diff'),
 url(r'^(?P<pk>\d+)/$',
     ArticleDetailView.as_view(),
     name='articles_article_detail'),
 url(r'^(?P<pk>\d+)/(?P<slug>[-a-z0-9]+)/$',
     ArticleDetailView.as_view(),
     name='articles_article_detail'),
 url(r'^(?P<pk>\d+)\.md$',
     ArticleDetailView.as_view(as_source=True),
     name='articles_article_source'),
 url(r'^edit/(?P<pk>\d+)/$',
     ArticleUpdateView.as_view(),