当前位置: 首页>>代码示例>>Python>>正文


Python IndexView.as_view方法代码示例

本文整理汇总了Python中views.IndexView.as_view方法的典型用法代码示例。如果您正苦于以下问题:Python IndexView.as_view方法的具体用法?Python IndexView.as_view怎么用?Python IndexView.as_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在views.IndexView的用法示例。


在下文中一共展示了IndexView.as_view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_view_IndexView

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
    def test_view_IndexView(self):
        """
        Funcion que realiza el test sobre la vista UserIndexView que genera
        lista de usuarios
        """
        # se loguea el usuario testuser
        user = self.client.login(username='testuser', password='test')
        self.assertTrue(user)
        user2 = User.objects.create_user(username='user_prueba', email='[email protected]', password='prueba')
        # se crean 10 proyectos para controlar que se retorne la lista completa de usuarios, que seran 11 en total
        for i in range(10):
            proyecto = Proyecto.objects.create(codigo='co%s' % i, nombre_corto='test%s' % i,
                                               nombre_largo='test%s' % i, cancelado=False, scrum_master=user2)


        # verificamos que la vista devuelva el template adecuado
        request = self.factory.get('/proyectos/')
        view = IndexView.as_view()
        response = view(request)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.template_name[0], 'proyectos/index.html')
        # verificamos los usuarios retornados
        self.assertEqual(len(response.context_data['object_list']), 10)

        print 'Test de IndexView de Proyecto realizado exitosamente'
开发者ID:frvc123,项目名称:sigp,代码行数:27,代码来源:tests.py

示例2: test_should_redirects_if_user_is_not_logged_in

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
 def test_should_redirects_if_user_is_not_logged_in(self):
     request = RequestFactory().get("/")
     user = User()
     user.is_authenticated = lambda: False
     request.user = user
     result = IndexView.as_view()(request)
     self.assertEqual(302, result.status_code)
开发者ID:pugpe,项目名称:pythonbrasil8,代码行数:9,代码来源:tests.py

示例3: test_view_IndexView

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
    def test_view_IndexView(self):
        """
        Funcion que realiza el test sobre la vista IndexView que genera
        lista de sprints
        """
        # se loguea el usuario testuser
        user = self.client.login(username='testuser', password='test')
        self.assertTrue(user)
        user2 = User.objects.create_user(username='user_prueba', email='[email protected]', password='prueba')

        proyecto = Proyecto.objects.create(codigo='codi', nombre_corto='test',
                                           nombre_largo='test', cancelado=False, scrum_master=user2)
        proyecto.save()

        # se crean 10 sprints para controlar que se retorne la lista completa de sprints, que seran 10 en total
        for i in range(10):
            sprint = Sprint.objects.create(nombre='sprint%s' % i, duracion='%d' % i, proyecto=proyecto)
            sprint.save()

        # verificamos que la vista devuelva el template adecuado
        request = self.factory.get(reverse('sprints:index', args=[proyecto.pk]))
        request.user = self.user

        response = IndexView.as_view()(request, pk_proyecto=proyecto.pk)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.template_name[0], 'sprints/index.html')
        # verificamos los user stories retornados
        self.assertEqual(len(response.context_data['object_list']), 10)

        print 'Test de IndexView de Sprints realizado exitosamente'
开发者ID:rodiaz,项目名称:sigp,代码行数:32,代码来源:tests.py

示例4: init_app

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
    def init_app(self, app):
        """Initializes the App.

        Args:
            app (TYPE): Description

        Returns:
            TYPE: Description
        """

        config = app.config.copy()

        self.debug = config.get('PONYWHOOSH_DEBUG', self.debug)
        self.indexes_path = config.get('PONYWHOOSH_INDEXES_PATH',  self.indexes_path)
        self.search_string_min_len = config.get('PONYWHOOSH_MIN_STRING_LEN', self.search_string_min_len)
        self.writer_timeout = config.get('PONYWHOOSH_WRITER_TIMEOUT', self.writer_timeout)
        self.url_route = config.get('PONYWHOOSH_URL_ROUTE', self.url_route)
        self.template_path = config.get('PONYWHOOSH_TEMPLATE_PATH', self.template_path)

        if self.debug:
            print 'PONYWHOOSH_DEBUG -> ', self.debug
            print 'PONYWHOOSH_INDEXES_PATH  -> ', self.indexes_path
            print 'PONYWHOOSH_MIN_STRING_LEN  -> ', self.search_string_min_len
            print 'PONYWHOOSH_WRITER_TIMEOUT -> ', self.writer_timeout
            print 'PONYWHOOSH_TEMPLATE_PATH -> ', self.template_path
            print 'PONYWHOOSH_URL_ROUTE -> ',  self.url_route

        loader = jinja2.ChoiceLoader([
            app.jinja_loader,
            jinja2.FileSystemLoader(self.template_path)
        ])

        app.jinja_loader = loader
        app.add_url_rule(
            self.url_route,
            view_func=IndexView.as_view('ponywhoosh/', pw=self)
        )
