def index(self, **kw): if not c.user.is_anonymous(): user = c.user sections = [section(user) for section in SectionsUtil.load_sections('personal_dashboard')] return dict(user=user, sections=sections, title="Personal Dashboard") else: redirect('/neighborhood')
def index(self, **kw): if not c.user.is_anonymous(): user = c.user sections = [ section(user) for section in SectionsUtil.load_sections('personal_dashboard') ] return dict(user=user, sections=sections, title="Personal Dashboard") else: redirect('/neighborhood')
def profile_sections(self): """ Loads and caches user profile sections from the entry-point group ``[allura.user_profile.sections]``. Profile sections are loaded unless disabled (see `allura.lib.helpers.iter_entry_points`) and are sorted according to the `user_profile_sections.order` config value. The config should contain a comma-separated list of entry point names in the order that they should appear in the profile. Unknown or disabled sections are ignored, and available sections that are not specified in the order come after all explicitly ordered sections, sorted randomly. """ if hasattr(UserProfileApp, '_sections'): return UserProfileApp._sections UserProfileApp._sections = SectionsUtil.load_sections('user_profile') return UserProfileApp._sections
def test_dashboard_sections(self): def ep(n): m = mock.Mock() m.name = n m.load()().display.return_value = 'Section %s' % n return m eps = map(ep, ['a', 'b', 'c', 'd']) order = {'personal_dashboard_sections.order': 'b, d,c , f '} with mock.patch('allura.lib.helpers.iter_entry_points') as iep: with mock.patch.dict(tg.config, order): iep.return_value = eps sections = SectionsUtil.load_sections('personal_dashboard') assert_equal(sections, [ eps[1].load(), eps[3].load(), eps[2].load(), eps[0].load() ]) r = self.app.get('/dashboard') assert_in('Section a', r.body) assert_in('Section b', r.body) assert_in('Section c', r.body) assert_in('Section d', r.body) assert_not_in('Section f', r.body)
def test_dashboard_sections(self): def ep(n): m = mock.Mock() m.name = n m.load()().display.return_value = 'Section %s' % n return m eps = map(ep, ['a', 'b', 'c', 'd']) order = {'personal_dashboard_sections.order': 'b, d,c , f '} with mock.patch('allura.lib.helpers.iter_entry_points') as iep: with mock.patch.dict(tg.config, order): iep.return_value = eps sections = SectionsUtil.load_sections('personal_dashboard') assert_equal(sections, [ eps[1].load(), eps[3].load(), eps[2].load(), eps[0].load()]) r = self.app.get('/dashboard') assert_in('Section a', r.body) assert_in('Section b', r.body) assert_in('Section c', r.body) assert_in('Section d', r.body) assert_not_in('Section f', r.body)