def test_actor_has_email_view(self): chrome = Chrome(self.env) req = MockRequest(self.env, authname='user1') self.assertEqual('<span class="trac-author">[email protected]</span>', unicode(chrome.authorinfo(req, '*****@*****.**'))) self.assertEqual('<span class="trac-author">User One <[email protected]></span>', unicode(chrome.authorinfo(req, 'User One <*****@*****.**>'))) self.assertEqual('<span class="trac-author">user</span>', str(chrome.authorinfo_short('User One <*****@*****.**>'))) self.assertEqual('<span class="trac-author">user</span>', str(chrome.authorinfo_short('*****@*****.**')))
def test_subject_is_none(self): chrome = Chrome(self.env) req = MockRequest(self.env) self.assertEqual('<span class="trac-author">(none)</span>', str(chrome.authorinfo(req, '(none)'))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo(req, None))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo(req, ''))) self.assertEqual('<span class="trac-author">(none)</span>', str(chrome.authorinfo_short('(none)'))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo_short(None))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo_short('')))
def test_subject_is_anonymous(self): chrome = Chrome(self.env) req = MockRequest(self.env) self.assertEqual('<span class="trac-author-anonymous">anonymous</span>', str(chrome.authorinfo(req, 'anonymous'))) self.assertEqual('<span class="trac-author-anonymous">anonymous</span>', str(chrome.authorinfo_short('anonymous')))
def test_authorinfo(self): chrome = Chrome(self.env) req = Request() self.assertEqual( '<span class="trac-author-anonymous">anonymous</span>', str(chrome.authorinfo(req, 'anonymous'))) self.assertEqual('<span class="trac-author">(none)</span>', str(chrome.authorinfo(req, '(none)'))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo(req, None))) self.assertEqual('<span class="trac-author-none">(none)</span>', str(chrome.authorinfo(req, ''))) self.assertEqual('<span class="trac-author">[email protected]</span>', str(chrome.authorinfo(req, '*****@*****.**'))) self.assertEqual( '<span class="trac-author">User One <[email protected]></span>', str(chrome.authorinfo(req, 'User One <*****@*****.**>')))
def get_timeline_markup(self, req, call, maxrows=10): """ Generates the markup needed when this component is called both explicitly inside wiki pages and implicitly by the ISideBarBoxProvider. Note this code uses methods from the trac TimelineModule module. """ chrome = Chrome(self.env) # last 14 days should be enough stop = datetime.now(req.tz) start = stop - timedelta(days=50) # use code from trac/timeline to generate event data timeline = TimelineModule(self.env) available_filters, filters = timeline.get_filters(req) include_authors, exclude_authors = timeline.authors() events = timeline.get_events(req, start, stop, filters, available_filters, include_authors, exclude_authors, maxrows) show_gravatar = self.config.get('avatar','mode').lower() != 'off' # create the mark up context = Context.from_request(req) event_list = tag.ul(class_="timeline-list no-style") for event in events: event_title = event['render']('title', context) event_url = event['render']('url', context) event_list.append(tag.li( show_gravatar and tag.img( src=req.href.avatar(event['author'] if event['author'] else 'anonymous'), class_="avatar", ) or "", tag.span( chrome.authorinfo(req, event['author']), class_="author" ), tag.span( pretty_age(event['date']), class_="date", ), tag.div( tag.i(class_="event-type fa fa-" + event['kind']), tag.a( event_title, href=event_url, ), class_="event-summary" ), class_="cf" )) # if the markup is being generated via ISideBarBoxProvider we don't # need to add a span3 class div_classes = "box-sidebar" if call == "macro": div_classes += " span3 right" return tag.div( tag.h3( tag.i( class_="fa fa-calendar" ), " Recent Project Activity" ), event_list, class_=div_classes, )