def OnSearch(self,event): self.list.DeleteAllItems() self.authorString=self.author.GetValue() self.titleString=self.title.GetValue() self.firstnameString=self.firstname.GetStringSelection() self.lastnameString=self.lastname.GetStringSelection() i = 0 bookcondition={} usercondition={} bookcondition["author"]=self.authorString bookcondition["title"]=self.titleString usercondition["fn"]=self.firstnameString usercondition["ln"]=self.lastnameString for x in Emprunt.select("return_date is null"): print x.date isGood=1 item = x.getItem() member = x.getBorrower() titres = item.title # titres = title in french... title = titres.booktitle a = Author.select("title_id=\'%d\'" % titres.id) a = list(a) print "6..." if len(a) > 1 or len(a) == 0: print "Shit !" author = a[0].authorName print author if len(usercondition) >= 1: if len(usercondition["fn"]) > 0 and not(member.first_name.find(usercondition['fn'])): isGood=0 else: print "f n matches" if len(usercondition["ln"]) > 0 and not(member.last_name.find(usercondition['ln'])): isGood=0 else: print "l n matches" if len(bookcondition) >= 1: if len(bookcondition["title"]) > 0 and not(title.find(bookcondition['title'])): isGood=0 else: print "title matches" if len(bookcondition["author"]) > 0 and not(author.find(bookcondition["author"])): isGood=0 else: print "author matches" if isGood == 1: self.list.InsertStringItem(i,title) self.list.SetStringItem(i,1,author) self.list.SetStringItem(i,2,member.first_name) self.list.SetStringItem(i,3,member.last_name) self.list.SetStringItem(i,4,x.date.isoformat()) self.list.SetStringItem(i,5, "%d" % x.id) self.list.SetItemData(i,i) i=i+1 if i>0: for x in range(6): self.list.SetColumnWidth(x, wxLIST_AUTOSIZE) EVT_LIST_ITEM_ACTIVATED(self,self.list.GetId(), self.onSelectItem)
def loadAllAuthors(self): self.allAuthorList.DeleteAllItems() theAuthors = list(Author.select()) i = 0 for author in theAuthors: print author self.allAuthorList.InsertStringItem(i,author.author_name.decode("string_escape")) i = i + 1 self.allAuthorList.SetColumnWidth(0, wxLIST_AUTOSIZE)
def test_authoredit_functional(self): random_item = random.sample(list(Author.select()), 1)[0] response = self._my_app.get("/authoredit", {"id": random_item.id}) code, error = tidylib.tidy_document(response.body, options={ "show-errors": 1, "show-warnings": 0 }) self.assertFalse(error, "/authoredit did not return valid html page")
def authors(self, letter=None): alphabet = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ] the_authors = False if letter != None: if letter in alphabet: the_authors = Author.select( """ author.author_name RLIKE " %s[^ ]*$" AND book.title_id=title.id AND book.status ='STOCK' AND author.id= author_title.author_id AND author_title.title_id=title.id""" % (escape_string(letter)), orderBy="author_name", clauseTables=['book', 'title', 'author_title'], distinct=True) else: the_authors = Author.select(""" author.author_name NOT RLIKE "^[:alpha:]" AND book.title_id=title.id AND book.status ='STOCK' AND author.id=author_title.author_id AND author_title.title_id=title.id""", orderBy="author_name", clauseTables=['book', 'title'], distinct=True) authors_for_letter = list(unique(the_authors)) authors_for_letter.sort(sort_by_last_name) return dict(authorswidget=AuthorsWidget(), titlelistwidget=TitleListWidget(), the_authors=authors_for_letter, the_letter=letter, alphabet=alphabet) else: return dict(authorswidget=AuthorsWidget(), titlelistwidget=TitleListWidget(), the_authors=False, the_letter=letter, alphabet=alphabet)
def authors(self,letter=None): alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] the_authors=False if letter != None: if letter in alphabet: the_authors=Author.select(""" author.author_name RLIKE " %s[^ ]*$" AND book.title_id=title.id AND book.status ='STOCK' AND author.id= author_title.author_id AND author_title.title_id=title.id""" % (escape_string(letter)),orderBy="author_name",clauseTables=['book','title','author_title'],distinct=True) else: the_authors=Author.select(""" author.author_name NOT RLIKE "^[:alpha:]" AND book.title_id=title.id AND book.status ='STOCK' AND author.id=author_title.author_id AND author_title.title_id=title.id""" ,orderBy="author_name",clauseTables=['book','title'],distinct=True) authors_for_letter=list(unique(the_authors)) authors_for_letter.sort(sort_by_last_name) return dict(authorswidget=AuthorsWidget(),titlelistwidget=TitleListWidget(),the_authors=authors_for_letter,the_letter=letter,alphabet=alphabet) else: return dict(authorswidget=AuthorsWidget(),titlelistwidget=TitleListWidget(),the_authors=False,the_letter=letter,alphabet=alphabet)
def test_authoredit_functional(self): random_item=random.sample(list(Author.select()), 1)[0] response=self._my_app.get('/authoredit', {'id':random_item.id}) code, error=tidylib.tidy_document(response.body, options={'show-errors':1, 'show-warnings':0}) self.assertFalse(error, '/authoredit did not return valid html page')