示例#1
0
    def test_view_only_ten(self):
        for i in range(11):
            path = Path.objects.get_or_create(url='/test%d' % 1)[0]
            Request.objects.create(path=path)

        view = RequestsView()
        context = view.get_context_data()

        self.assertEqual(len(context['requests_list']), 10)
示例#2
0
    def test_ordering(self):
        p1 = Path.objects.create(url='/test%d' % 1, priority=1)
        p2 = Path.objects.create(url='/test%d' % 2, priority=2)
        p3 = Path.objects.create(url='/test%d' % 3, priority=3)

        for path in (p1, p2, p3)*2:
            Request.objects.create(path=path)

        view = RequestsView()
        context = view.get_context_data()
        path_list = [request.path.url for request in context['requests_list']]

        self.assertEqual(path_list, ['/test%d' % (d/2) for d in range(7, 1, -1)])
示例#3
0
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from person.views import MainPageView, EditMainPageView
from utils.views import RequestsView


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
     url(r'^$', MainPageView.as_view(), name='main'),
     url(r'^requests/$', RequestsView.as_view(), name='request_list'),
     url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
     url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='logout'),
     url(r'^edit_home/$', EditMainPageView.as_view(), name='edit_home'),
    # url(r'^test_assignment/', include('test_assignment.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)