team4alfanous team mailing list archive
-
team4alfanous team
-
Mailing list archive
-
Message #00303
[Branch ~team4alfanous/alfanous/alfanous-git] Rev 488: Back compatibility of links between the old WUI and new one
------------------------------------------------------------
revno: 488
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Sat 2013-01-05 18:54:02 +0100
message:
Back compatibility of links between the old WUI and new one
- the first's based on the old API which search as:
search=QUERY
- the second is based on the new API which search as:
action=search&query=QUERY
modified:
src/alfanous-django/wui/views.py
--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git
Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous-django/wui/views.py'
--- src/alfanous-django/wui/views.py 2013-01-05 17:08:08 +0000
+++ src/alfanous-django/wui/views.py 2013-01-05 17:54:02 +0000
@@ -46,22 +46,33 @@
def results( request ):
""" """
+ show_params = { "action":"show", "query": "all" }
+
if request.GET.has_key( "query" ) and not ( request.GET.has_key( "action" ) and not request.GET["action"] == "search" ):
- raw_search = RAWoutput.do( request.GET )
- raw_suggest = RAWoutput.do( #use suggest as second action
- { "action":"suggest",
- "query": request.GET["query"]
+ search_params = request.GET
+ suggest_params = { "action":"suggest", "query": request.GET["query"] }
+ elif request.GET.has_key( "search" ):
+ ## back-compatibility of links:
+ # if it's a classic API style, wrap it to the new API style
+ search_params = { "action": "search",
+ "query": request.GET["search"],
+ "page": request.GET["page"] if request.GET.has_key( "page" ) else 1,
+ "sortedby": request.GET["sortedby"] if request.GET.has_key( "sortedby" ) else "relevance"
+ }
+ suggest_params = {
+ "action":"suggest",
+ "query": request.GET["search"]
}
- )
else:
- raw_search = None
- raw_suggest = None
+ search_params = None
+ suggest_params = None
- raw_show = RAWoutput.do( #use show as third action
- { "action":"show",
- "query": "all"
- }
- )
+ #use search as first action
+ raw_search = RAWoutput.do( search_params ) if search_params else None
+ #use suggest as second action
+ raw_suggest = RAWoutput.do( suggest_params ) if suggest_params else None
+ #use show as third action
+ raw_show = RAWoutput.do( show_params ) if show_params else None
# language information
@@ -88,7 +99,7 @@
"image_extension": "_ar" if language_info['bidi']
else "_en",
- "params": request.GET,
+ "params": search_params,
"results": raw_search,
"suggestions": raw_suggest,
"info": raw_show