def test_results_empty(self):
        """
        The results view of a question should display choices and counts.
        """
        question = self.create_question(question_text='Question.', days=-5)
        choice1 = Choice.objects.create(
            question=question,
            choice_text='Choice 1',
            votes=10,
        )
        choice2 = Choice.objects.create(
            question=question,
            choice_text='Choice 2',
            votes=11,
        )

        request = self.request_factory.get(reverse('polls:results', args=(question.id,)))
        response = ResultsView.as_view()(request, pk=question.id)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "<li>{} -- {} votes</li>".format(choice1.choice_text, choice1.votes))
        self.assertContains(response, "<li>{} -- {} votes</li>".format(choice2.choice_text, choice2.votes))
Exemple #2
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from django.conf.urls import url
from polls.views import DetailView, ResultsView

from . import views

urlpatterns = [
	url(r'^$', views.index, name='index'),
	url(r'(?P<pk>[0-9]+)/$',
		DetailView.as_view(), name='detail'),
	url(r'(?P<pk>[0-9]+)/results/$',
		ResultsView.as_view(), name='results'),
	url(r'(?P<question_id>[0-9]+)/vote/$',
		views.vote, name='vote'),
	url(r'^login/$', views.Login, name='login'),
	url(r'^logout/$', views.Logout, name='logout'),
]
Exemple #3
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'),
]
Exemple #4
0
from django.urls import path
from django.conf.urls import url

from . import views
from polls.views import HomeView, CreateTournamentView, LoginView, SignUpView, TournamentView, LogoutView, HighscoresView, ResultsView

app_name = 'polls'
urlpatterns = [
    path('tournament/<int:tournament_id>/',
         TournamentView.as_view(),
         name='tournament'),
    path('', TournamentView.as_view(), name='check_answer'),
    path('create/', CreateTournamentView.as_view(), name='create'),
    path('create_tourny/',
         CreateTournamentView.as_view(),
         name='create_tourny'),
    path('index/', HomeView.as_view(), name='index'),
    path('login/', LoginView.as_view(), name='login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('signup/', SignUpView.as_view(), name='signup'),
    path('highscores/', HighscoresView.as_view(), name='highscores'),
    path('', SignUpView.as_view(), name='create_user'),
    path('scores/<int:score>', ResultsView.as_view(), name='results'),
]
Exemple #5
0
from polls.views import PollView, ResultsView, PollIndexView

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',

    url(
        regex=r'^$',
        view=PollIndexView.as_view(),
        name='index'
    ),

    url(
        regex=r'^(?P<poll_id>\d+)/vote/$',
        view=PollView.as_view(),
        name='vote'
    ),

    url(
        regex=r'^(?P<poll_id>\d+)/results/$',
        view=ResultsView.as_view(),
        name='results'
    ),

    url(r'^admin/', include(admin.site.urls)),
)
Exemple #6
0
from django.conf.urls import url

from polls.views import IndexView, DetailView, ResultsView
from . import views 

app_name = 'polls'
urlpatterns = [
  url(r'^$', IndexView.as_view(), name='index'),
  url(r'^(?P<pk>\d+)$', DetailView.as_view(), name='detail'),
  url(r'^(?P<pk>\d+)/results$', ResultsView.as_view(), name='results'),
  url(r'^ok$', views.note, name='note'),
  url(r'^(?P<question_id>\d+)/vote$', views.vote, name='vote')
]