Following code was sent to me by Marcus Priesch. I modified it for Roundup 0.8. I am assuming you have added a Date field called 'deadline' to your 'issue' class.
This customization is structured as follows: A file called '_generic.calendar.html' in the 'html' folder of your tracker home, a file called 'datehelp.py' in the 'extensions' folder of your tracker home, and code to display the link in your item template.
To display the link for the DateHelp in your item template use following tag: '<span tal:content="structure python:utils.date_help(request, context.deadline)"/>' Put the tag in your 'issue.item.html' template.
The 'utils.date_help' call has following arguments:
- *request*: The request object. Just leave this.
- *item*: The name of the property you wish to modify. Should probably be of the form 'context.property'
- *width*: (optional) The width of the popup window, default=300
- *height*: (optional) The height of the popup window, default=200
- *label*: (optional) The link text to display, default="(cal)"
- *form*: (optional) The form to write the selected date back to, default="itemSynopsis"
In the html folder of your tracker home add a file called '_generic.calendar.html' with following contents::
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html>
<head>
<link rel="stylesheet" type="text/css" href="@@file/style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8;" /> <title tal:content="string:Roundup Calendar"></title> <disabled script language="Javascript"
- type="text/javascript" tal:content="structure string: // this is the name of the field in the original form that we're working on form = window.opener.document.${request/form/form/value};
field = '${request/form/property/value}';" >
<disabled /script>
- type="text/javascript" tal:content="structure string: // this is the name of the field in the original form that we're working on form = window.opener.document.${request/form/form/value};
</head> <body class="body"
tal:content="structure python:utils.html_calendar (request)">
</body>
</html>
In the extensions folder of your tracker home add a file called 'datehelp.py' with following contents::
- from roundup import date import calendar import time r_date = date def date_help ( request
- , item , width = 300 , height = 200 , label = "(cal)" , form = "itemSynopsis" ) :
- """dump out the link to a calendar pop-up window item: HTMLProperty e.g.: context.deadline """ if item.isset () :
date = "&date=%s" % item
- date = ""
return ( """<a class="classhelp" """
- """href="javascript:help_window """
- """('%s?@template=calendar"""
"""&property=%s""" """&form=%s%s', %d, %d)">%s</a>""" % ( request.classname
- , item._name , form , date , width , height , label )
- """returns a html calendar.
request the roundup.request object
- - @template : name of the template - form : name of the form to store back the date - property : name of the property of the form to store
- back the date
res.append ("""<table class="calendar">""")
base_link = "%s?@template=%s&property=%s&form=%s&date=%s" % \
- (request.classname, template, property, form, curr_date)
res.append (""" <tr>""") res.append (""" <td>""") res.append (""" <table width="100%" class="calendar_nav">""") res.append (""" <tr>""") link = base_link + "&display=%s" % date_prev_month res.append (""" <td><a href="%s"><</a></td>""" % link) res.append (""" <td>%s</td>""" % calendar.month_name [month]) link = base_link + "&display=%s" % date_next_month res.append (""" <td><a href="%s">></a></td>""" % link) # spacer res.append (""" <td width="100%"></td>""") # year link = base_link + "&display=%s" % date_prev_year res.append (""" <td><a href="%s"><</a></td>""" % link) res.append (""" <td>%s</td>""" % year) link = base_link + "&display=%s" % date_next_year res.append (""" <td><a href="%s">></a></td>""" % link) res.append (""" </tr>""") res.append (""" </table>""") res.append (""" </td>""") res.append (""" </tr>""") # the calendar
res.append (""" <tr>""") res.append (""" <td>""") res.append (""" <table class="calendar_display">""") res.append (""" <tr class="weekdays">""") for day_ in calendar.weekheader (3).split () :
- res.append \
(""" <td>%s</td>""" % day_)
res.append (""" </tr>""") for week_ in calendar.monthcalendar (year, month) :
- res.append \
(""" <tr>""")
- link = "javascript:form[field].value = '%d-%02d-%02d'; " \
- "window.close ();" % (year, month, day_)
- month == curr_date.month and \ year == curr_date.year :
- # highlight style = "today"
- style = ""
- res.append \
(""" <td class="%s"><a href="%s">%s</a></td>""" %
- (style, link, day_))
- res.append \
(""" <td></td>""")
(""" </tr>""")
res.append (""" </table>""") res.append (""" </tb>""") res.append (""" </tr>""") res.append ("""</table>""") return "\n".join (res)
- - @template : name of the template - form : name of the form to store back the date - property : name of the property of the form to store
- instance.registerUtil('date_help', date_help) instance.registerUtil('html_calendar', html_calendar)