Exemplo n.º 1
0
def addMenuItemToComposit(compositKey, menuItemKey):
	composit = Composit.get(compositKey)
	menuItem = MenuItem.get(menuItemKey)
	compositItem = CompositMenuItemListItem()
	compositItem.menuItem = menuItem
	compositItem.composit = composit
	compositItem.put()
	modifyComposit(composit)
Exemplo n.º 2
0
	def get(self):
		if not isUserAdmin(self):
			self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
			self.redirect("/")
			return
		composits = Composit.all()
		template_values = {
			'composits' : composits
		}
		template = jinja_environment.get_template('templates/csv/compositList.download')
		self.response.out.write(template.render(template_values))
Exemplo n.º 3
0
	def post(self):
		if not isUserCook(self):
			self.redirect("/")
			return
		else:
			day = getFormDate(self)
			compositKey=self.request.get('compositKey')
			if ((compositKey != None) and (compositKey != "")):
				composit=Composit.get(compositKey)
				if (composit != None):
					if composit.occurrences.count()==0:
						#Save new price
						composit.price = int(self.request.get('price'))
						composit.put()
						modifyComposit(composit)
			self.redirect("/menuEdit?day="+str(day))
Exemplo n.º 4
0
def getComposit(key):
	client = memcache.Client()
	composit = client.get(key)
	if composit == None:
		try:
			compositDb = Composit.get(key)
			if compositDb == None:
				return None
		except:
			return None
		composit = createCompositData(compositDb)
		client.set(key,composit)
	# Fetch menu item data for keys
	composit['category'] = getDishCategory(composit['categoryKey'])
	composit['components'] = fetchMenuItemsForComposit(composit)
	return composit
Exemplo n.º 5
0
def getDaysComposits(day, categoryKey):
	client = memcache.Client()
	key = COMPOSIT_FOR_DAY+ str(day) + "_" + str(categoryKey)
	daysItems = client.get(key)
	if daysItems == None:
		composits = Composit.all().filter("day = ", day).filter("categoryKey = ", categoryKey)
		daysItems=[]
		for composit in composits:
			compositObject = createCompositData(composit)
			client.set(compositObject['key'], compositObject)
			daysItems.append(compositObject)
		client.set(key,daysItems)
	retItems = []
	# Fetch menu item data for keys
	for composit in daysItems:
		composit['components'] = fetchMenuItemsForComposit(composit)
		retItems.append(composit)
	return retItems
Exemplo n.º 6
0
	def post(self):
		if not isUserCook(self):
			self.redirect("/")
			return
		else:
			day = getFormDate(self)
			#Deletes a dish from current days menu
			compositKey=self.request.get('compositKey')
			if ((compositKey != None) and (compositKey != "")):
				composit=Composit.get(compositKey)
				if composit != None and composit.occurrences.count() == 0:
					for component in composit.components:
						component.delete()
					composit.delete()
					deleteComposit(composit)
				else:
					composit.active = False
					composit.put()
					modifyComposit(composit)
			self.redirect("/menuEdit?day="+str(day))
Exemplo n.º 7
0
def addComposit(categoryKey, day):
	# Add it to database
	composit = Composit()
	composit.day=day
	composit.category=DishCategory.get(categoryKey)
	composit.price = composit.category.basePrice
	composit.categoryKey=str(categoryKey)
	composit.put()
	# Adds it to cache
	client = memcache.Client()
	key = COMPOSIT_FOR_DAY+ str(composit.day) + "_" + str(composit.categoryKey)
	daysComposits = client.get(key)
	#If we have something to update
	if daysComposits != None:
		# Just add this menu item
		compositObject = createCompositData(composit)
		daysComposits.append(compositObject)
		client.set(compositObject['key'], compositObject)
		client.set(key,daysComposits)