Пример #1
0
	def get(self):
		if not isUserDelivery(self):
			self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
			self.redirect("/")
			return	
		userKey = self.request.get("userKey")
		mondayString = self.request.get("monday")
		monday = datetime.datetime.strptime(mondayString, "%Y-%m-%d").date()
		user = User.get(userKey)
		if user == None:
			print "No user!"
			return
		weeks = user.weeks.filter("monday = ", monday)
		referenceWeek = weeks.get()
		days = []
		weekOrderTotal = 0
		weekDeliveryTotal = 0
		for i in range(0,5):
			day = {}
			actualDay = monday + datetime.timedelta(days=i)
			daysOrderItems = getOrderedItemsFromWeekData(weeks, actualDay)
			address=getOrderAddress(referenceWeek, actualDay)
			day['orderedItems'] = daysOrderItems
			day['day']=dayNames[i]
			day['date'] = actualDay
			orderedPrice = 0
			for orderedItem in daysOrderItems:
				try:
					orderedPrice = orderedPrice + orderedItem['price'] * orderedItem['orderedQuantity']
				except:
					pass
			weekOrderTotal = weekOrderTotal + orderedPrice
			day["orderedPrice"] = orderedPrice
			if len(daysOrderItems) > 0:
				day['address'] = address
				deliveryCost = 0
				if address != None:
					deliveryCost = getZipBasedDeliveryCost(address.zipNumCode, orderedPrice)
				day["deliveryCost"] = deliveryCost
				weekDeliveryTotal = weekDeliveryTotal + deliveryCost
			days.append(day)
		template_values = {
			'user':user,
			'days':days,
			'week':referenceWeek,
			'deliveryTotal':weekDeliveryTotal,
			'orderTotal':weekOrderTotal,
			'total':weekOrderTotal + weekDeliveryTotal,
		}
		prevMonday = monday + datetime.timedelta(days= -7)
		template_values['prev'] = prevMonday
		nextMonday = monday + datetime.timedelta(days= 7)
		template_values['next'] = nextMonday
		template = jinja_environment.get_template('templates/delivery.html')
		self.printPage(str(day), template.render(template_values), False, False)
Пример #2
0
	def get(self):
		if not isUserDelivery(self):
			self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
			self.redirect("/")
			return
		day=getBaseDate(self)
		calendar=day.isocalendar()
		#Organize into days
		dayTotal = 0
		dayCount = 0
		dayQuantity = 0
		dayObject={}
		dayObject["day"]=dayNames[calendar[2]-1]
		dayObject["date"]=day
		prevDay=day+datetime.timedelta(days=-1)
		nextDay=day+datetime.timedelta(days=1)
		today=datetime.date.today()
		monday = getMonday(day)
		weeks = UserWeekOrder.all().filter('monday = ', monday)
		deliveries = []
		for week in weeks:
			dailyUserTotal = 0
			items = getOrderedItemsFromWeekData([week], day)
			if len(items) > 0:
				for item in items:
					dayTotal = dayTotal + item['orderedQuantity'] * item['price']
					dailyUserTotal = dailyUserTotal + item['orderedQuantity'] * item['price']
				orderAddress = getOrderAddress(week, day)
				if orderAddress == None:
					orderAddress = week.user.addresses.get(0)
				orderAddress.comment = getOrderComment(week, day)
				orderAddress.orderedItems = items
				orderAddress.week = week
				orderAddress.dailyUserTotal = dailyUserTotal
				orderAddress.dailyUserDelivery = getZipBasedDeliveryCost(orderAddress.zipNumCode, dailyUserTotal)
				orderAddress.todayPaid = getPaid(week, day)
				orderAddress.weeklyPaid = getWeeklyPaid(week)
				orderAddress.weeklyTotal = getOrderTotal([week])
				orderAddress.weeklyDelivery = getWeeklyDelivery(week)
				deliveries.append(orderAddress)
		sortedDeliveries = sorted(deliveries, key=lambda item:item.zipNumCode)
		template_values = {
			'next':nextDay,
			'actual':today,
			'orders':sortedDeliveries,
			'day':dayObject,
			'dayTotal': dayTotal,
		}
		template_values['prev'] = prevDay
		template = jinja_environment.get_template('templates/deliveryReviewOrders.html')
		self.printPage(str(day), template.render(template_values), False, False)
Пример #3
0
	def get(self):
		if(not isUserLoggedIn(self)):
			self.redirect("/")
			return
		day = getOrderBaseDate(self)
		monday = getMonday(day)
		firstOrderableDay = getFirstOrderableDate(self);
		user = getUser(self)
		weeks = user.weeks.filter("monday = ", monday)
		days=[]
		for i in range(0,5):
			actualDayObject={}
			orderedPrice = 0
			actualDay=monday+datetime.timedelta(days=i)
			if actualDay < firstOrderableDay:
				actualDayObject["changable"] = False
			else:
				actualDayObject["changable"] = True
			daysOrderItems = getOrderedItemsFromWeekData(weeks, actualDay)
			actualDayObject['orderedItems'] = daysOrderItems
			for orderedItem in daysOrderItems:
				try:
					orderedPrice = orderedPrice + orderedItem['price'] * orderedItem['orderedQuantity']
				except:
					pass
			actualDayObject['day']=dayNames[i]
			actualDayObject['date'] = actualDay
			actualDayObject["orderedPrice"] = orderedPrice
			if daysOrderItems != None and len(daysOrderItems)>0:
				if (weeks.count() > 0):
					week = weeks.get()
				else:
					week = UserWeekOrder()
				address = getOrderAddress(week, actualDay)
				comment = getOrderComment(week, actualDay)
				if address == None:
					address = user.addresses.get()
				actualDayObject['address'] = address
				actualDayObject['comment'] = comment
				actualDayObject["deliveryCost"] = getZipBasedDeliveryCost(address.zipNumCode, orderedPrice)
			days.append(actualDayObject)
		# 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)
		availableAddresses = []
		for address in user.addresses:
			address.deliveryCost = getZipBasedDeliveryCost(address.zipNumCode, 0)
			address.deliveryLimit = getZipBasedDeliveryLimit(address.zipNumCode)
			availableAddresses.append(address)
		template_values = {
			'days':days,
			'addresses':availableAddresses,
		}
		if nextMonday <= actualMonday + datetime.timedelta(days=FURTHEST_DAY_DISPLAYED):
			template_values['next'] = nextMonday
		if prevMonday >= actualMonday:
			template_values['prev'] = prevMonday
		# A single dish with editable ingredient list
		template = jinja_environment.get_template('templates/reviewOrderedMenu.html')
		logInfo(self, self.URL, "REVIEW_PERSONAL_MENU")
		self.printPage(str(day), template.render(template_values), False, True)