开发者ID:compiteing,项目名称:flask-ponywhoosh,代码行数:39,代码来源:__init__.py

示例5: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
from django.conf.urls.defaults import patterns, url
from django.views.generic import ListView

from models import Video, TwitterFeed
from views import IndexView

urlpatterns = patterns('',
    url(r'^$', IndexView.as_view(), name='connect_index'),

    url(r'^video/$', ListView.as_view( 
            queryset=Video.objects.all().order_by('title'),
        ),
        name='connect_video_list'
    ),

    url(r'^twitter/$', ListView.as_view(
            queryset=TwitterFeed.objects.all().order_by('handle'),
        ),
        name='connect_twitterfeed_list'
    ),
)
开发者ID:ebrelsford,项目名称:cas_food,代码行数:23,代码来源:urls.py

示例6: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
# -*- encoding: utf-8 -*-
"""Defines all urls conf."""
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required
from views import IndexView, ProfileView, TestView, SaveTestView, CourseView

urlpatterns = patterns('',
	url(r'^$', login_required(IndexView.as_view()), name='dashboard'),
	url(r'^profile/$', login_required(ProfileView.as_view()), name='dashboard-profile'),
	url(r'^test/$', login_required(TestView.as_view()), name='dashboard-test'),
	url(r'^test/save/$', login_required(SaveTestView.as_view()), name='dashboard-save-test'),
	url(r'^(?P<course>\w{5,45})/$', login_required(CourseView.as_view()), name='dashboard-course'),
)
开发者ID:dairdr,项目名称:funpro,代码行数:15,代码来源:urls.py

示例7: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
    OpenTopicView,
    ModeratePost,
)


urlpatterns = patterns(
    "",
    # Syndication feeds
    url("^feeds/posts/$", LastPosts(), name="feed_posts"),
    url("^feeds/topics/$", LastTopics(), name="feed_topics"),
)

urlpatterns += patterns(
    "pybb.views",
    # Index, Category, Forum
    url("^$", IndexView.as_view(), name="index"),
    url("^category/(?P<pk>\d+)/$", CategoryView.as_view(), name="category"),
    url("^forum/(?P<pk>\d+)/$", ForumView.as_view(), name="forum"),
    # User
    url("^users/(?P<username>[^/]+)/$", UserView.as_view(), name="user"),
    url("^block_user/([^/]+)/$", "block_user", name="block_user"),
    # Profile
    url("^profile/edit/$", ProfileEditView.as_view(), name="edit_profile"),
    # Topic
    url("^topic/(?P<pk>\d+)/$", TopicView.as_view(), name="topic"),
    url("^topic/(?P<pk>\d+)/stick/$", StickTopicView.as_view(), name="stick_topic"),
    url("^topic/(?P<pk>\d+)/unstick/$", UnstickTopicView.as_view(), name="unstick_topic"),
    url("^topic/(?P<pk>\d+)/close/$", CloseTopicView.as_view(), name="close_topic"),
    url("^topic/(?P<pk>\d+)/open/$", OpenTopicView.as_view(), name="open_topic"),
    # Add topic/post
    url("^forum/(?P<forum_id>\d+)/topic/add/$", AddPostView.as_view(), name="add_topic"),
开发者ID:nigma,项目名称:pybbm,代码行数:33,代码来源:urls.py

示例8: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
# -*- encoding: utf-8 -*-
"""Defines all urls conf."""
from django.conf.urls import patterns, url
from views import IndexView, ProjectView, ContactView, ThanksView, ResultView, ResultByIndexView, WordView

urlpatterns = patterns('',
	url(r'^$', IndexView.as_view(), name='dictionary-index'), # index web
	url(r'^contact/$', ContactView.as_view(), name='dictionary-contact'), # contact page
	url(r'^project/$', ProjectView.as_view(), name='dictionary-project'), # project page
	url(r'^search/$', ResultView.as_view(), name='dictionary-search'), # search a word
	url(r'^index/(?P<letter>\w{1})/$', ResultByIndexView.as_view(), name='dictionary-search-by-index'), # search by index
	url(r'^word/(?P<word>\d+)/$', WordView.as_view(), name='dictionary-word'), # view a info word
	url(r'^thanks/$', ThanksView.as_view(), name='dictionary-thanks'), # response to sent message
)
开发者ID:dairdr,项目名称:lexicon,代码行数:16,代码来源:urls.py

示例9: test_should_have_200_status_code_when_user_is_logged_in

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
 def test_should_have_200_status_code_when_user_is_logged_in(self):
     request = RequestFactory().get("/")
     request.user = User()
     result = IndexView.as_view()(request)
     self.assertEqual(200, result.status_code)
开发者ID:pugpe,项目名称:pythonbrasil8,代码行数:7,代码来源:tests.py

示例10: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 george 
#
# Distributed under terms of the MIT license.

from django.conf.urls import patterns
from views import IndexView

urlpatterns = patterns('',
    (r'^$', IndexView.as_view()),
)

开发者ID:littleq0903,项目名称:fumoufeed,代码行数:15,代码来源:urls.py

示例11: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
# coding: utf-8

from django.conf.urls import patterns, include, url
from views import IndexView, ArticleDetailView
# admin
from django.contrib import admin
admin.autodiscover()

# xadmin
import xadmin
xadmin.autodiscover()


urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'doit.views.home', name='home'),
    url(r'^index/', IndexView.as_view(), name='index_view'),
    url(r'^article/(?P<pk>[0-9]+)/$', ArticleDetailView.as_view(), name='article_detail'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^xadmin/', include(xadmin.site.urls)),
)
开发者ID:guolee89,项目名称:doit,代码行数:25,代码来源:urls.py

