def test_authors_few(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve')] doc = pq(self.table.render_authors(row)) assert doc('span').text() == 'bob steve' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url( 123, username='******') assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url( 456, username='******') assert doc('span').attr('title') == 'bob steve'
def test_authors_few(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve')] doc = pq(self.table.render_authors(row)) assert doc('span').text() == 'bob steve' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url( 123, username='******') assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url( 456, username='******') assert doc('span').attr('title') == 'bob steve'
def test_authors_four(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve'), (789, 'cvan'), (999, 'basta')] doc = pq(self.table.render_authors(row)) assert doc.text() == 'bob steve cvan ...' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url( 123, username='******') assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url( 456, username='******') assert doc('span a:eq(2)').attr('href') == UserProfile.create_user_url( 789, username='******') assert doc('span').attr('title') == 'bob steve cvan basta', doc.html()
def test_authors_four(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve'), (789, 'cvan'), (999, 'basta')] doc = pq(self.table.render_authors(row)) assert doc.text() == 'bob steve cvan ...' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url( 123, username='******') assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url( 456, username='******') assert doc('span a:eq(2)').attr('href') == UserProfile.create_user_url( 789, username='******') assert doc('span').attr('title') == 'bob steve cvan basta', doc.html()
def location(self, item): urlargs = '&'.join( ([f'page_e={item.extension_page}'] if item.extension_page > 1 else []) + ([f'page_t={item.theme_page}'] if item.theme_page > 1 else [])) return UserProfile.create_user_url( item.id) + (f'?{urlargs}' if urlargs else '')
def render_authors(self, record): authors = record.authors if not len(authors): return '' more = ' '.join( safe_substitute(u'%s', uname) for (_, uname) in authors) author_links = ' '.join( safe_substitute(u'<a href="%s">%s</a>', UserProfile.create_user_url(id_), uname) for (id_, uname) in authors[0:3]) return u'<span title="%s">%s%s</span>' % (more, author_links, ' ...' if len(authors) > 3 else '')
def render_authors(self, record): authors = record.authors if not len(authors): return '' more = ' '.join( safe_substitute(u'%s', uname) for (_, uname) in authors) author_links = ' '.join( safe_substitute(u'<a href="%s">%s</a>', UserProfile.create_user_url(id_), uname) for (id_, uname) in authors[0:3]) return u'<span title="%s">%s%s</span>' % ( more, author_links, ' ...' if len(authors) > 3 else '')