コード例 #1
0
 def test_get_update_form(self):
     '''A user sees the edit form prepopulated with the current data.'''
     # add a Note, make sure it's slug is generated
     self.assertEqual(self.note.slug, 'frogs')
     # the user can see the page using the slug of the Note in the URL
     get_request = self.factory.get('/notes/frogs/edit/')
     get_request.user = self.user
     response = NoteUpdate.as_view()(get_request, slug=self.note.slug)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Frogs')
コード例 #2
0
 def test_edit_note_redirect(self):
     '''After a valid form submission, the user is redirected.'''
     previous_content = self.note.content
     # user enters data they want to replace current Note data
     new_content = "What makes a frog's tongue so sticky?"
     form_data = {'content': new_content}
     # user submits the form
     post_request = self.factory.post('/notes/frogs/edit/', form_data)
     post_request.user = self.user
     response = NoteUpdate.as_view()(post_request, slug=self.note.slug)
     # the data in the field of the corresponding Note changes
     self.assertEqual(response.status_code, 302)
     self.assertEqual(self.note.content, new_content)
コード例 #3
0
"""main_config URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/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, include
from notes.views import NoteCreate, NoteListView, NoteDetailView, NoteUpdate, NoteDelete

urlpatterns = [
    path('create', NoteCreate.as_view(), name='note-create'),
    path('', NoteListView.as_view(), name='note-list'),
    path('<int:pk>/', NoteDetailView.as_view(), name='note-detail'),
    path('update/<int:pk>/', NoteUpdate.as_view(), name='note-update'),
    path('delete/<int:pk>/', NoteDelete.as_view(), name='note-delete'),
]
コード例 #4
0
ファイル: urls.py プロジェクト: schroederjacob/UNC-BACS-350
from django.urls import path

from notes.views import IndexPage, NoteCreate, NoteDetail, NoteList, NoteUpdate


urlpatterns = [

    # Notes
    path('', NoteList.as_view(), name='note-list'),
    path('<int:pk>', NoteDetail.as_view(), name='note-detail'),
    path('add', NoteCreate.as_view(), name='note-add'),
    path('<int:pk>/', NoteUpdate.as_view(), name='note-edit'),

]
コード例 #5
0
from django.urls import path
from notes.views import (NoteList, NoteDetail, NoteCreate, NoteUpdate,
                         NoteDelete, post_on_medium)
from django.conf import settings
from django.conf.urls.static import static

app_name = 'notes'
urlpatterns = ([
    path('', NoteCreate.as_view(), name="create_note_form"),
    path('home/', NoteList.as_view(), name='index'),
    path('<slug:slug>/edit/', NoteUpdate.as_view(), name="edit_note_form"),
    path('<slug:slug>/delete/', NoteDelete.as_view(), name='delete_note'),
    path('<slug:slug>/', NoteDetail.as_view(), name='notes-detail-page'),
    path(('https://medium.com/m/oauth/authorize?' + 'client_id={{clientId}}' +
          '&scope=basicProfile,publishPost&state={{state}}' +
          '&response_type=code&redirect_uri={{redirectUri}}'),
         post_on_medium,
         name='post-to-medium'),
])
コード例 #6
0
from django.conf.urls import url

from notes.views import NoteListView, NoteDetailView, NoteCreate, NoteUpdate, NoteDelete

urlpatterns = [
    url(r'^$', NoteListView.as_view(), name='note-list'),
    url(r'^(?P<pk>\d+)/$', NoteDetailView.as_view(), name='note-detail'),
    url(r'note/add/$', NoteCreate.as_view(), name='note-add'),
    url(r'note/(?P<pk>[0-9]+)/$', NoteUpdate.as_view(), name='note-update'),
    url(r'note/(?P<pk>[0-9]+)/delete/$',
        NoteDelete.as_view(),
        name='note-delete'),
]
コード例 #7
0
ファイル: urls.py プロジェクト: Kovali0/WebNotes
from django.urls import re_path, path

from notes.views import NoteDetailView, NoteListView, NoteCreate, NoteUpdate, NoteDelete, Dashboard, Register, \
    TopicListView, TopicDetailView, TopicCreate, TopicUpdate, TopicDelete

urlpatterns = [
    #re_path(r'', Dashboard, name='dashboard'),
    re_path(r'^$', NoteListView.as_view(), name='note-list'),
    re_path(r'^(?P<pk>\d+)/$', NoteDetailView.as_view(), name='note-detail'),
    re_path(r'note/add/$', NoteCreate.as_view(), name='note-form'),
    re_path(r'note/(?P<pk>[0-9]+)/$',
            NoteUpdate.as_view(),
            name='note-update-form'),
    re_path(r'note/(?P<pk>[0-9]+)/delete/$',
            NoteDelete.as_view(),
            name='note-confirm-delete'),
    re_path(r'users/dashboard/', Dashboard, name='dashboard'),
    re_path(r'^register/', Register, name='register'),
    re_path(r'^topics/$', TopicListView.as_view(), name='topic-list'),
    re_path(r'^topics/(?P<pk>\d+)/$',
            TopicDetailView.as_view(),
            name='topic-detail'),
    re_path(r'topics/add/$', TopicCreate.as_view(), name='topic-form'),
    re_path(r'topics/(?P<pk>[0-9]+)/$',
            TopicUpdate.as_view(),
            name='topic-update-form'),
    re_path(r'topics/(?P<pk>[0-9]+)/delete/$',
            TopicDelete.as_view(),
            name='topic-confirm-delete'),
]