Esempio n. 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))
Esempio n. 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)
Esempio n. 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)
Esempio n. 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"
Esempio n. 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)
Esempio n. 6
0
	def get_borrower(self):
		borrower = UserAccount.get_by_id(self.borrower.id())
		return borrower
Esempio n. 7
0
	def get_owner(self):
		owner = UserAccount.get_by_id(self.owner.id())
		return owner.name
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 11
0
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		return "%s has requested to connect" %(other.name)
Esempio n. 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))
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)