예제 #1
0
파일: models.py 프로젝트: byu-osl/bookout
	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))
예제 #2
0
파일: models.py 프로젝트: byu-osl/bookout
	def confirm(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		
		due_date = None
		cur_user = UserAccount.query(UserAccount.key==self.useraccount).get()
		cur_user.lend_book(int(bookcopy.key.id()), int(other.key.id()), due_date)
		
		self.cleanup()
		
		otherAction = WaitingToBorrow.query(WaitingToBorrow.book == bookcopy.key and WaitingToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "You have agreed to lend %s to %s" %(book.title,other.name)
예제 #3
0
파일: models.py 프로젝트: byu-osl/bookout
	def confirm(self):
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		other = UserAccount.query(UserAccount.key==bookcopy.borrower).get()
		book = Book.query(Book.key==bookcopy.book).get()
		bookcopy.return_book()
		bookcopy.put()
		self.cleanup()
		return "%s has been returned to your library" %(book.title)
예제 #4
0
파일: models.py 프로젝트: byu-osl/bookout
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		self.cleanup()
		
		otherAction = RequestToBorrow.query(RequestToBorrow.book == bookcopy.key and RequestToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "Request cancelled"
예제 #5
0
파일: models.py 프로젝트: byu-osl/bookout
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		self.cleanup()

		otherAction = WaitingToBorrow.query(WaitingToBorrow.book == bookcopy.key and WaitingToBorrow.useraccount == other.key).get()
		otherAction.cleanup()
		
		return "You have denied %s permission to borrow %s" %(other.name,book.title)
예제 #6
0
파일: models.py 프로젝트: byu-osl/bookout
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		return "%s has requested to borrow '%s'" %(other.name,book.title)
예제 #7
0
파일: models.py 프로젝트: byu-osl/bookout
	def reject(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		self.cleanup()
		return "You have rejected a connection request from %s" %(other.name)
예제 #8
0
파일: models.py 프로젝트: byu-osl/bookout
	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)
예제 #9
0
파일: models.py 프로젝트: byu-osl/bookout
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		return "%s has requested to connect" %(other.name)
예제 #10
0
파일: models.py 프로젝트: byu-osl/bookout
	def text(self):
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		other = UserAccount.query(UserAccount.key==bookcopy.borrower).get()
		book = Book.query(Book.key==bookcopy.book).get()
		return "%s wants to extend the due date of '%s' to %s?" %(other.name,book.title,str(self.due_date))
예제 #11
0
파일: models.py 프로젝트: byu-osl/bookout
	def reject(self):
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		other = UserAccount.query(UserAccount.key==bookcopy.borrower).get()
		book = Book.query(Book.key==bookcopy.book).get()
		self.cleanup()
		return "Recorded that %s didn't return %s" %(other.name,book.title)
예제 #12
0
파일: models.py 프로젝트: byu-osl/bookout
	def text(self):
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		other = UserAccount.query(UserAccount.key==bookcopy.borrower).get()
		book = Book.query(Book.key==bookcopy.book).get()
		return "%s reported checking in '%s'" %(other.name,book.title)
예제 #13
0
파일: models.py 프로젝트: byu-osl/bookout
	def confirm(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		print "You have accepted a connection request from %s" %(other.name)
예제 #14
0
파일: models.py 프로젝트: byu-osl/bookout
	def text(self):
		other = UserAccount.query(UserAccount.key==self.connection).get()
		bookcopy = BookCopy.query(BookCopy.key==self.book).get()
		book = Book.query(Book.key==bookcopy.book).get()
		return "You have requested to borrow '%s' from %s" %(book.title,other.name)
예제 #15
0
파일: models.py 프로젝트: byu-osl/bookout
	def get_borrower(self):
		borrower = UserAccount.get_by_id(self.borrower.id())
		return borrower.name
예제 #16
0
파일: models.py 프로젝트: byu-osl/bookout
	def get_owner(self):
		owner = UserAccount.get_by_id(self.owner.id())
		return owner.name