team4alfanous team mailing list archive
-
team4alfanous team
-
Mailing list archive
-
Message #00294
[Branch ~team4alfanous/alfanous/alfanous-git] Rev 478: make the translations and recitations lists dynamic in the WUI
------------------------------------------------------------
revno: 478
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Fri 2013-01-04 21:03:59 +0100
message:
make the translations and recitations lists dynamic in the WUI
fix a key_error when the chosen recitation doesn't exist in the system
modified:
src/alfanous-django/templates/base.html
src/alfanous-django/templates/wui.html
src/alfanous-django/wui/views.py
src/alfanous/Outputs.py
src/alfanous/Searching.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/templates/base.html'
--- src/alfanous-django/templates/base.html 2013-01-02 16:25:44 +0000
+++ src/alfanous-django/templates/base.html 2013-01-04 20:03:59 +0000
@@ -233,6 +233,8 @@
<td colspan="4" style="background:url(/static/images/main_table_06.png) no-repeat;width:395px;height:21px;"> </td></tr>
</table>
+
+
<div class="donate-box" >
<a class="donate_button" target='_blank' href=''>{{ _("Donate") }}</a><br/>
</div>
@@ -268,7 +270,6 @@
<option value="recitation">{{ _("Recitation") }}</option>
</select><br /><!--[if lte IE 8]><![endif]-->
-
<span class="xtitle">{{ _("Sorted by") }} :</span>
<select id="sortedby" class="styled" name="sortedby">
<option value="score">{{ _("Default") }}</option>
@@ -278,38 +279,14 @@
<option value="subject">{{ _("Topics") }}</option>
</select><br /><!--[if lte IE 8]><![endif]-->
- <!--
- TODO generate dynamically the lists of translations and recitations
- {
- action: show,
- query: translations
- }
- -->
- <span class="xtitle"> {{ _("Translation:") }} :</span>
- <select id="translation" class="styled" name="translation">
- <option value="shakir">{{ _("Default") }}</option>
- <option value="None">{{ _("No translation") }}</option>
- <option value="shakir">{{ _("English - Shakir") }}</option>
- <option value="transliteration-en">{{ _("English - Transliteration") }}</option>
- </select><br /><!--[if lte IE 8]><![endif]-->
-
- <span class="xtitle"> {{ _("Recitation:") }}</span>
- <select id="recitation" class="styled" name="recitation">
- <option value="14">{{ _("Default") }}</option>
- <option value="14">{{ _("Mishary Rashid Alafasy") }}</option>
- <option value="1">{{ _("AbdulBasit AbdusSamad (Murattal style)") }}</option>
- <option value="10">{{ _("Abu Bakr Ash-Shaatree") }}</option>
- <option value="12">{{ _("Ahmed_ibn_Ali_al-Ajamy") }}</option>
- <option value="16">{{ _("Saad Al Ghamadi") }}</option>
- <option value="17">{{ _("Hani Rifai") }}</option>
- <option value="21">{{ _("Husary Mujawwad") }}</option>
- <option value="23">{{ _("Hudhaify") }}</option>
- <option value="30">{{ _("Menshawi") }}</option>
- <option value="37">{{ _("Muhammad Ayyoub") }}</option>
- <option value="43">{{ _("Saood bin Ibraaheem Ash-Shuraym") }}</option>
- <option value="45">{{ _("Ibrahim_Walk") }}</option>
- <option value="5">{{ _("Abdullah Basfar") }}</option>
- </select><br /><!--[if lte IE 8]><![endif]-->
+{% block translations_panel %}
+
+{% endblock %}
+
+{% block recitations_panel %}
+
+{% endblock %}
+
</div>
<br />
=== modified file 'src/alfanous-django/templates/wui.html'
--- src/alfanous-django/templates/wui.html 2013-01-04 00:05:45 +0000
+++ src/alfanous-django/templates/wui.html 2013-01-04 20:03:59 +0000
@@ -62,6 +62,30 @@
</div>
{% endblock %}
+{% block translations_panel %}
+ <span class="xtitle"> {{ _("Translation:") }} :</span>
+ <select id="translation" class="styled" name="translation">
+ <option value="en.shakir">{{ _("Default") }}</option>
+ <option value="None">{{ _("No translation") }}</option>
+ {% for translation_id, translation_name in info.show.translations.items %}
+ <option value="{{ translation_id }}">{{ translation_name }}</option>
+ {% endfor %}
+ </select><br /><!--[if lte IE 8]><![endif]-->
+{% endblock %}
+
+{% block recitations_panel %}
+ <span class="xtitle"> {{ _("Recitation:") }}</span>
+ <select id="recitation" class="styled" name="recitation">
+ <option value="14">{{ _("Default") }}</option>
+ <option value="0">{{ _("No recitation") }}</option>
+ {% for recitation_id, recitation_details in info.show.recitations.items %}
+ {% if recitation_id != "ayahCount" %}
+ <option value="{{ recitation_id }}">{{ recitation_details.name }} - {{ recitation_details.bitrate }} </option>
+ {% endif %}
+ {% endfor %}
+ </select><br /><!--[if lte IE 8]><![endif]-->
+{% endblock %}
+
{% block pages_bottom %}
{% block pages_top %}
<br />
=== modified file 'src/alfanous-django/wui/views.py'
--- src/alfanous-django/wui/views.py 2013-01-02 03:31:49 +0000
+++ src/alfanous-django/wui/views.py 2013-01-04 20:03:59 +0000
@@ -47,14 +47,21 @@
def results( request ):
""" """
if request.GET.has_key( "query" ) and not ( request.GET.has_key( "action" ) and not request.GET["action"] == "search" ):
- raw_results = RAWoutput.do( request.GET )
- raw_suggestions = RAWoutput.do( #use suggest as second action
+ raw_search = RAWoutput.do( request.GET )
+ raw_suggest = RAWoutput.do( #use suggest as second action
{ "action":"suggest",
- "query": request.GET["query"] }
+ "query": request.GET["query"]
+ }
)
else:
- raw_results = None
- raw_suggestions = None
+ raw_search = None
+ raw_suggest = None
+
+ raw_show = RAWoutput.do( #use show as third action
+ { "action":"show",
+ "query": "all"
+ }
+ )
# language information
@@ -68,8 +75,6 @@
request.LANGUAGE_CODE = translation.get_language()
- print raw_suggestions
-
return render_to_response( 'wui.html',
{
"bidi": "rtl" if language_info['bidi']
@@ -83,8 +88,9 @@
else "_en",
"params": request.GET,
- "results": raw_results,
- "suggestions": raw_suggestions
+ "results": raw_search,
+ "suggestions": raw_suggest,
+ "info": raw_show
}
)
=== modified file 'src/alfanous/Outputs.py'
--- src/alfanous/Outputs.py 2013-01-04 17:29:21 +0000
+++ src/alfanous/Outputs.py 2013-01-04 20:03:59 +0000
@@ -642,7 +642,8 @@
"text": Gword_tamdid( H( V( r["aya_"] ) ) ) if script == "standard"
else Gword_tamdid( H( r["uth_"] ) ),
"translation": trad_text[r["gid"]] if ( translation != "None" and translation and trad_text.has_key( r["gid"] ) ) else None,
- "recitation": None if not recitation else u"http://www.everyayah.com/data/" + self._recitations[recitation]["subfolder"].encode( "utf-8" ) + "/%03d%03d.mp3" % ( r["sura_id"], r["aya_id"] ),
+ "recitation": None if not recitation or not self._recitations.has_key( recitation ) \
+ else u"http://www.everyayah.com/data/" + self._recitations[recitation]["subfolder"].encode( "utf-8" ) + "/%03d%03d.mp3" % ( r["sura_id"], r["aya_id"] ),
"prev_aya":{
"id":adja_ayas[r["gid"] - 1]["aya_id"],
"sura":adja_ayas[r["gid"] - 1]["sura"],
=== modified file 'src/alfanous/Searching.py'
--- src/alfanous/Searching.py 2012-06-01 03:38:52 +0000
+++ src/alfanous/Searching.py 2013-01-04 20:03:59 +0000
@@ -124,8 +124,10 @@
query = self._qparser.parse( querystr )
results = self.searcher.search( query, limit, QSort( sortedby ), reverse )
terms = set()
- try:query.all_terms( terms )
- except:pass
+ try:
+ query.all_terms( terms )
+ except:
+ pass
return results, terms