Example #1
def prefsPost(handler, p_default_sprint_tab, p_default_tasks_tab, p_backlog_style, p_messages = []):
	def die(msg):
		print msg

	handler.wrappers = False

	if not handler.session['user']:
		die("You must be logged in to modify preferences")
	if p_default_sprint_tab not in sprintTabs():
		die("Unrecognized default sprint tab <b>%s</b>" % stripTags(p_default_sprint_tab))
	if p_default_tasks_tab not in taskTabs:
		die("Unrecognized default task tab <b>%s</b>" % stripTags(p_default_tasks_tab))
	if set(p_backlog_style.keys()) != set(name for block in statusMenu for name in block):
		die("Backlog style key mismatch")
	if not set(p_messages.keys()) <= set(name for name, desc in messageTypes):
		die("Message type mismatch")

	prefs = handler.session['user'].getPrefs()
	prefs.defaultSprintTab = p_default_sprint_tab
	prefs.defaultTasksTab = p_default_tasks_tab
	prefs.backlogStyles = p_backlog_style
	prefs.messages = dict((name, name in p_messages.keys()) for name, desc in messageTypes)

	handler.responseCode = 299
	print "Saved changes"
Example #2
 def printSprint(sprint):
     if sprint.isActive() or sprint.isPlanning():
         print '<div class="sprint-active">'
         print '<div class="sprint-name">%s</div>' % sprint.link(handler.session["user"], "sprint-large")
         print '<div class="sprint-time">'
         if sprint.isPlanning():
             print '<span class="label danger">Planning</span>'
         elif sprint.isReview():
             print '<span class="label success">Review</span>'
             day = Weekday.today().date()
             sprintDays = [i.date() for i in sprint.getDays()]
             print '<span class="label primary">Day %d of %d</span>' % (
                 sprintDays.index(day) + 1,
         print "</div><br>"
         for tab in sprintTabs().group("").values():
             print '<a href="%s">%s</a>' % (tab.getPath(sprint.id), tab.getDisplayName().lower())
         if handler.session["user"] in sprint.members:
             print '<a href="/sprints/%d?search=assigned:me">your tasks</a>' % sprint.id
         print "</div>"
         print '<div class="sprint-summary">%s <span class="sprint-time">(%s - %s)</span></div>' % (
Example #3
def prefs(handler):
	requirePriv(handler, 'User')

	prefs = handler.session['user'].getPrefs()
	print "<script src=\"/static/prefs.js\" type=\"text/javascript\"></script>"
	print InfoBox('', id = 'post-status', close = True)
	print "<form method=\"post\" action=\"/prefs\">"

	print InfoBox("Note", "Your password and avatar are controlled from <a href=\"/users/%s\">your profile</a>" % handler.session['user'].username)

	print "<a name=\"default-sprint-tab\"></a>"
	print "<h3>Default Sprint Tab</h3>"
	print "Which tab you're taken to when following links in the project list:<br><br>"
	print "<select name=\"default_sprint_tab\">"
	for tab in sprintTabs().group('').values():
		print "<option value=\"%s\"%s>%s</option>" % (tab.name, ' selected' if tab.name == prefs.defaultSprintTab else '', tab.getDisplayName())
	print "</select>"

	print "<a name=\"default-tasks-tab\"></a>"
	print "<h3>Default Tasks Tab</h3>"
	print "Which tab you're taken to when adding a new backlog task:<br><br>"
	print "<select name=\"default_tasks_tab\">"
	for tab in taskTabs.group('').values():
		print "<option value=\"%s\"%s>%s</option>" % (tab.name, ' selected' if tab.name == prefs.defaultTasksTab else '', tab.getDisplayName())
	print "</select>"

	print "<h3>Backlog Style</h3>"
	print "How each task on the backlog is styled, based on status:<br><br>"
	select = ResponseWriter()
	print "<select name=\"backlog_style[%s]\">"
	for name in backlogStyles:
		print "<option value=\"%s\">%s</option>" % (name, name.title())
	print "</select>"
	select = select.done()

	tbl = LRTable()
	for statusBlock in statusMenu:
		for name in statusBlock:
			val = prefs.backlogStyles[name]
			tbl[statuses[name].text] = (select % name).replace("<option value=\"%s\">" % val, "<option value=\"%s\" selected>" % val)
	print tbl

	print "<h3>Messages</h3>"
	print "Which events will automatically notify you via system message:<br><br>"
	for name, desc in messageTypes:
		print "<input type=\"checkbox\" name=\"messages[%s]\" id=\"messages[%s]\"%s><label for=\"messages[%s]\">%s</label><br>" % (name, name, ' checked' if prefs.messages[name] else '', name, desc)

	print "<br>"
	print Button('Save', id = 'save-button', type = 'button').positive()
	print "</form>"