Add custom templates.
[infos-pratiques:etalage.git] / etalage / templates / search-form.mako
1 ## -*- coding: utf-8 -*-
2
3
4 ## Etalage -- Open Data POIs portal
5 ## By: Emmanuel Raviart <eraviart@easter-eggs.com>
6 ##
7 ## Copyright (C) 2011, 2012 Easter-eggs
8 ## http://gitorious.org/infos-pratiques/etalage
9 ##
10 ## This file is part of Etalage.
11 ##
12 ## Etalage is free software; you can redistribute it and/or modify
13 ## it under the terms of the GNU Affero General Public License as
14 ## published by the Free Software Foundation, either version 3 of the
15 ## License, or (at your option) any later version.
16 ##
17 ## Etalage is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ## GNU Affero General Public License for more details.
21 ##
22 ## You should have received a copy of the GNU Affero General Public License
23 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
25
26 <%def name="search_form_content()" filter="trim">
27     % for name, value in sorted(params.iteritems()):
28 <%
29         if name in (
30                 'bbox',
31                 'category' if not ctx.hide_category else None,
32                 'filter' if ctx.show_filter else None,
33                 'page',
34                 'term' if not ctx.hide_term else None,
35                 'territory' if not ctx.hide_territory else None,
36                 ):
37             continue
38         if value is None or value == u'':
39             continue
40 %>\
41         % if isinstance(value, list):
42             % for item_value in value:
43             <input name="${name}" type="hidden" value="${item_value or ''}">
44             % endfor
45         % else:
46             <input name="${name}" type="hidden" value="${value or ''}">
47         % endif
48     % endfor
49             <fieldset>
50     % if not ctx.hide_category:
51 <%
52         error = errors.get('categories') if errors is not None else None
53         if error and isinstance(error, dict):
54             error_index, error_message = sorted(error.iteritems())[0]
55         else:
56             error_index = None
57             error_message = error
58 %>\
59                 <div class="control-group${' error' if error else ''}">
60                     <label class="control-label" for="category">Catégorie</label>
61                     <div class="controls">
62     % if categories:
63         % for category_index, category in enumerate(categories):
64             % if error is None or category_index not in error:
65                         <label class="checkbox"><input checked name="category" type="checkbox" value="${category.name}">
66                             <span class="label label-success"><i class="icon-tag icon-white"></i>
67                             ${category.name}</span></label>
68             % endif
69         % endfor
70     % endif
71                         <input class="input-xlarge" id="category" name="category" type="text" value="${params['category'][error_index] \
72                                 if error_index is not None else ''}">
73         % if error_message:
74                         <span class="help-inline">${error_message}</span>
75         % endif
76                     </div>
77                 </div>
78     % endif
79     % if not ctx.hide_term:
80 <%
81         error = errors.get('term') if errors is not None else None
82 %>\
83                 <div class="control-group${' error' if error else ''}">
84                     <label class="control-label" for="term">Intitulé</label>
85                     <div class="controls">
86                         <input class="input-xlarge" id="term" name="term" type="text" value="${params['term'] or ''}">
87         % if error:
88                         <span class="help-inline">${error}</span>
89         % endif
90                     </div>
91                 </div>
92     % endif
93     % if not ctx.hide_territory:
94 <%
95         error = errors.get('territory') if errors is not None else None
96 %>\
97                 <div class="control-group${' error' if error else ''}">
98                     <label class="control-label" for="territory">Territoire</label>
99                     <div class="controls">
100                         <input class="input-xlarge" id="territory" name="territory" type="text" value="${params['territory'] or ''}">
101         % if error:
102                         <span class="help-inline">${error}</span>
103         % endif
104                     </div>
105                 </div>
106     % endif
107     % if ctx.show_filter:
108 <%
109         error = errors.get('filter') if errors is not None else None
110 %>\
111                 <div class="control-group${' error' if error else ''}">
112                     <label class="control-label" for="filter">Afficher</label>
113                     <div class="controls">
114                         <label class="radio">
115                             <input${' checked' if not params['filter'] else ''} name="filter" type="radio" value="">
116                             Tous les organismes
117                         </label>
118                         <label class="radio">
119                             <input${' checked' if params['filter'] == 'competence' else ''} name="filter" type="radio" value="competence">
120                             Uniquement les organismes compétents pour le territoire
121                         </label>
122                         <label class="radio">
123                             <input${' checked' if params['filter'] == 'presence' else ''} name="filter" type="radio" value="presence">
124                             Uniquement les organismes présents sur le territoire
125                         </label>
126         % if error:
127                         <p class="help-block">${error}</p>
128         % endif
129                     </div>
130                 </div>
131     % endif
132                 <div class="form-actions">
133                     <button class="btn btn-primary" type="submit"><i class="icon-search icon-white"></i> ${_('Search')}</button>
134                 </div>
135             <fieldset>
136 </%def>
137