made wiki link optional

This commit is contained in:
Stefan Kögl 2012-04-25 08:35:33 +02:00
parent 8616aa27a0
commit a2af77f9f3
4 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/" xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude"> xmlns:xi="http://www.w3.org/2001/XInclude">
<py:def function="render_event(event, with_day=False)"> <py:def function="render_event(event, with_day=False, wiki_on=True)">
<h2>${event.name}<span py:if="'EVENTS_MODIFY' in perm" class="edit"><a style="color:#f00;" href="${href.event('edit', event.e_id)}">edit</a></span></h2> <h2>${event.name}<span py:if="'EVENTS_MODIFY' in perm" class="edit"><a style="color:#f00;" href="${href.event('edit', event.e_id)}">edit</a></span></h2>
<table py:with="dt = selected_tz.normalize(event.time_begin.astimezone(selected_tz));dt2 = selected_tz.normalize(event.time_end.astimezone(selected_tz))"> <table py:with="dt = selected_tz.normalize(event.time_begin.astimezone(selected_tz));dt2 = selected_tz.normalize(event.time_end.astimezone(selected_tz))">
<tr> <tr>
@ -22,7 +22,7 @@
<td headers="h_coordinates"><a href="${'http://www.openstreetmap.org/index.html?mlat=%s&amp;mlon=%s&amp;zoom=15&amp;layers=B00TTT' % (event.location.lat, event.location.lon)}">${event.location.coordinate_str()}</a></td> <td headers="h_coordinates"><a href="${'http://www.openstreetmap.org/index.html?mlat=%s&amp;mlon=%s&amp;zoom=15&amp;layers=B00TTT' % (event.location.lat, event.location.lon)}">${event.location.coordinate_str()}</a></td>
</tr> </tr>
</py:if> </py:if>
<tr> <tr py:if="wiki_on">
<td headers="wiki_link"><a href="${href.wiki(event.wikipage)}">wiki page</a></td> <td headers="wiki_link"><a href="${href.wiki(event.wikipage)}">wiki page</a></td>
</tr> </tr>
</table> </table>

View File

@ -19,7 +19,7 @@
<div py:otherwise="" class="unique">E<br/>I<br/>N<br/>Z<br/>E<br/>L<br/>T<br/>E<br/>R<br/>M<br/>I<br/>N</div> <div py:otherwise="" class="unique">E<br/>I<br/>N<br/>Z<br/>E<br/>L<br/>T<br/>E<br/>R<br/>M<br/>I<br/>N</div>
</py:choose> </py:choose>
<div class="event-intern"> <div class="event-intern">
${render_event(event, True)} ${render_event(event, True, wiki_on)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -27,7 +27,7 @@
<td py:if="eventlist != False" class="${isinstance(eventlist, list) and 'upcoming-event' or 'upcoming'}" rowspan="${eventlist.rowspan and eventlist.rowspan or None}"> <td py:if="eventlist != False" class="${isinstance(eventlist, list) and 'upcoming-event' or 'upcoming'}" rowspan="${eventlist.rowspan and eventlist.rowspan or None}">
<py:if test="eventlist != True"> <py:if test="eventlist != True">
<py:for each="event in eventlist"> <py:for each="event in eventlist">
${render_event(event)} ${render_event(event, wiki_on=wiki_on)}
</py:for> </py:for>
</py:if> </py:if>
</td> </td>

View File

@ -24,6 +24,7 @@ from trac.util.datefmt import get_timezone, utc, format_time, localtz
from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet, add_warning, add_notice, add_ctxtnav, add_script, add_link, Chrome from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet, add_warning, add_notice, add_ctxtnav, add_script, add_link, Chrome
from trac.web import IRequestHandler from trac.web import IRequestHandler
from trac.wiki import IWikiSyntaxProvider from trac.wiki import IWikiSyntaxProvider
from trac.wiki.web_ui import WikiModule
from dateutil import rrule from dateutil import rrule
from genshi.builder import tag from genshi.builder import tag
@ -728,7 +729,7 @@ class EventModule(Component):
events = sorted(events, key=attrgetter("time_begin")) events = sorted(events, key=attrgetter("time_begin"))
title = _("Event Overview") title = _("Event Overview")
session_tzname, selected_tz = get_tz(req.session.get('tz', self.env.config.get("trac", "default_timezone") or None)) session_tzname, selected_tz = get_tz(req.session.get('tz', self.env.config.get("trac", "default_timezone") or None))
return "event_list.html", {"events" : events, "title" : title, "session_tzname" : session_tzname, "selected_tz" : selected_tz}, None return "event_list.html", {"wiki_on" : self.env.is_component_enabled(WikiModule), "events" : events, "title" : title, "session_tzname" : session_tzname, "selected_tz" : selected_tz}, None
def __display_upcoming_events(self, req): def __display_upcoming_events(self, req):
if req.args.get("format") == 'ical': if req.args.get("format") == 'ical':
@ -746,13 +747,13 @@ class EventModule(Component):
add_link(req, 'alternate', conversion_href, conversion[1], conversion[3], conversion[0]) add_link(req, 'alternate', conversion_href, conversion[1], conversion[3], conversion[0])
session_tzname, selected_tz = get_tz(req.session.get('tz', self.env.config.get("trac", "default_timezone") or None)) session_tzname, selected_tz = get_tz(req.session.get('tz', self.env.config.get("trac", "default_timezone") or None))
n = datetime.now(utc) n = utc.localize(datetime.utcnow())
n = n.replace(hour=0, minute=0, second=0, microsecond=0) n = n.replace(hour=0, minute=0, second=0, microsecond=0)
end = n + timedelta(183) end = n + timedelta(183)
end = end.replace(hour=23, minute=0, second=59, microsecond=999) end = end.replace(hour=23, minute=0, second=59, microsecond=999)
table, headers = self.__get_upcoming_table(n, end) table, headers = self.__get_upcoming_table(n, end)
return "events.html", {"table" : table, "headers" : headers, "session_tzname" : session_tzname, "format" : "%a, %d.%m.%Y", "selected_tz" : selected_tz, "title" : _("Upcoming Events for"), "title2" : "%s - %s" % (n.strftime('%A, %d.%m.%Y %H:%M'), end.strftime('%A, %d.%m.%Y %H:%M')), "now" : n, "end" : end}, None return "events.html", {"wiki_on" : self.env.is_component_enabled(WikiModule), "table" : table, "headers" : headers, "session_tzname" : session_tzname, "format" : "%a, %d.%m.%Y", "selected_tz" : selected_tz, "title" : _("Upcoming Events for"), "title2" : "%s - %s" % (n.strftime('%A, %d.%m.%Y %H:%M'), end.strftime('%A, %d.%m.%Y %H:%M')), "now" : n, "end" : end}, None
def __display_events_by_day(self, req): def __display_events_by_day(self, req):
add_stylesheet (req, 'hw/css/event.css') add_stylesheet (req, 'hw/css/event.css')