Exemplo n.º 1
0
def build(locations, roles, schedule, startDate, tab):
	"""
	Formats the given data and generates the html page
	"""
	calendar = ""

	def curTab(day):
		return "curTab" if day == tab else "tab"

	params = { "%PREV_WEEK%":util.startOfPrevWeek(startDate),
	"%NEXT_WEEK%":util.startOfNextWeek(startDate),
	"%START_WEEK%":util.toDateStr(util.startOfWeek(startDate),True),
	"%END_WEEK%":util.toDateStr(util.endOfWeek(startDate),True),
	"%M%": curTab(0),
	"%T%": curTab(1),
	"%W%": curTab(2),
	"%R%": curTab(3),
	"%F%": curTab(4),
	"%S%": curTab(5),
	}
	
	#build the calendar
	for i,day in enumerate(schedule):
		
		calendar += buildDay(locations, roles, day, util.addDays(startDate, i))
		
	#add the body of the page
	params["%CAL_BODY%"] = calendar
		
	return view.render("ui/webCal.html", params, tab=tab)
Exemplo n.º 2
0
def build( appointmentList, startOfWeek, location ):
	"""
	Formats and returns the html for the detailed list
	appointmentList - a list of days, each day is a list of appointments for that day
	startOfWeek - a datetime object that represents the start of the week
	location - the location to list the appointments for
	"""

	DAY_TEMPLATE = "<li class=\"important\">%s %s</li>\n"
	APP_TEMPLATE = "<li><a %s href=\"editAppointment?name=%s&time=%s\">%s %s %s</a></li>\n"
	EMPTY_TEMPLATE = "<li><a href=\"editAppointment?time=%s\">No Appointments</a></li>\n"

	appList = ""
	params = {"%LOCATION%":location}

	#display the appointments for each day
	for i,dayList in enumerate(appointmentList):
	
		datetime = util.addDays(startOfWeek, i)
		
		#generate the header for the day
		appList += DAY_TEMPLATE % ( util.toDayName(datetime), util.toDateStr(datetime, True) )
		
		#if there are any appointments for the day then show them
		if len(dayList):
		
			#generate the html for each appointment
			for app in sorted(dayList, timeCompare):
				appList += APP_TEMPLATE % ("class=\"booked\"" if app.isBooked() else "", app.staffName, app.time, app.getFTime(), app.staffName, "- " + app.description if app.description else "")
		
		#else show a place holder
		else:
			appList += EMPTY_TEMPLATE % datetime
	
	#add the scheduled appointments to the page
	params["%THE_LIST%"] = appList
		
	return view.render("ui/daydetails.html", params)