Exemple #1
0
 def addIssue(self):
     memID = request.params['memberid']
     bkID = request.params['bookid']
     mem = Session.query(Members).filter_by(memberID=memID).first()
     member_allowance = Session.query(Issues).all()
     nameList = []
     for i in member_allowance:
         nameList.append(i.memberID)
     d = {}
     for i in set(nameList):
         d[i] = nameList.count(i)
     if d.get(int(memID), 1) > 2:
         session['flash'] = 'That member may not take out any more books.\
                 Maximum allowance of 3 reached.'
         session.save()
         #self.index()
     else:
         bk = Session.query(Books).filter_by(bookID=bkID).first()
         bk.status = False
         Session.add(bk)
         Session.commit()
         issueDate = datetime.date.today()
         dueDate = issueDate + datetime.timedelta(days=14)
         returned = False
         issue_details = Issues(mem.memberID, bk.bookID, issueDate,
                 dueDate, returned)
         Session.add(issue_details)
         Session.commit()
         session.clear()
         session['flash'] = 'Issue successfully added'
         session.save()
     redirect('/issues/')
Exemple #2
0
 def addBook(self):
     title = self.form_result['title']
     author = self.form_result['author']
     status = True
     bk_details = Books(title, author, status)
     Session.add(bk_details)
     Session.commit()
     session.clear()
     session['flash'] = 'Successfully added new book.'
     session.save()
     redirect('/books/')
Exemple #3
0
 def addMember(self):
     name = self.form_result['name']
     address = self.form_result['address']
     suburb = self.form_result['suburb']
     city = self.form_result['city']
     mem_details = Members(name, address, suburb, city)
     Session.add(mem_details)
     Session.commit()
     session.clear()
     session['flash'] = 'New member successfully added.'
     session.save()
     redirect('/members/')
Exemple #4
0
 def editBook(self):
     bk_id = request.params['id']
     bk_details = self.book_q.filter_by(bookID=bk_id).first()
     bk_details.title = self.form_result['title']
     bk_details.author = self.form_result['author']
     #bk_details.status = request.params['status']
     Session.add(bk_details)
     Session.commit()
     session.clear()
     session['flash'] = 'Book successfully edited.'
     session.save()
     redirect('/books/')
Exemple #5
0
 def editMember(self):
     mem_id = request.params['id']
     mem_details = self.member_q.filter_by(memberID=mem_id).first()
     mem_details.name = self.form_result['name']
     mem_details.address = self.form_result['address']
     mem_details.suburb = self.form_result['suburb']
     mem_details.city = self.form_result['city']
     Session.add(mem_details)
     Session.commit()
     session.clear()
     session['flash'] = 'Member successfully edited.'
     session.save()
     redirect('/members/')
Exemple #6
0
 def deleteIssue(self):
     is_id = request.params['issueID']
     is_details = self.issue_q.filter_by(issueID=is_id).first()
     bk = Session.query(Books).filter_by(bookID=is_details.bookID).first()
     bk.status = True
     Session.add(bk)
     Session.commit()
     Session.delete(is_details)
     Session.commit()
     session.clear()
     session['flash'] = 'Issue successfully returned.'
     session.save()
     redirect('/issues/')
Exemple #7
0
 def editIssue(self):
     is_id = request.params['id']
     is_details = self.issue_q.filter_by(issueID=is_id).first()
     is_details.memberID = request.params['memberID']
     is_details.bookID = request.params['bookID']
     i = datetime.datetime.strptime(request.params['issueDate'], '%Y-%m-%d')
     is_details.issueDate = i
     print is_details.issueDate, '*' * 500
     d = datetime.datetime.strptime(request.params['dueDate'], '%Y-%m-%d')
     is_details.dueDate = d
     Session.add(is_details)
     Session.commit()
     session.clear()
     session['flash'] = 'Issue successfully edited.'
     session.save()
     redirect('/issues/')