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

Diff of /trunk/htdocs/search.py

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

Revision 133 Revision 134
6 6
7This module implements the front end functionality for all script search 7This module implements the front end functionality for all script search
8related actions. 8related actions.
9""" 9"""
10 10
11__revision__ = '$Id$' 11__revision__ = "$Id$"
12__authors__ = ["Scott Hadfield <hadfield@gentoo.org>", 12__authors__ = ["Scott Hadfield <hadfield@gentoo.org>",
13 "Ian Leitch <port001@gentoo.org>"] 13 "Ian Leitch <port001@gentoo.org>"]
14__modulename__ = 'search' 14__modulename__ = "search"
15 15
16import os 16import os
17 17
18from harmonious.utils import exposed, default 18from harmonious.utils import exposed, default
19 19
20from glsr.setup import config 20from glsr.setup import config
21from glsr.site.basedomain import BaseDomain
22 21
23from glsr.site import script 22from glsr.site import script
24from glsr.site.category import Category 23from glsr.site.category import Category
25from glsr.site.language import Language 24from glsr.site.language import Language
26from glsr.site.user import User 25from glsr.site import table_listing, user
27 26
28class Search(BaseDomain): 27class Search(table_listing.TableListing):
29 """The search domain class.""" 28 """The search domain class."""
30 29
31 @default 30 @default
32 @default 31 @exposed
33 def prompt(self): 32 def prompt(self):
34 """Display the script search page.""" 33 """Display the script search page."""
35 34
36 self._do_header() 35 self._do_header()
37 self._set_template(os.path.join(config.template_loc, 36 self._set_template(os.path.join(config.template_loc,
47 if self._harm.request.queries.has_key("search_type"): 46 if self._harm.request.queries.has_key("search_type"):
48 search_type = self._harm.request.queries["search_type"] 47 search_type = self._harm.request.queries["search_type"]
49 else: 48 else:
50 search_type = "" 49 search_type = ""
51 50
51 self._hidden_fields = [{"name": "search_type", "value": search_type}]
52
52 if search_type == "submitter": 53 if search_type == "submitter":
53 # Search for scripts based on the submitter id. 54 # Search for scripts based on the submitter id.
54 if self._harm.request.queries.has_key("submitter_id"): 55 if self._harm.request.queries.has_key("submitter_id"):
55 submitter_id = self._harm.request.queries["submitter_id"] 56 submitter_id = self._harm.request.queries["submitter_id"]
56 scripts = script.list_scripts( 57 scripts = script.list_scripts(
57 script_constraints = {'submitter_id': submitter_id}) 58 script_constraints = {'submitter_id': submitter_id})
59 self._hidden_fields.append({"name": "submitter_id",
60 "value": submitter_id})
58 61
59 elif search_type == "list_all": 62 elif search_type == "list_all":
60 # Find and list all scripts. 63 # Find and list all scripts.
61 scripts = script.list_scripts() 64 scripts = script.list_scripts()
62 65
63 else: 66 else:
64 scripts = self._standard() 67 scripts = self._standard()
68
69 self._domain = __modulename__
70 self._page = "search"
71 self._list_title = "Script Listing"
72
73 self._fields = [
74 {"name": "script_submitter", "title": "Author",
75 "link": ("index.py?page=profile&mode=viewprofile&uid=%s",
76 "script_submitter_id")},
77 {"name": "script_name", "title": "Name",
78 "link": ("viewscript.py?script_id=%s", "script_id")},
79 {"name": "script_category", "title": "Category"},
80 {"name": "script_language", "title": "Language"},
81 {"name": "script_rank", "title": "Rank"},
82 {"name": "subscript_version", "title": "Version"},
83 {"name": "subscript_date", "title": "Date Created"},
84 {"name": "subscript_status", "title": "Status"},
85 {"name": "subscript_approvedby",
86 "title": "Approved By"}]
65 87
66 for record in scripts: 88 for record in scripts:
67 user_obj = User(record["script_submitter_id"]) 89 user_obj = user.User(record["script_submitter_id"])
68 category_obj = Category(record["script_category_id"]) 90 category_obj = Category(record["script_category_id"])
69 language_obj = Language(record["script_language_id"]) 91 language_obj = Language(record["script_language_id"])
70 92
71 record.update({'script_submitter': user_obj.get_alias(), 93 record.update({'script_submitter': user_obj.get_alias(),
72 'script_category': category_obj.name(), 94 'script_category': category_obj.name(),
73 'script_language': language_obj.name()}) 95 'script_language': language_obj.name()})
74 96
97 self._loop_data = scripts
98
75 self._do_header() 99 self._do_header()
76 self._set_template(os.path.join(config.template_loc, 100 self._make_table()
77 'list_scripts.tpl'))
78 self._template.param("MAIN_LOOP_LEN", len(scripts))
79 self._template.param("MAIN_LOOP", scripts)
80 self._template.param("SORTBY", "a")
81 self._template.param("ORDER", "author")
82 self._harm.response.append_body(self._template.output()) 101 self._harm.response.append_body(self._template.output())
83 self._do_footer() 102 self._do_footer()
84 103
85 def _standard(self): 104 def _standard(self):
86 """Perform a standard search, based on form inputs.""" 105 """Perform a standard search, based on form inputs."""

Legend:
Removed from v.133  
changed lines
  Added in v.134

  ViewVC Help
Powered by ViewVC 1.1.20