Author: mbonetti
Date: Fri May  8 03:03:24 2009
New Revision: 518

Modified:
    branches/electron/pages/admin/__init__.py
    branches/electron/pages/templates/admin/pages/page/change_list_table.html

Log:
experimental page searching

Modified: branches/electron/pages/admin/__init__.py
==============================================================================
--- branches/electron/pages/admin/__init__.py   (original)
+++ branches/electron/pages/admin/__init__.py   Fri May  8 03:03:24 2009
@@ -74,6 +74,7 @@
          )]

      def __call__(self, request, url):
+        print url

          # Delegate to the appropriate method, based on the URL.
          if url is None:
@@ -93,7 +94,7 @@
          elif 'delete-content' in url:
              page_id, action, language_id = url.split('/')
              return delete_content(request,unquote(page_id),  
unquote(language_id))
-
+
          elif url.endswith('/sub-menu'):
              return sub_menu(request, unquote(url[:-9]))
          elif url.endswith('/move-page'):
@@ -104,7 +105,6 @@
              return change_status(request, unquote(url[:-24]),  
Page.PUBLISHED)
          elif url.endswith('/change-status-hidden'):
              return change_status(request, unquote(url[:-21]), Page.HIDDEN)
-
          ret = super(PageAdmin, self).__call__(request, url)


@@ -360,13 +360,25 @@
          # HACK: overrides the changelist template and later resets it to  
None
          if template_name:
              self.change_list_template = template_name
+
+        q=request.POST.get('q', '').strip()
+
+        if q:
+            page_ids = list(set([c.page.pk for c in  
Content.objects.filter(body__icontains=q)]))
+            pages =  
Page.objects.filter(pk__in=page_ids).order_by("tree_id")
+        else:
+            pages = Page.objects.root().order_by("tree_id")
+
          context = {
              'name': _("page"),
-            'pages': Page.objects.root().order_by("tree_id"),
+            'pages': pages,
              'opts': self.model._meta
          }
+
+
          context.update(extra_context or {})
          change_list = self.changelist_view(request, context)
+
          self.change_list_template = None
          return change_list


Modified:  
branches/electron/pages/templates/admin/pages/page/change_list_table.html
==============================================================================
---  
branches/electron/pages/templates/admin/pages/page/change_list_table.html       
 
(original)
+++  
branches/electron/pages/templates/admin/pages/page/change_list_table.html       
 
Fri May  8 03:03:24 2009
@@ -1,4 +1,15 @@
  {% load i18n pages_tags %}
+
+<div id="toolbar">
+<form id="changelist-search" action="" method="post">
+    <div>
+        <label for="searchbar"><img  
src="/admin_media/img/admin/icon_searchbox.png" alt="{% trans "Search" %}"  
/></label>
+        <input type="text" size="25" name="q" value="{{q}}" id="searchbar"  
/>
+        <input type="submit" name="g" value="{% trans "Go" %}" />
+    </div>
+</form>
+</div>
+
  <table cellspacing="0" id="page-list">
      <thead>
          <tr>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to