Exemplo n.º 1
0
	def get(self):
		if not isUserCook(self):
			self.redirect("/")
			return
		day = getBaseDate(self)
		#Organize into days
		menu=[]
		dishCategories=getDishCategories()
		monday = getMonday(day)
		days=[]
		for i in range(0,5):
			actualDay=monday+datetime.timedelta(days=i)
			days.append(getDay(actualDay, i, getDaysAvailableMenuItems(actualDay)))
		for category in dishCategories:
			if not category['canBeTopLevel']:
				continue
			actualCategoryObject={}
			actualCategoryObject['category']=category
			categoryKey=category['key']
			dishes = getCategoryWithDishes(category['key'])['dishes']
			availableDishes=sorted(dishes, key=lambda dish: dish['title'])
			actualCategoryObject['availableDishes']=availableDishes
			items=[]
			for i in range(0,5):
				actualDay=monday+datetime.timedelta(days=i)
				items.append(getDaysItemsForCategory(categoryKey, actualDay, i, days[i]["availableMenuItems"]))
			actualCategoryObject["days"]=items
			menu.append(actualCategoryObject)
		# A single dish with editable ingredient list
		prevMonday=monday+datetime.timedelta(days = -7)
		nextMonday=monday+datetime.timedelta(days = 7)
		today=datetime.date.today()
		actualMonday = getMonday(today)
		allDishes=getDishes()
		template_values = {
			'days':days,
			'prev':prevMonday,
			'next':nextMonday,
			'actual':actualMonday,
			'menu':menu,
			'allDishes':allDishes
		}
		template = jinja_environment.get_template('templates/menuEdit.html')
		self.printPage(str(day), template.render(template_values), False, False)
Exemplo n.º 2
0
	def get(self):
		if not isUserCook(self):
			self.redirect("/")
			return
		day = getBaseDate(self)
		#Determine the week
		nextCalendar=day.isocalendar()
		#Organize into days
		dayIndex=nextCalendar[2]-1
		availableMenuItems = getDaysAvailableMenuItems(day)
		days = []
		days.append(getDay(day, dayIndex, availableMenuItems))
		menu = getMenu(day, dayIndex, availableMenuItems)
		# A single dish with editable ingredient list
		prevDay=day+datetime.timedelta(days=-1)
		nextDay=day+datetime.timedelta(days=1)
		nextCalendar=nextDay.isocalendar()
		#Organize into days
		if nextCalendar[2]==6:
			nextDay=nextDay+datetime.timedelta(days=2)
		elif nextCalendar[2]==7:
			nextDay=nextDay+datetime.timedelta(days=1)
		prevCalendar=prevDay.isocalendar()
		#Organize into days
		if prevCalendar[2]==6:
			prevDay=prevDay+datetime.timedelta(days=-1)
		elif prevCalendar[2]==7:
			prevDay=prevDay+datetime.timedelta(days=-2)
		allDishes=getDishes()
		template_values = {
			'days':days,
			'prev':prevDay,
			'next':nextDay,
			'menu':menu,
			'allDishes':allDishes
		}
		template = jinja_environment.get_template('templates/menuEdit.html')
		self.printPage(str(day), template.render(template_values), False, False)