示例12: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
# -*- encoding: utf-8 -*-
"""Defines all urls conf."""
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required
from views import IndexView, SavePanelView, ReviewPanelView, GroupsPanelView, StudentsPanelView
from api import Student, SavePanelStudent

urlpatterns = patterns('',
	url(r'^$', login_required(IndexView.as_view()), name='student-index'),

	# Panel
	url(r'^panel/manage/$', SavePanelView.as_view(), name='student-manage-panel'),
	url(r'^panel/review/$', ReviewPanelView.as_view(), name='student-review-panel'),
	url(r'^panel/groups/(?P<grade>\w{1,10})$', GroupsPanelView.as_view(), name='student-groups-panel'),
	url(r'^panel/students/(?P<grade>\w{1,10})/(?P<group>\w{1,10})$', StudentsPanelView.as_view(), name='student-students-panel'),

	# API
	url(r'^api/v1/students/$', Student.as_view(), name='student-api-students'),
	url(r'^api/v1/panel/manage/save/$', SavePanelStudent.as_view(), name='student-api-manage-panel-save'),
)
开发者ID:dairdr,项目名称:notes,代码行数:22,代码来源:urls.py

示例13: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
# pylint: disable=E1120

from django.conf.urls import patterns, url, include
from django.contrib import admin
from django.conf import settings
from views import TermsRequiredView, SecureView, IndexView
from django.views.decorators.cache import never_cache
from termsandconditions.decorators import terms_required
from django.contrib.auth.decorators import login_required

admin.autodiscover()

urlpatterns = patterns('',

    # Home Page
    url(r'^$', never_cache(IndexView.as_view()), name="tc_demo_home_page"),

    # Home Page
    url(r'^anon/$', never_cache(IndexView.as_view(template_name="index_anon.html")), name="tc_demo_home_anon_page"), #used for pipeline user test

    # Secure Page
    url(r'^secure/$', never_cache((login_required(SecureView.as_view()))), name="tc_demo_secure_page"),

    # Secure Page Too
    url(r'^securetoo/$', never_cache(login_required(SecureView.as_view(template_name="securetoo.html"))), name="tc_demo_secure_page_too"),

    # Terms Required
    url(r'^termsrequired/$', never_cache(terms_required(login_required(TermsRequiredView.as_view()))), name="tc_demo_required_page"),

    # Terms and Conditions
    url(r'^terms/', include('termsandconditions.urls')),
开发者ID:wamdam,项目名称:django-termsandconditions,代码行数:33,代码来源:urls.py

示例14: patterns

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
from django.conf.urls import patterns, include, url
from django.conf import settings
from office.views import OfficeSearchView
from django.contrib import admin
from django.contrib.staticfiles import views
from views import IndexView



urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'customrcare.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^office/search', OfficeSearchView.as_view()),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', IndexView.as_view(template_name = 'customrcare/index.html')),
    url(r'^static/css/bootstrap.min.css', 'django.views.static.serve',
    {'document_root', settings.STATIC_ROOT}),
)
开发者ID:Deepakdubey90,项目名称:customer-care,代码行数:21,代码来源:urls.py

示例15: url

# 需要导入模块: from views import IndexView [as 别名]
# 或者: from views.IndexView import as_view [as 别名]
from django.conf.urls import include, url
from views import IndexView, FetchView, ResultView, DetailView

urlpatterns = [
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^search/$', IndexView.as_view(), name='search_item'),
    url(r'^fetch/(?P<query>.+)/$', FetchView.as_view(), name='fetch_item'),
    url(r'^detail/(?P<pk>.+)/$', DetailView.as_view(), name='app_detail'),
    #url(r'^results/$', ResultView.as_view(), name='results'),
]
开发者ID:shriyanka,项目名称:googleplay,代码行数:12,代码来源:urls.py


注:本文中的views.IndexView.as_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。