diff options
author | heather <unknown> | 2011-05-13 23:48:06 -0400 |
---|---|---|
committer | heather <unknown> | 2011-05-13 23:48:06 -0400 |
commit | 5ab09f1ef6532d02cc0cda6cb49e91ea2d93209f (patch) | |
tree | d312a3e0eb995b6fc2c74bac4f80aa46c58db205 | |
parent | 21b45561ab164d4e27f764e2eff9e402520afef2 (diff) | |
download | d2-5ab09f1ef6532d02cc0cda6cb49e91ea2d93209f.tar.bz2 d2-5ab09f1ef6532d02cc0cda6cb49e91ea2d93209f.tar.xz d2-5ab09f1ef6532d02cc0cda6cb49e91ea2d93209f.zip |
directly show map if only one result comes back from search
-rw-r--r-- | lib/d2/app/controllers/index.py | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/d2/app/controllers/index.py b/lib/d2/app/controllers/index.py index 23f7b5e..7febb82 100644 --- a/lib/d2/app/controllers/index.py +++ b/lib/d2/app/controllers/index.py | |||
@@ -30,25 +30,29 @@ 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): | ||
34 | if id_type == 'occupant': | ||
35 | forges = self._forge.get_forge_by_occupant_id(id) | ||
36 | details = self._detail.occupant_details(id) | ||
37 | plots = [] | ||
38 | if len(forges) > 0: | ||
39 | plot_ids = [forge.plot_id for forge in forges] | ||
40 | 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 | |||
46 | self.render('index.html', | ||
47 | mode="map", | ||
48 | details=details, | ||
49 | plots=plots, | ||
50 | forges=forges) | ||
51 | |||
52 | |||
33 | def get(self, id_type=None, id=None): | 53 | def get(self, id_type=None, id=None): |
34 | if id_type and id: | 54 | if id_type and id: |
35 | if id_type == 'occupant': | 55 | self._show_map(id_type, id) |
36 | forges = self._forge.get_forge_by_occupant_id(id) | ||
37 | details = self._detail.occupant_details(id) | ||
38 | plots = [] | ||
39 | if len(forges) > 0: | ||
40 | plot_ids = [forge.plot_id for forge in forges] | ||
41 | plots = self._plot.get_all(plot_ids) | ||
42 | else: # plot | ||
43 | forges = self._forge.get_forge_by_plot_id(id) | ||
44 | details = self._detail.plot_details(id) | ||
45 | plots = self._plot.get_all([id]) | ||
46 | |||
47 | self.render('index.html', | ||
48 | mode="map", | ||
49 | details=details, | ||
50 | plots=plots, | ||
51 | forges=forges) | ||
52 | else: | 56 | else: |
53 | self.render('index.html', mode="get") | 57 | self.render('index.html', mode="get") |
54 | 58 | ||
@@ -57,5 +61,9 @@ class IndexController(BaseController): | |||
57 | name = self.get_argument('name') | 61 | name = self.get_argument('name') |
58 | details = self._search.search(name) | 62 | details = self._search.search(name) |
59 | 63 | ||
60 | self.render('index.html', mode='post', | 64 | if len(details) == 1: |
65 | self._show_map(details[0].id_type, | ||
66 | details[0].id) | ||
67 | else: | ||
68 | self.render('index.html', mode='post', | ||
61 | details=details) | 69 | details=details) |