def test_index_view_with_no_questions(self):
        """
        If no questions exist, an appropriate message should be displayed.
        """
        request = self.request_factory.get(reverse('polls:index'))
        response = IndexView.as_view()(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "No polls are available")
 def test_no_question(self):
     """
     If no question exists, an appropriate message is displayed.
     """
     path = reverse('polls:index')
     print(path)
     request = RequestFactory().get(path)
     response = IndexView.as_view()(request).render()
     assert response.status_code == 200
     assert 'No polls are available.' in str(response)
    def test_index_view_with_a_future_question(self):
        """
        Questions with a pub_date in the future should not be displayed on
        the index page.
        """
        question = self.create_question(question_text="Future question", days=30)
        request = self.request_factory.get(reverse('polls:index'))
        response = IndexView.as_view()(request)

        self.assertNotContains(response, question.question_text)
 def test_past_question(self):
     """
     Questions with a pub_date in the past are displayed on the
     index page.
     """
     path = reverse('polls:index')
     request = RequestFactory().get(path)
     create_question(question_text="Past question.", days=-30)
     response = IndexView.as_view()(request).render()
     assert response.status_code == 200
     assert 'Past question.' in str(response.content)
    def test_index_view_with_two_past_questions(self):
        """
        The questions index page may display multiple questions.
        """
        question1 = self.create_question(question_text="Past question", days=-30)
        question2 = self.create_question(question_text="Past question", days=-5)
        request = self.request_factory.get(reverse('polls:index'))
        response = IndexView.as_view()(request)

        self.assertContains(response, question1.question_text)
        self.assertContains(response, question2.question_text)
 def test_future_question(self):
     """
     Questions with a pub_date in the future aren't displayed on
     the index page.
     """
     path = reverse('polls:index')
     request = RequestFactory().get(path)
     create_question(question_text="Future question.", days=30)
     response = IndexView.as_view()(request).render()
     assert response.status_code == 200
     assert 'No polls are available.' in str(response.content)
    def test_index_view_with_future_question_and_past_question(self):
        """
        Even if both past and future questions exist, only past questions
        should be displayed.
        """
        past_question = self.create_question(question_text="Past question", days=-30)
        future_question = self.create_question(question_text="Future question", days=30)
        request = self.request_factory.get(reverse('polls:index'))
        response = IndexView.as_view()(request)

        self.assertContains(response, past_question.question_text)
        self.assertNotContains(response, future_question.question_text)
 def test_future_question_and_past_question(self):
     """
         Even if both past and future questions exist, only past questions
         are displayed.
         """
     path = reverse('polls:index')
     request = RequestFactory().get(path)
     create_question(question_text='Future question.', days=30)
     create_question(question_text='Past question.', days=-30)
     response = IndexView.as_view()(request).render()
     assert response.status_code == 200
     assert 'Past question.' in str(response.content)
 def test_two_past_question(self):
     """
     The questions index page may display multiple questions.
     """
     path = reverse('polls:index')
     request = RequestFactory().get(path)
     create_question(question_text='Past question 1.', days=-30)
     create_question(question_text='Past question 2.', days=-2)
     response = IndexView.as_view()(request).render()
     assert response.status_code == 200
     assert 'Past question 1.' in str(response.content)
     assert 'Past question 2.' in str(response.content)
예제 #10
0
from django.urls import path
from polls.views import IndexView, DetailView, ResultsView
from . import views

app_name = 'polls'
urlpatterns = [
    path('', IndexView.as_view(), name='index'),
    path('<int:pk>/', DetailView.as_view(), name='detail'),
    path('<int:pk>/results/', ResultsView.as_view(), name='results'),
    path('<int:question_id>/vote/', views.vote, name='vote'),
]
예제 #11
0
파일: urls.py 프로젝트: nonre/questionp
"""questionproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/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 polls import views
from polls.views import DetailView, ResultView, IndexView
from django.views.generic.base import RedirectView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', RedirectView.as_view(url='polls/'), name='home'),
    path('polls/', IndexView.as_view(), name='index'),
    path('polls/<int:pk>/', DetailView.as_view(), name='detail'),
    path('polls/<int:question_id>/vote', views.vote, name='vote'),
    path('polls/<int:pk>/result', ResultView.as_view(), name='result'),
]
예제 #12
0
from django.conf.urls import patterns, include, url

from polls.views import IndexView, QuestionView

urlpatterns = patterns('',
    url(r'^detail/(?P<question_id>\d+)$', QuestionView.as_view(), name="poll_detail"),
    url(r'^$', IndexView.as_view(), name='home'),
)
예제 #13
0
from django.contrib import admin
from django.urls import path
from django.contrib import admin
from django.urls import include, path
from django.views.generic.base import TemplateView
from polls.views import IndexView

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
    path('accounts/', include('django.contrib.auth.urls')),
    path('', IndexView.as_view(), name='home'),
    #path('', TemplateView.as_view(template_name='index.html'), name='home'),
    #path('polls/', TemplateView.as_view(template_name='polls/index.html'), name='home'),
]
예제 #14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = 'polls 's usrls page'
__author__ = 'zhouzhuan'
__mtime__ = '2017/6/20'
"""
from django.conf.urls import patterns, url
from django.views.generic import DetailView, ListView
from polls.models import Poll
from polls.views import IndexView, DetailViewNew
urlpatterns = patterns(
    '',
    url(r'^$',
        IndexView.as_view(queryset=Poll.objects.order_by('-qub_date')[:5],
                          context_object_name='latest_poll_list',
                          template_name='polls/index.html'),
        name='index'),
    url(r'^(?P<pk>\d+)/$',
        DetailViewNew.as_view(model=Poll, template_name='polls/detail.html'),
        name='detail'),
    url(r'^(?P<pk>\d+)/results/$',
        DetailView.as_view(model=Poll, template_name='polls/results.html'),
        name='results'),
    url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote', name='vote'),
)

