diff options
author | heather <unknown> | 2011-05-20 01:18:24 -0400 |
---|---|---|
committer | heather <unknown> | 2011-05-20 01:18:24 -0400 |
commit | d5a700ffa2bdfc87662ac42565b30e7f668926d4 (patch) | |
tree | d892ed907e3045a6b90f02e415ccca4a8c25d577 | |
parent | 3ef2fa22185c0b61bf2a95698ab3afe05fc1b6c4 (diff) | |
download | d2-d5a700ffa2bdfc87662ac42565b30e7f668926d4.tar.bz2 d2-d5a700ffa2bdfc87662ac42565b30e7f668926d4.tar.xz d2-d5a700ffa2bdfc87662ac42565b30e7f668926d4.zip |
modify various script to accomodate Len's search changes
-rw-r--r-- | lib/d2/app/controllers/index.py | 37 | ||||
-rw-r--r-- | lib/d2/app/controllers/svg_text.py | 2 | ||||
-rw-r--r-- | lib/d2/bin/d2_server.py | 4 | ||||
-rw-r--r-- | templates/index.html | 14 |
4 files changed, 39 insertions, 18 deletions
diff --git a/lib/d2/app/controllers/index.py b/lib/d2/app/controllers/index.py index 7febb82..1c6ae66 100644 --- a/lib/d2/app/controllers/index.py +++ b/lib/d2/app/controllers/index.py | |||
@@ -30,18 +30,18 @@ class IndexController(BaseController): | |||
30 | self._plot_ = PlotAdapter.load() | 30 | self._plot_ = PlotAdapter.load() |
31 | return self._plot_ | 31 | return self._plot_ |
32 | 32 | ||
33 | def _show_map(self, id_type, id): | 33 | def _show_map(self, occupant_id, plot_id): |
34 | if id_type == 'occupant': | 34 | if plot_id: |
35 | forges = self._forge.get_forge_by_occupant_id(id) | 35 | forges = self._forge.get_forge_by_plot_id(plot_id) |
36 | details = self._detail.occupant_details(id) | 36 | details = self._detail.details(plot_id, occupant_id) |
37 | plots = self._plot.get_all([plot_id]) | ||
38 | else: | ||
39 | forges = self._forge.get_forge_by_occupant_id(occupant_id) | ||
40 | details = self._detail.details(plot_id, occupant_id) | ||
37 | plots = [] | 41 | plots = [] |
38 | if len(forges) > 0: | 42 | if len(forges) > 0: |
39 | plot_ids = [forge.plot_id for forge in forges] | 43 | plot_ids = [forge.plot_id for forge in forges] |
40 | plots = self._plot.get_all(plot_ids) | 44 | plots = self._plot.get_all(plot_ids) |
41 | else: # plot | ||
42 | forges = self._forge.get_forge_by_plot_id(id) | ||
43 | details = self._detail.plot_details(id) | ||
44 | plots = self._plot.get_all([id]) | ||
45 | 45 | ||
46 | self.render('index.html', | 46 | self.render('index.html', |
47 | mode="map", | 47 | mode="map", |
@@ -50,9 +50,20 @@ class IndexController(BaseController): | |||
50 | forges=forges) | 50 | forges=forges) |
51 | 51 | ||
52 | 52 | ||
53 | def get(self, id_type=None, id=None): | 53 | def get(self, type_1=None, id_1=None, type_2=None, id_2=None): |
54 | if id_type and id: | 54 | if type_1 and id_1: |
55 | self._show_map(id_type, id) | 55 | if type_2 and id_2: |
56 | occupant_id = id_1 | ||
57 | plot_id = id_2 | ||
58 | else: | ||
59 | if type_1 == 'occupant': | ||
60 | occupant_id = id_1 | ||
61 | plot_id = None | ||
62 | else: | ||
63 | plot_id = id_1 | ||
64 | occupant_id = None | ||
65 | |||
66 | self._show_map(occupant_id, plot_id) | ||
56 | else: | 67 | else: |
57 | self.render('index.html', mode="get") | 68 | self.render('index.html', mode="get") |
58 | 69 | ||
@@ -62,8 +73,8 @@ class IndexController(BaseController): | |||
62 | details = self._search.search(name) | 73 | details = self._search.search(name) |
63 | 74 | ||
64 | if len(details) == 1: | 75 | if len(details) == 1: |
65 | self._show_map(details[0].id_type, | 76 | self._show_map(details[0].occupant_id, |
66 | details[0].id) | 77 | details[0].plot_id) |
67 | else: | 78 | else: |
68 | self.render('index.html', mode='post', | 79 | self.render('index.html', mode='post', |
69 | details=details) | 80 | details=details) |
diff --git a/lib/d2/app/controllers/svg_text.py b/lib/d2/app/controllers/svg_text.py index c8d89e0..4ffc5cf 100644 --- a/lib/d2/app/controllers/svg_text.py +++ b/lib/d2/app/controllers/svg_text.py | |||
@@ -34,7 +34,7 @@ class SvgTextController(BaseController): | |||
34 | occupant_record = self._db.session.query(Occupant).filter( | 34 | occupant_record = self._db.session.query(Occupant).filter( |
35 | "occupant_id=:occupant_id").params( | 35 | "occupant_id=:occupant_id").params( |
36 | occupant_id=forge_record.occupant_id).first() | 36 | occupant_id=forge_record.occupant_id).first() |
37 | details = detail_adapter.occupant_details(forge_record.occupant_id) | 37 | details = detail_adapter.details(None, forge_record.occupant_id) |
38 | if details: | 38 | if details: |
39 | label = details.label | 39 | label = details.label |
40 | coordinate = self._db.session.query(LabelCoordinate).filter( | 40 | coordinate = self._db.session.query(LabelCoordinate).filter( |
diff --git a/lib/d2/bin/d2_server.py b/lib/d2/bin/d2_server.py index fbe4741..2321263 100644 --- a/lib/d2/bin/d2_server.py +++ b/lib/d2/bin/d2_server.py | |||
@@ -19,7 +19,9 @@ def main(): | |||
19 | } | 19 | } |
20 | application = tornado.web.Application([ | 20 | application = tornado.web.Application([ |
21 | (r"/svg_text/(.*)", SvgTextController, extras), | 21 | (r"/svg_text/(.*)", SvgTextController, extras), |
22 | (r"/(occupant|plot)/(.*)", IndexController, extras), | 22 | (r"/(plot)/(.*)", IndexController, extras), |
23 | (r"/(occupant)/(.*)/(plot)/(.*)", IndexController, extras), | ||
24 | (r"/(occupant)/(.*)", IndexController, extras), | ||
23 | (r"/", IndexController, extras), | 25 | (r"/", IndexController, extras), |
24 | ], **settings) | 26 | ], **settings) |
25 | http_server = tornado.httpserver.HTTPServer(application) | 27 | http_server = tornado.httpserver.HTTPServer(application) |
diff --git a/templates/index.html b/templates/index.html index 8ec15c8..43bd556 100644 --- a/templates/index.html +++ b/templates/index.html | |||
@@ -129,10 +129,18 @@ | |||
129 | Found: | 129 | Found: |
130 | {% for detail in details %} | 130 | {% for detail in details %} |
131 | <ul id="result-list"> | 131 | <ul id="result-list"> |
132 | {% if detail.id_type == u'occupant' %} | 132 | {% if detail.occupant_id %} |
133 | <li><a href="/occupant/{{detail.id}}">{{detail.label}}</a></li> | 133 | {% if detail.plot_id %} |
134 | <li><a href="/occupant/{{detail.occupant_id}}/plot/{{detail.plot_id}}">{{detail.label}}</a>{{detail.description}}</li> | ||
135 | {% else %} | ||
136 | <li><a href="/occupant/{{detail.occupant_id}}">{{detail.label}}</a>{{detail.description}}</li> | ||
137 | {% end %} | ||
134 | {% else %} | 138 | {% else %} |
135 | <li><a href="/plot/{{detail.id}}">{{detail.label}} </a></li> | 139 | {% if detail.plot_id %} |
140 | <li><a href="/plot/{{detail.plot_id}}">{{detail.label}}</a>{{detail.description}}</li> | ||
141 | {% else %} | ||
142 | <li>{{detail.label}} {{detail.description}}</li> | ||
143 | {% end %} | ||
136 | {% end %} | 144 | {% end %} |
137 | </ul> | 145 | </ul> |
138 | {% end %} | 146 | {% end %} |