def handle(self, *args, **options): if options['delete']: Page.objects.filter(slug='home').delete() try: HomePage.objects.get(slug='home') except ObjectDoesNotExist: Page.objects.filter(slug='home').delete() # homepage cannot be saved without a parent home_page = HomePageFactory.build( description_header="Share and accept documents securely.", slug="home") root_page = Page.objects.get(title='Root') root_page.add_child(instance=home_page) site = Site.objects.create(site_name='SecureDrop.org (Dev)', hostname='localhost', port='8000', root_page=home_page, is_default_site=True) image = CustomImage.objects.filter(title='Sample Image').first() if not image: image = CustomImage.objects.create( title='Sample Image', file=ImageFile(open( 'common/static/images/logo_solid_white.png', 'rb'), name='logo'), attribution='createdevdata') sssettings = SocialSharingSEOSettings.for_site(site) sssettings.default_description = 'SecureDrop' sssettings.default_image = image sssettings.save() home_page.save() site.save() management.call_command('createblogdata', '10') management.call_command('createdirectory', '10') management.call_command('createnavmenu') management.call_command('createfootersettings') management.call_command('createresultgroups') management.call_command('createsearchmenus') # Create superuser if not User.objects.filter(is_superuser=True).exists(): User.objects.create_superuser( 'test', 'test@securedrop', 'test', ) self.stdout.write('Superuser created:\n' '\tname: test\n' '\temail: test@securedrop\n' '\tpassword: test')
def test_non_routable_wagtail_page(self): # Wagtail can only route a page if it starts with the same # path as Site.root_page.url, which in the case of this test # is '/', so the non-routable URL should not start with '/'. page = HomePageFactory.build(path='non_root_route') index_wagtail_page(page) # Document should not be created nor errors raised self.assertEqual( SearchDocument.objects.filter( key=KEY_FORMAT.format(page.pk)).count(), 0)
def setUp(self): Page.objects.filter(slug='home').delete() home_page = HomePageFactory.build( description_header="Share and accept documents securely.", slug="home") root_page = Page.objects.get(title='Root') root_page.add_child(instance=home_page) Site.objects.create(site_name='SecureDrop.org (Dev)', hostname='localhost', port='8000', root_page=home_page, is_default_site=True) self.blog_index = BlogIndexPageFactory(parent=home_page, search_description="Search me!") self.blog_index.save() self.blog = BlogPageFactory(parent=self.blog_index) BlogPageFactory(parent=self.blog_index) self.client = Client() response = self.client.get("{}feed/".format(self.blog_index.url)) self.parsed = feedparser.parse(response.content)
def setUp(self): self.root_page = Page.add_root(instance=Page(title="Root")) self.page = HomePageFactory.build() self.root_page.add_child(instance=self.page)
def handle(self, *args, **options): if options['delete']: Page.objects.filter(slug='home').delete() try: HomePage.objects.get(slug='home') except ObjectDoesNotExist: Page.objects.filter(slug='home').delete() # homepage cannot be saved without a parent home_page = HomePageFactory.build( description_header="Share and accept documents securely.", slug="home") root_page = Page.objects.get(title='Root') root_page.add_child(instance=home_page) site = Site.objects.create(site_name='SecureDrop.org (Dev)', hostname='localhost', port='8000', root_page=home_page, is_default_site=True) image = CustomImage.objects.filter(title='Sample Image').first() if not image: image = CustomImage.objects.create( title='Sample Image', file=ImageFile(open( 'common/static/images/logo_solid_white.png', 'rb'), name='logo'), attribution='createdevdata') sssettings = SocialSharingSEOSettings.for_site(site) sssettings.default_description = 'SecureDrop' sssettings.default_image = image sssettings.save() home_page.save() site.save() # IMAGES icon_collection = wagtail_factories.CollectionFactory(name='Icons') if options.get('download_images', True): self.stdout.write('Fetching images') self.stdout.flush() image_fail = False for i in range(15): if not self.fetch_image(500, 500, icon_collection, 'animals'): image_fail = True if image_fail: self.stdout.write( self.style.NOTICE('NOTICE: Some images failed to save')) else: self.stdout.write(self.style.SUCCESS('OK')) else: faker = factory.faker.Faker._get_faker(locale='en-US') for i in range(20): CustomImageFactory.create( file__width=500, file__height=500, file__color=faker.safe_color_name(), collection=icon_collection, ) management.call_command('createblogdata', '10') management.call_command('createdirectory', '10') management.call_command('createnavmenu') management.call_command('createfootersettings') management.call_command('createresultgroups') management.call_command('createsearchmenus') management.call_command('createmarketing') # Create superuser if not User.objects.filter(is_superuser=True).exists(): User.objects.create_superuser( 'test', 'test@securedrop', 'test', ) self.stdout.write('Superuser created:\n' '\tname: test\n' '\temail: test@securedrop\n' '\tpassword: test')