Example #1
0
	def lend(self, borrowerID, date = None):
		import datetime
		borrower = UserAccount.getuser(borrowerID)
		owner = UserAccount.get_by_id(self.owner.id())
		self.borrower = borrower.key
		if(date):
			self.due_date = datetime.datetime.strptime(date, '%Y-%m-%d');
		else:
			self.due_date = datetime.datetime.now() + datetime.timedelta(days=int(owner.lending_length))
Example #2
0
	def confirm(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		
		due_date = None
		cur_user = UserAccount.query(UserAccount.key==self.useraccount).get()
		cur_user.lend_item(int(itemcopy.key.id()), int(other.key.id()), due_date)
		
		self.cleanup()
		
		otherAction = WaitingToBorrow.query(WaitingToBorrow.item == itemcopy.key and WaitingToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "You have agreed to lend %s to %s" %(item.title,other.name)
Example #3
0
	def confirm(self):
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		other = UserAccount.query(UserAccount.key==itemcopy.borrower).get()
		item = Item.query(Item.key==itemcopy.item).get()
		itemcopy.return_item()
		itemcopy.put()
		self.cleanup()
		return "%s has been returned to your library" %(item.title)
Example #4
0
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		self.cleanup()
		
		otherAction = RequestToBorrow.query(RequestToBorrow.item == itemcopy.key and RequestToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "Request cancelled"
Example #5
0
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		self.cleanup()

		otherAction = WaitingToBorrow.query(WaitingToBorrow.item == itemcopy.key and WaitingToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "You have denied %s permission to borrow %s" %(other.name,item.title)
Example #6
0
	def get_borrower(self):
		borrower = UserAccount.get_by_id(self.borrower.id())
		return borrower
Example #7
0
	def get_owner(self):
		owner = UserAccount.get_by_id(self.owner.id())
		return owner.name
Example #8
0
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		return "%s has requested to borrow '%s'" %(other.name,item.title)
Example #9
0
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		self.cleanup()
		return "You have rejected a connection request from %s" %(other.name)
Example #10
0
	def confirm(self):
		invitee = UserAccount.query(UserAccount.key==self.connection).get()
		invited = UserAccount.query(UserAccount.key==self.useraccount).get()
		invited.add_connection(invitee)
		self.cleanup()
		return "You have accepted a connection request from %s" %(invitee.name)
Example #11
0
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		return "%s has requested to connect" %(other.name)
Example #12
0
	def text(self):
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		other = UserAccount.query(UserAccount.key==itemcopy.borrower).get()
		item = Item.query(Item.key==itemcopy.item).get()
		return "%s wants to extend the due date of '%s' to %s?" %(other.name,item.title,str(self.due_date))
Example #13
0
	def reject(self):
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		other = UserAccount.query(UserAccount.key==itemcopy.borrower).get()
		item = Item.query(Item.key==itemcopy.item).get()
		self.cleanup()
		return "Recorded that %s didn't return %s" %(other.name,item.title)
Example #14
0
	def text(self):
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		other = UserAccount.query(UserAccount.key==itemcopy.borrower).get()
		item = Item.query(Item.key==itemcopy.item).get()
		return "%s reported checking in '%s'" %(other.name,item.title)
Example #15
0
	def confirm(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		print "You have accepted a connection request from %s" %(other.name)
Example #16
0
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		itemcopy = ItemCopy.query(ItemCopy.key==self.item).get()
		item = Item.query(Item.key==itemcopy.item).get()
		return "You have requested to borrow '%s' from %s" %(item.title,other.name)