Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_01_prefilled_attributes(self):
self.create_entry()
objects = prefill_entry_list(Entry.objects.published(), 'rawcontent_set', 'categories')
self.assertEqual(len(objects[0]._prefill_categories), 0)
self.assertEqual(len(objects[0]._prefill_rawcontent_set), 1)
self.assertEqual(unicode(objects[0]), 'Something')
objects = Entry.objects.published()
self.assertEqual(len(objects[0].prefilled_categories), 0)
self.assertEqual(len(objects[0].prefilled_rawcontent_set), 1)
objects = prefill_entry_list(Entry.objects.published(), 'rawcontent_set', 'categories', region='another')
self.assertEqual(len(objects[0]._prefill_categories), 0)
self.assertEqual(len(objects[0]._prefill_rawcontent_set), 0)
self.login()
def test_24_admin_redirects(self):
self.create_default_page_set()
page = Page.objects.get(pk=1)
response = self.create_pagecontent(page, _continue=1)
self.assertRedirects(response, '/admin/page/page/1/')
response = self.create_pagecontent(page, _addanother=1)
self.assertRedirects(response, '/admin/page/page/add/')
response = self.create_pagecontent(page)
self.assertRedirects(response, '/admin/page/page/')
Entry.register_extensions('seo', 'translations', 'seo')
class BlogTestCase(TestCase):
def setUp(self):
u = User(username='test', is_active=True, is_staff=True, is_superuser=True)
u.set_password('test')
u.save()
Entry.register_regions(('main', 'Main region'), ('another', 'Another region'))
Entry.prefilled_categories = prefilled_attribute('categories')
Entry.prefilled_rawcontent_set = prefilled_attribute('rawcontent_set')
def login(self):
assert self.client.login(username='test', password='test')
def create_entry(self):
entry = Entry.objects.create(
published=True,
def test_01_prefilled_attributes(self):
self.create_entry()
objects = prefill_entry_list(Entry.objects.published(), 'rawcontent_set', 'categories')
self.assertEqual(len(objects[0]._prefill_categories), 0)
self.assertEqual(len(objects[0]._prefill_rawcontent_set), 1)
self.assertEqual(unicode(objects[0]), 'Something')
objects = Entry.objects.published()
self.assertEqual(len(objects[0].prefilled_categories), 0)
self.assertEqual(len(objects[0].prefilled_rawcontent_set), 1)
objects = prefill_entry_list(Entry.objects.published(), 'rawcontent_set', 'categories', region='another')
self.assertEqual(len(objects[0]._prefill_categories), 0)
self.assertEqual(len(objects[0]._prefill_rawcontent_set), 0)
self.login()
help_text=_(
'Exclude everything other than the application\'s'
' content when rendering subpages.'),
),
}
Page.create_content_type(ApplicationContent, APPLICATIONS=(
('blog_urls', 'Blog', {
'admin_fields': get_admin_fields,
'urls': 'example.blog_urls',
}),
))
Entry.register_regions(
('main', 'Main region'),
)
Entry.create_content_type(RawContent)
Entry.create_content_type(
ImageContent,
POSITION_CHOICES=(
('default', 'Default position'),
)
)
class BlogEntriesNavigationExtension(NavigationExtension):
"""
Extended navigation for blog entries.
It would be added to 'Blog' page properties in admin.
from django.conf.urls import patterns, url
from django.views import generic
from feincms.module.blog.models import Entry
urlpatterns = patterns(
'',
url(r'^(?P\d+)/', generic.DetailView.as_view(
queryset=Entry.objects.all(),
), name='blog_entry_detail'),
url(r'^$', generic.ListView.as_view(
queryset=Entry.objects.all(),
), name='blog_entry_list'),
)
from django.conf.urls import patterns, url
from django.views import generic
from feincms.module.blog.models import Entry
urlpatterns = patterns(
'',
url(r'^(?P\d+)/', generic.DetailView.as_view(
queryset=Entry.objects.all(),
), name='blog_entry_detail'),
url(r'^$', generic.ListView.as_view(
queryset=Entry.objects.all(),
), name='blog_entry_list'),
)