Beispiel #1
0
    def test_include_args(self):
        "GET arguments can be included in the redirected URL"
        response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/'))
        self.assertEqual(response.status_code, 301)
        self.assertEqual(response['Location'], '/bar/')

        response = RedirectView.as_view(url='/bar/', query_string=True)(self.rf.get('/foo/?pork=spam'))
        self.assertEqual(response.status_code, 301)
        self.assertEqual(response['Location'], '/bar/?pork=spam')
numeric_days_info_dict = dict(date_based_info_dict, day_format='%d')

date_based_datefield_info_dict = dict(date_based_info_dict, queryset=DateArticle.objects.all())

urlpatterns = patterns('',
    (r'^accounts/login/$', 'djangocg.contrib.auth.views.login', {'template_name': 'login.html'}),
    (r'^accounts/logout/$', 'djangocg.contrib.auth.views.logout'),

    # Special URLs for particular regression cases.
    url('^中文/$', 'regressiontests.views.views.redirect'),
    url('^中文/target/$', 'regressiontests.views.views.index_page'),
)

# rediriects, both temporary and permanent, with non-ASCII targets
urlpatterns += patterns('',
    ('^nonascii_redirect/$', RedirectView.as_view(
        url='/中文/target/', permanent=False)),
    ('^permanent_nonascii_redirect/$', RedirectView.as_view(
        url='/中文/target/', permanent=True)),
)

urlpatterns += patterns('regressiontests.views.views',
    (r'^shortcuts/render_to_response/$', 'render_to_response_view'),
    (r'^shortcuts/render_to_response/request_context/$', 'render_to_response_view_with_request_context'),
    (r'^shortcuts/render_to_response/mimetype/$', 'render_to_response_view_with_mimetype'),
    (r'^shortcuts/render/$', 'render_view'),
    (r'^shortcuts/render/base_context/$', 'render_view_with_base_context'),
    (r'^shortcuts/render/content_type/$', 'render_view_with_content_type'),
    (r'^shortcuts/render/status/$', 'render_view_with_status'),
    (r'^shortcuts/render/current_app/$', 'render_view_with_current_app'),
    (r'^shortcuts/render/current_app_conflict/$', 'render_view_with_current_app_conflict'),
)
Beispiel #3
0
 def test_redirect_when_meta_contains_no_query_string(self):
     "regression for #16705"
     # we can't use self.rf.get because it always sets QUERY_STRING
     response = RedirectView.as_view(url='/bar/')(self.rf.request(PATH_INFO='/foo/'))
     self.assertEqual(response.status_code, 301)
Beispiel #4
0
 def test_redirect_DELETE(self):
     "Default is a permanent redirect"
     response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/'))
     self.assertEqual(response.status_code, 301)
     self.assertEqual(response['Location'], '/bar/')
Beispiel #5
0
 def test_parameter_substitution(self):
     "Redirection URLs can be parameterized"
     response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42)
     self.assertEqual(response.status_code, 301)
     self.assertEqual(response['Location'], '/bar/42/')
Beispiel #6
0
 def test_include_urlencoded_args(self):
     "GET arguments can be URL-encoded when included in the redirected URL"
     response = RedirectView.as_view(url='/bar/', query_string=True)(
         self.rf.get('/foo/?unicode=%E2%9C%93'))
     self.assertEqual(response.status_code, 301)
     self.assertEqual(response['Location'], '/bar/?unicode=%E2%9C%93')
Beispiel #7
0
 def test_temporary_redirect(self):
     "Permanent redirects are an option"
     response = RedirectView.as_view(url='/bar/', permanent=False)(self.rf.get('/foo/'))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response['Location'], '/bar/')
Beispiel #8
0
 def test_no_url(self):
     "Without any configuration, returns HTTP 410 GONE"
     response = RedirectView.as_view()(self.rf.get('/foo/'))
     self.assertEqual(response.status_code, 410)
Beispiel #9
0
from djangocg.conf.urls import patterns, url
from djangocg.views.generic import RedirectView

from . import views


urlpatterns = patterns('',
    (r'^no_template_view/$', views.no_template_view),
    (r'^staff_only/$', views.staff_only_view),
    (r'^get_view/$', views.get_view),
    (r'^request_data/$', views.request_data),
    (r'^request_data_extended/$', views.request_data, {'template':'extended.html', 'data':'bacon'}),
    url(r'^arg_view/(?P<name>.+)/$', views.view_with_argument, name='arg_view'),
    (r'^login_protected_redirect_view/$', views.login_protected_redirect_view),
    (r'^redirects/$', RedirectView.as_view(url='/test_client_regress/redirects/further/')),
    (r'^redirects/further/$', RedirectView.as_view(url='/test_client_regress/redirects/further/more/')),
    (r'^redirects/further/more/$', RedirectView.as_view(url='/test_client_regress/no_template_view/')),
    (r'^redirect_to_non_existent_view/$', RedirectView.as_view(url='/test_client_regress/non_existent_view/')),
    (r'^redirect_to_non_existent_view2/$', RedirectView.as_view(url='/test_client_regress/redirect_to_non_existent_view/')),
    (r'^redirect_to_self/$', RedirectView.as_view(url='/test_client_regress/redirect_to_self/')),
    (r'^circular_redirect_1/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_2/')),
    (r'^circular_redirect_2/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_3/')),
    (r'^circular_redirect_3/$', RedirectView.as_view(url='/test_client_regress/circular_redirect_1/')),
    (r'^redirect_other_host/$', RedirectView.as_view(url='https://otherserver:8443/test_client_regress/no_template_view/')),
    (r'^set_session/$', views.set_session_view),
    (r'^check_session/$', views.check_session_view),
    (r'^request_methods/$', views.request_methods_view),
    (r'^check_unicode/$', views.return_unicode),
    (r'^parse_unicode_json/$', views.return_json_file),
    (r'^check_headers/$', views.check_headers),
Beispiel #10
0
from __future__ import absolute_import

from djangocg.conf.urls import patterns
from djangocg.views.generic import RedirectView

from . import views


urlpatterns = patterns('',
    (r'^get_view/$', views.get_view),
    (r'^post_view/$', views.post_view),
    (r'^header_view/$', views.view_with_header),
    (r'^raw_post_view/$', views.raw_post_view),
    (r'^redirect_view/$', views.redirect_view),
    (r'^secure_view/$', views.view_with_secure),
    (r'^permanent_redirect_view/$', RedirectView.as_view(url='/test_client/get_view/')),
    (r'^temporary_redirect_view/$', RedirectView.as_view(url='/test_client/get_view/', permanent=False)),
    (r'^http_redirect_view/$', RedirectView.as_view(url='/test_client/secure_view/')),
    (r'^https_redirect_view/$', RedirectView.as_view(url='https://testserver/test_client/secure_view/')),
    (r'^double_redirect_view/$', views.double_redirect_view),
    (r'^bad_view/$', views.bad_view),
    (r'^form_view/$', views.form_view),
    (r'^form_view_with_template/$', views.form_view_with_template),
    (r'^login_protected_view/$', views.login_protected_view),
    (r'^login_protected_method_view/$', views.login_protected_method_view),
    (r'^login_protected_view_custom_redirect/$', views.login_protected_view_changed_redirect),
    (r'^permission_protected_view/$', views.permission_protected_view),
    (r'^permission_protected_view_exception/$', views.permission_protected_view_exception),
    (r'^permission_protected_method_view/$', views.permission_protected_method_view),
    (r'^session_view/$', views.session_view),
    (r'^broken_view/$', views.broken_view),