Permalink
Browse files

Restore company search option

  • Loading branch information...
1 parent ef3e6a9 commit 9845f29488520b612746845e311a7ba3f3162923 @danohuiginn committed Mar 12, 2012
Showing with 25 additions and 10 deletions.
  1. +0 −8 README
  2. +25 −2 panama/webtorn.py
View
8 README
@@ -1,8 +0,0 @@
-
-Requirements:
-[these requirements could mostly be eliminated quite easily]
-
-web.py
-simplejson
-mysqldb
-
View
@@ -36,8 +36,11 @@ def get(self):
html = '<html><h2>Search Panama company records</h2>\
<form action="%s/personsearch" method="get">\
<b>Name of person</b><input type = "text" name = "name"><br>\
- <input type="submit" value="Search">\
- ' % BASEURL
+ <input type="submit" value="Search"></form><br/>\
+ <form action="%s/search/company" method="get">\
+ <b>Name of company</b><input type = "text" name = "name"><br>\
+ <input type="submit" value="Search"></form><br/>\
+ ' % (BASEURL, BASEURL)
html += ABOUTTEXT
html += '</html>'
self.write(html)
@@ -136,13 +139,33 @@ def get(self, rawSearchterm = u''):
html += HTMLTAIL
self.write(html)
+class searchCompanyPage(tornado.web.RequestHandler):
+
+ def get(self, rawSearchterm = u''):
+ if rawSearchterm is u'':
+ arguments = parse_qs(self.request.query)
+ rawSearchterm = arguments.get('name')[0]
+ html = HTMLHEAD
+ unquotedTerm = urllib.unquote(rawSearchterm).upper()
+ liketerm = Company.sqlrepr('%%%s%%' % unquotedTerm)
+ sqlquery = "company.name LIKE %s" % liketerm
+ html += '<h2>Company Search results</h2><h3>searching for %s</h3><ul>' % sqlquery
+ people = Company.select(sqlquery)
+ for thisone in people:
+ html += "<li><a href='%s/company/id/%s'>%s</a></li>" %(BASEURL, thisone.recordid, thisone.name)
+ html += '</ul>'
+ html += HTMLTAIL
+ self.write(html)
+
urls = [
('/?', indexPage,),
('/person/(.*)', personPage,),
('/person$', personPage,),
('/company/id/?(.*)', companyByNumberPage),
('/personsearch/?(.*)', searchPersonPage),
('/search/person/?(.*)', searchPersonPage),
+ ('/search/company/?(.*)', searchCompanyPage),
+
]
for url in urls[:]:
newurl = ('/panama' + url[0], url[1])

0 comments on commit 9845f29

Please sign in to comment.