# from polls import  views
#
# urlpatterns = patterns('',
#                        #ex: /polls/
예제 #15
0
파일: urls.py 프로젝트: tedchengy/test
"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
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 polls.views import IndexView
urlpatterns = [
    url(r'^$', IndexView.as_view(), name='home'),
    url(r'^admin/', admin.site.urls),
    url(r'^polls/', include('polls.urls', namespace="polls")),
]
예제 #16
0
파일: urls.py 프로젝트: jdestradap/bildung
from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll
from polls.views  import IndexView


urlpatterns = patterns('',
    
    url(r'^$',
        IndexView.as_view(),
        name = 'index'),    
            # queryset=Poll.objects.order_by('-pub_date')[:5],
            # context_object_name='latest_poll_list',
            # template_name='polls/index.html')),
    url(r'^(?P<pk>\d+)/$',
        DetailView.as_view(
            model=Poll,
            template_name='polls/detail.html')),
    url(r'^(?P<pk>\d+)/results/$',
        DetailView.as_view(
            model=Poll,
            template_name='polls/results.html'),
        name='poll_results'),
    url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
)
예제 #17
0
"""website URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/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 include, path
from polls.views import IndexView

urlpatterns = [
    path('', IndexView.as_view()),
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]
        description="설문조사, 블로그, 예약 어플리케이션 관리 OPEN API입니다.",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="*****@*****.**"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)

# http://localhost:8000/swagger/
urlpatterns = [
    path('admin/', admin.site.urls),

    # 사용자 아이디와 암호를 전달받아 토큰을 발급해주는 rest framework 기능
    path('api/get_token/', views.obtain_auth_token),

    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'),

    # polls어플리케이션의 IndexView를 메인페이지로 설정 #하위에 있는 어플리케이션은 메인으로 잡아줌
    path('', IndexView.as_view(), name="main"),
    path('polls/', include('polls.urls')),
    path('blog/', include('blog.urls')),
    # 이건 api다 라는걸 보여주기위해.. 여기에 api 안 넣어도 되긴함 ㅋ
    path('api/booking/', include('booking.urls')),
]
예제 #19
0
"""tutorial URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
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 include, url
from django.contrib import admin

from polls.views import IndexView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'polls/', include('polls.urls', namespace = "polls")),
    url(r'^$', IndexView.as_view(), name = "index")
]
예제 #20
0
from django.conf.urls import url

from polls.views import DetailView, IndexView, ResultView, vote

urlpatterns = [
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^(?P<pk>[0-9]+)/detail/$', DetailView.as_view(), name='detail'),
    url(r'^(?P<pk>[0-9]+)/result/$', ResultView.as_view(), name='result'),
    url(r'^(?P<question_id>[0-9]+)/vote/$', vote, name='vote'),
]
예제 #21
0
from polls.views import DetailView, IndexView, LoginView, LogoutView, RegisterView, ResultView
from django.urls.conf import re_path

urlpatterns = [
    re_path(r'^logout/$', LogoutView.as_view(), name='logout'),
    re_path(r'^login/$', LoginView.as_view(), name='login'),
    re_path(r'^register/$', RegisterView.as_view(), name='register'),
    re_path(r'^detail/(?P<id>\d+)$', DetailView.as_view(), name='detail'),
    re_path(r'^result/(?P<id>\d+)$', ResultView.as_view(), name='result'),
    re_path(r'^$', IndexView.as_view(), name='index'),
]
예제 #22
0
from django.conf.urls import url

from polls.views import DetailView, IndexView, results, vote

urlpatterns = [
    url(r'^$', IndexView.as_view(), name='polls_list'),
    url(r'^(?P<pk>[0-9]+)/$', DetailView.as_view(), name='poll_detail'),
    url(r'^(?P<question_id>[0-9]+)/vote/$', vote, name='vote'),
    url(r'^(?P<question_id>[0-9]+)/results/$', results, name='results'),
]
예제 #23
0
from django.contrib import admin
from django.urls import path, include
from polls import views
from polls.views import IndexView

urlpatterns = [
    path('', views.index),
    path('react-index/', IndexView.as_view()),
    path('admin/', admin.site.urls),
    path('polls/', include('polls.urls'))
]
예제 #24
0
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
from django.contrib import admin
#from polls.views import index as poll_views_index
from polls.views import detail as poll_views_detail
from polls.views import results as poll_views_result
from polls.views import vote as poll_views_vote
from polls.views import year_archive as poll_views_year_archive
from polls.views import os_command as poll_views_os_command
from polls.views import DetailView,IndexView

urlpatterns = [
    url(r'^', admin.site.urls),
    url(r'^(?P<parameter1>[0-9]+)/vote/$',poll_views_vote,name='poll_views_vote'),
    url(r'^year_archive/(?P<year>[0-9]+)/$', poll_views_year_archive, name='poll_views_year_archive'),

    url(r'^detail/(?P<pk>[0-9]+)/$', DetailView.as_view(), name='detail'),
    url(r'^index/(?P<pk>[0-9]+)/$', IndexView.as_view(), name='index'),

   # url(r'^detail/(?P<question_id>[0-9]+)/$',poll_views_detail,name='poll_views_detail'),
    url(r'^results/(?P<question_id>[0-9]+)/$', poll_views_result, name='poll_views_result'),
    url(r'^vote/(?P<question_id>[0-9]+)/$', poll_views_vote, name='poll_views_vote'),
    #url(r'^index/$', poll_views_index, name='poll_views_index'),
    url(r'os_command/$',poll_views_os_command,name='os_command'),


]