def _setUpVeterisSubsite(self): main = getPage("/home/") home = Page(slug="veteris", title="Veteris Council") main.add_child(instance=home) home.save_revision().publish() activities = Page(slug="activities", title="Veteris Calendar") home.add_child(instance=activities) activities.save_revision().publish() Site.objects.create(hostname='veteris.joy.test', root_page_id=home.id, is_default_site=False) events = CalendarPage(owner=self.user, slug="veteris-events", title="Veteris Events") home.add_child(instance=events) events.save_revision().publish() committee = RecurringEventPage(owner=self.user, slug="veteris-committee", title="Committee Meeting", repeat=Recurrence( dtstart=dt.date(1970, 1, 5), freq=MONTHLY, byweekday=[MO], until=dt.date(1978, 8, 7)), time_from=dt.time(14), time_to=dt.time(15)) events.add_child(instance=committee) committee.save_revision().publish()
def testFromUnsupported(self): page = Page(owner=self.user, slug="thoughts", title="My thoughts for today") self.home.add_child(instance=page) page.save_revision().publish() with self.assertRaises(CalendarTypeError): VCalendar.fromPage(page, self._getRequest("/thoughts/"))
def handle(self, *args, **options): # Get blogpage content type blogpage_content_type, created = ContentType.objects.get_or_create( model='blogpage', app_label='blog', defaults={'name': 'page'} if DJANGO_VERSION < (1, 8) else {}) # Get root page rootpage = Page.objects.first() # Set site root page as root site page site = Site.objects.first() site.root_page = rootpage site.save() # Create example blog page blogpage = Page( title="Blog", content_type=blogpage_content_type, slug='blog', ) # Add blog page as a child for homepage rootpage.add_child(instance=blogpage) revision = blogpage.save_revision() revision.publish()
def _setUpNovaSubsite(self): main = getPage("/home/") home = Page(slug="nova", title="Nova Homepage") main.add_child(instance=home) home.save_revision().publish() activities = Page(slug="activities", title="Nova Activities") home.add_child(instance=activities) activities.save_revision().publish() Site.objects.create(hostname='nova.joy.test', root_page_id=home.id, is_default_site=False) events = CalendarPage(owner=self.user, slug="nova-events", title="Nova Events") home.add_child(instance=events) events.save_revision().publish() committee = RecurringEventPage(owner=self.user, slug="executive-meeting", title="Executive Committee Meeting", repeat=Recurrence(dtstart=dt.date( 1984, 8, 5), freq=WEEKLY, byweekday=[TH]), time_from=dt.time(13), time_to=dt.time(15)) events.add_child(instance=committee) committee.save_revision().publish() event = SimpleEventPage(owner=self.user, slug="rubbish-blitz", title="Rubbish Blitz", date=dt.date(1984, 9, 13), time_from=dt.time(12, 30), time_to=dt.time(17)) events.add_child(instance=event) event.save_revision().publish() cancellation = CancellationPage( owner=self.user, slug="1984-09-13-cancellation", title="Cancellation for Thursday 13th of September", overrides=committee, except_date=dt.date(1984, 9, 13), cancellation_title="Meeting Cancelled", cancellation_details="The committee will be at " "the working bee") committee.add_child(instance=cancellation) cancellation.save_revision().publish()
class SearchTestCase(TestCase): def setUp(self) -> None: self.user = get_user_model().objects.create_user( 'Test User', '*****@*****.**', 'password') self.user.groups.add(Group.objects.get(name="Moderators")) self.client.force_login(self.user) self.default_site = Site.objects.get(id=1) self.root_page = Page.objects.get(id=1) self.training_root_page = Page(owner=self.user, slug='Test', title='Test') self.root_page.add_sibling(instance=self.training_root_page) PageViewRestriction.objects.create(page=self.training_root_page, restriction_type='password', password='******') self.training_root_page.save_revision().publish() self.training_site = Site(hostname='localhost', port='8000', site_name='Training', root_page=self.training_root_page) self.training_site.save() self.factory = RequestFactory() def test_search_does_not_return_training_pages(self): """ Searches should not return results from the Wagtail "Training" Site. """ request = self.factory.get(reverse('search'), {'query': 'Test'}) request.user = AnonymousUser() response = search(request) self.assertNotContains( response, '<h4><a href="http://localhost:8000/">Test</a></h4>')
class TestMultiCalendarCreate(TestCase): def setUp(self): self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.main = getPage("/home/") self.sub = Page(slug="nova", title="Nova Homepage") self.main.add_child(instance=self.sub) self.sub.save_revision().publish() Site.objects.create(hostname='nova.joy.test', root_page_id=self.sub.id, is_default_site=False) SpecificCalendarPage.is_creatable = True GeneralCalendarPage.is_creatable = True def testMainSiteAnotherCalendar(self): calendar = CalendarPage( owner=self.user, slug="events", title="Events", ) self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertFalse(CalendarPage.can_create_at(self.main)) def testSubSiteAnotherCalendar(self): calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertTrue(CalendarPage.can_create_at(self.sub)) def testNoSiteAnotherCalendar(self): rogue = Page(slug="rogue", title="Rogue") self.assertFalse(CalendarPage.can_create_at(rogue)) def testMainSiteAnotherSpecificCalendar(self): calendar = SpecificCalendarPage(owner=self.user, slug="events", title="Events") self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertTrue(SpecificCalendarPage.can_create_at(self.main)) def testMainSiteAnotherGeneralCalendar(self): calendar = GeneralCalendarPage( owner=self.user, slug="events", title="Events", ) self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertFalse(GeneralCalendarPage.can_create_at(self.main)) def testSubSiteAnotherGeneralCalendar(self): calendar = GeneralCalendarPage( owner=self.user, slug="events", title="Events", ) self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertFalse(GeneralCalendarPage.can_create_at(self.sub)) def testCalendarMixture(self): general = GeneralCalendarPage( owner=self.user, slug="events1", title="Events", ) self.main.add_child(instance=general) general.save_revision().publish() self.assertTrue(CalendarPage.can_create_at(self.main)) calendar = CalendarPage( owner=self.user, slug="events2", title="Events", ) self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertTrue(SpecificCalendarPage.can_create_at(self.main)) specific = SpecificCalendarPage(owner=self.user, slug="events3", title="Events") self.main.add_child(instance=specific) specific.save_revision().publish()