/[glsr]/trunk/htdocs/search.py
Gentoo

Diff of /trunk/htdocs/search.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 185 Revision 186
16import os 16import os
17 17
18from framework.utils import exposed, default 18from framework.utils import exposed, default
19 19
20from glsr.setup import config 20from glsr.setup import config
21 21from glsr.site import category, language, script, table_listing, user
22from glsr.site import script
23from glsr.site.category import Category
24from glsr.site.language import Language
25from glsr.site import table_listing, user
26 22
27class Search(table_listing.TableListing): 23class Search(table_listing.TableListing):
28 """The search domain class.""" 24 """The search domain class."""
29 25
30 @default 26 @default
32 def prompt(self): 28 def prompt(self):
33 """Display the script search page.""" 29 """Display the script search page."""
34 30
35 self._do_header() 31 self._do_header()
36 self._set_template(os.path.join(config.template_loc, 32 self._set_template(os.path.join(config.template_loc,
37 'search_scripts.tpl')) 33 "search_scripts.tpl"))
34 self._template.param("LANG_LOOP", language.list_all(["language_id",
35 "language_name"]))
36 self._template.param("CAT_LOOP", category.list_all(["category_id",
37 "category_name"]))
38 self._template.param('GLSR_URL', config.url) 38 self._template.param("GLSR_URL", config.url)
39 self._harm.response.append_body(self._template.output()) 39 self._harm.response.append_body(self._template.output())
40 self._do_footer() 40 self._do_footer()
41 41
42 @exposed 42 @exposed
43 def search(self): 43 def search(self):
72 72
73 self._fields = [ 73 self._fields = [
74 {"name": "script_name", "title": "Name", 74 {"name": "script_name", "title": "Name",
75 "link": ("viewscript.py?script_id=%s", "script_id")}, 75 "link": ("viewscript.py?script_id=%s", "script_id")},
76 {"name": "script_submitter", "title": "Author", 76 {"name": "script_submitter", "title": "Author",
77 "link": ("profile.py?page=view&uid=%s", 77 "link": ("profile.py?page=view&uid=%s", "script_submitter_id")},
78 "script_submitter_id")},
79 {"name": "script_category", "title": "Category"}, 78 {"name": "script_category", "title": "Category"},
80 {"name": "script_language", "title": "Language"}, 79 {"name": "script_language", "title": "Language"},
81 {"name": "script_rank", "title": "Rank"}, 80 {"name": "script_rank", "title": "Rank"},
82 {"name": "subscript_version", "title": "Version"}, 81 {"name": "subscript_version", "title": "Version"},
83 {"name": "subscript_date", "title": "Date Created"}, 82 {"name": "subscript_date", "title": "Date Created"},
84 {"name": "subscript_status", "title": "Status"}, 83 {"name": "subscript_status", "title": "Status"},
85 {"name": "subscript_approvedby", 84 {"name": "subscript_approvedby", "title": "Approved By"}]
86 "title": "Approved By"}]
87 85
88 for record in scripts: 86 for record in scripts:
89 user_obj = user.User(record["script_submitter_id"]) 87 user_obj = user.User(record["script_submitter_id"])
90 category_obj = Category(record["script_category_id"]) 88 category_obj = category.Category(record["script_category_id"])
91 language_obj = Language(record["script_language_id"]) 89 language_obj = language.Language(record["script_language_id"])
92 90
93 record.update({'script_submitter': user_obj.get_alias(), 91 record.update({'script_submitter': user_obj.get_alias(),
94 'script_category': category_obj.name(), 92 'script_category': category_obj.name(),
95 'script_language': language_obj.name()}) 93 'script_language': language_obj.name()})
96 94
110 terms['name'] = self._harm.request.forms.getvalue('name') 108 terms['name'] = self._harm.request.forms.getvalue('name')
111 109
112 if self._harm.request.forms.has_key("descr"): 110 if self._harm.request.forms.has_key("descr"):
113 terms['descr'] = self._harm.request.forms.getvalue('descr') 111 terms['descr'] = self._harm.request.forms.getvalue('descr')
114 112
115 if self._harm.request.forms.has_key("submitter_id"):
116 terms['submitter_id'] = (
117 self._harm.request.forms.getvalue('submitter_id'))
118
119 if self._harm.request.forms.has_key("current"): 113 if self._harm.request.forms.has_key("current"):
120 terms['current'] = self._harm.request.forms.getvalue('current') 114 terms['current'] = self._harm.request.forms.getvalue('current')
121 115
122 return script.search(terms) 116 if self._harm.request.forms.has_key("submitter"):
117 submitter = self._harm.request.forms.getvalue('submitter')
118 terms['submitter_id'] = user.get_uid_by_alias(submitter)
123 119
120 if self._harm.request.forms.has_key("category_id"):
121 terms['category_id'] = (
122 self._harm.request.forms.getvalue('category_id'))
123
124 if self._harm.request.forms.has_key("language_id"):
125 terms['language_id'] = (
126 self._harm.request.forms.getvalue('language_id'))
127
128 return script.search(
129 ["script_submitter_id", "script_category_id", "script_language_id",
130 "script_rank", "script_name", "script_descr"], terms)
131

Legend:
Removed from v.185  
changed lines
  Added in v.186

  ViewVC Help
Powered by ViewVC 1.1.20