コード例 #1
0
 def _get_request_view_and_content(self, rf):
     request = rf.get("/")
     request.user = UserFactory()
     content = ContentFactory(author=request.user.profile)
     view = ContentUpdateView(request=request, kwargs={"pk": content.id})
     view.object = content
     return request, view, content
コード例 #2
0
from django.conf.urls import url

from socialhome.content.views import ContentCreateView, ContentUpdateView, ContentDeleteView, ContentView

urlpatterns = [
    url(r"^create/$", ContentCreateView.as_view(), name="create"),
    url(r"^(?P<pk>[0-9]+)/~edit/$", ContentUpdateView.as_view(),
        name="update"),
    url(r"^(?P<pk>[0-9]+)/~delete/$",
        ContentDeleteView.as_view(),
        name="delete"),

    # Content detail works with three different versions
    # /content/123/  # pk
    # /content/123/slug/  # pk + slug
    # /content/abcd-edfg-ffff-aaaa/  # guid
    url(r"^(?P<pk>[0-9]+)/$", ContentView.as_view(), name="view"),
    url(r"^(?P<pk>[0-9]+)/(?P<slug>[-\w]+)/$",
        ContentView.as_view(),
        name="view-by-slug"),
    url(r"^(?P<guid>[^/]+)/$", ContentView.as_view(), name="view-by-guid"),
]
コード例 #3
0
ファイル: urls.py プロジェクト: qincpp/socialhome
from django.conf.urls import url

from socialhome.content.views import ContentCreateView, ContentUpdateView, ContentDeleteView

urlpatterns = [
    url(r"^create/$", ContentCreateView.as_view(), name="create"),
    url(r"^edit/(?P<pk>[0-9]+)$", ContentUpdateView.as_view(), name="update"),
    url(r"^delete/(?P<pk>[0-9]+)$", ContentDeleteView.as_view(),
        name="delete"),
]