--- a/web/hdabo/static/hdabo/js/hdabo.js Fri Jul 08 12:03:07 2011 +0200
+++ b/web/hdabo/static/hdabo/js/hdabo.js Fri Jul 08 12:09:59 2011 +0200
@@ -35,6 +35,7 @@
datasheet_id:$('#datasheet_id').val(),
num_page:$('#num_page').val(),
nb_by_page:$('#nb_by_page').val(),
+ alpha:$('#alpha').val(),
searched:$('#searched_str').val()
},
callback : function(value, settings) {
@@ -90,6 +91,7 @@
datasheet_id:$('#datasheet_id').val(),
num_page:$('#num_page').val(),
nb_by_page:$('#nb_by_page').val(),
+ alpha:$('#alpha').val(),
searched:$('#searched_str').val()
},
callback : function(value, settings) {
@@ -111,6 +113,7 @@
datasheet_id:$('#datasheet_id').val(),
num_page:$('#num_page').val(),
nb_by_page:$('#nb_by_page').val(),
+ alpha:$('#alpha').val(),
searched:$('#searched_str').val()
},
callback : function(value, settings) {
@@ -250,6 +253,7 @@
datasheet_id:$('#datasheet_id').val(),
num_page:$('#num_page').val(),
nb_by_page:$('#nb_by_page').val(),
+ alpha:$('#alpha').val(),
searched:$('#searched_str').val(),
tag_id:id_tag,
activated:new_checked
--- a/web/hdabo/templates/all_tags.html Fri Jul 08 12:03:07 2011 +0200
+++ b/web/hdabo/templates/all_tags.html Fri Jul 08 12:09:59 2011 +0200
@@ -56,45 +56,46 @@
{% csrf_token %}
<p>Chercher :
{% for s in search_def %}
- <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, searched=s.1 %}">{{s.0}}</a>
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, alpha=alpha, searched=s.1 %}">{{s.0}}</a>
{% endfor %}
<input type="text" name="searched" value="{% if searched %}{{searched}}{% endif %}" id="searched" />
</p>
<p>Tags {{ current_page.start_index }} à {{ current_page.end_index }} sur {{ nb_total }}</p>
<div id="count_nav_top"><p>
{% if searched and searched != "" %}
- <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, searched=searched %}"><<</a>
- <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, searched=searched %}"><</a>
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}"><</a>
{{ num_page }}/{{ last_page }}
- <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, searched=searched %}">></a>
- <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, searched=searched %}">>></a></p>
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}">>></a></p>
{% else %}
- <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page %}"><<</a>
- <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page %}"><</a>
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, alpha=alpha %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, alpha=alpha %}"><</a>
{{ num_page }}/{{ last_page }}
- <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page %}">></a>
- <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page %}">>></a>
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, alpha=alpha %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, alpha=alpha %}">>></a>
{% endif %}</p>
</div>
<input type="hidden" name="num_page" value="{{num_page}}" id="num_page" />
<input type="hidden" name="nb_by_page" value="{{nb_by_page}}" id="nb_by_page" />
<input type="hidden" name="searched_str" value="{% if searched %}{{searched}}{% endif %}" id="searched_str" />
+ <input type="hidden" name="alpha" value="{% if alpha %}{{alpha}}{% endif %}" id="alpha" />
<div id="tag_table_container">
{% include "partial/all_tags_table.html" %}
</div>
<div id="count_nav_bottom"><p>
{% if searched and searched != "" %}
- <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, searched=searched %}"><<</a>
- <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, searched=searched %}"><</a>
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}"><</a>
{{ num_page }}/{{ last_page }}
- <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, searched=searched %}">></a>
- <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, searched=searched %}">>></a></p>
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, alpha=alpha, searched=searched %}">>></a></p>
{% else %}
- <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page %}"><<</a>
- <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page %}"><</a>
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, alpha=alpha %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, alpha=alpha %}"><</a>
{{ num_page }}/{{ last_page }}
- <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page %}">></a>
- <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page %}">>></a>
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, alpha=alpha %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, alpha=alpha %}">>></a>
{% endif %}</p>
</div>
{% endblock %}
--- a/web/hdabo/templates/partial/all_tags_table.html Fri Jul 08 12:03:07 2011 +0200
+++ b/web/hdabo/templates/partial/all_tags_table.html Fri Jul 08 12:09:59 2011 +0200
@@ -1,7 +1,15 @@
{% block tag_table %}
<table id="all_tags_table">
<tr><th>id</th>
- <th>label</th>
+ <th>
+ {% if alpha != "true" and alpha != "1" %}
+ {% if searched and searched != "" %}
+ <a href="{% url hdabo.views.all_tags num_page='1', nb_by_page=nb_by_page, alpha='true', searched=searched %}">label</a>
+ {% else %}
+ <a href="{% url hdabo.views.all_tags num_page='1', nb_by_page=nb_by_page, alpha='true' %}">label</a>
+ {% endif %}
+ {% else %}label{% endif %}
+ </th>
{% comment %}<th>original_label</th>{% endcomment %}
<th class="text_centered">Lien W</th>
<th class="text_centered">Lien D</th>
@@ -9,7 +17,15 @@
<th class="large_25 text_centered">Supprimer<br/>le lien W</th>
<th>Alias</th>
<th class="text_centered">Nb de<br/>fiches</th>
- <th>Popularité</th></tr>
+ <th>
+ {% if alpha == "true" or alpha == "1" %}
+ {% if searched and searched != "" %}
+ <a href="{% url hdabo.views.all_tags num_page='1', nb_by_page=nb_by_page, alpha='false', searched=searched %}">Popularité</a>
+ {% else %}
+ <a href="{% url hdabo.views.all_tags num_page='1', nb_by_page=nb_by_page, alpha='false' %}">Popularité</a>
+ {% endif %}
+ {% else %}Popularité{% endif %}
+ </th></tr>
{% for tag in tags %}
<tr class="imageline {% cycle 'hdabooddline' 'hdaboevenline' %}">
<td class="reset_wp_info">{{tag.id}}</td>
--- a/web/hdabo/urls.py Fri Jul 08 12:03:07 2011 +0200
+++ b/web/hdabo/urls.py Fri Jul 08 12:09:59 2011 +0200
@@ -36,7 +36,8 @@
url(r'^alltags$', 'hdabo.views.all_tags'),
url(r'^alltags/(?P<num_page>[\w-]+)$', 'hdabo.views.all_tags'),
url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/$', 'hdabo.views.all_tags'),
- url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/(?P<searched>.+)/$', 'hdabo.views.all_tags'),
+ url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/(?P<alpha>[\w-]+)/$', 'hdabo.views.all_tags'),
+ url(r'^alltags/(?P<num_page>[\w-]+)/(?P<nb_by_page>[\w-]+)/(?P<alpha>[\w-]+)/(?P<searched>.+)/$', 'hdabo.views.all_tags'),
url(r'^validatedatasheet$', 'hdabo.views.validate_datasheet'),
url(r'^validatedatasheet/(?P<ds_id>[\w-]+)$', 'hdabo.views.validate_datasheet'),
url(r'^validatedatasheet/(?P<ds_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.validate_datasheet'),
--- a/web/hdabo/views.py Fri Jul 08 12:03:07 2011 +0200
+++ b/web/hdabo/views.py Fri Jul 08 12:09:59 2011 +0200
@@ -183,7 +183,7 @@
@login_required
-def all_tags(request, num_page=None, nb_by_page=None, searched=None):
+def all_tags(request, num_page=None, nb_by_page=None, alpha="false", searched=None):
# If the view is asked after a form sent with post vars, it means that searched is a post var.
if u"searched" in request.POST :
@@ -192,7 +192,7 @@
num_page = 1
# Get paginator and current page
- current_page, p, num_page, nb_by_page = get_current_page(num_page, nb_by_page, searched)
+ current_page, p, num_page, nb_by_page = get_current_page(num_page, nb_by_page, alpha, searched)
prev_page = max(num_page - 1, 1)
next_page = min(num_page + 1, p.num_pages)
@@ -218,7 +218,7 @@
'prev_page':prev_page, 'next_page':next_page, 'last_page':last_page,
'num_page':num_page, 'nb_by_page':nb_by_page, 'searched':searched,
'categories':json.dumps(get_categories()),
- 'search_def':search_def, 'searched':searched},
+ 'search_def':search_def, 'alpha':alpha},
context_instance=RequestContext(request))
@@ -267,16 +267,16 @@
@login_required
-def get_all_tags_table(request, num_page=None, nb_by_page=None, searched=None):
+def get_all_tags_table(request, num_page=None, nb_by_page=None, alpha="false", searched=None):
- current_page, p, num_page, nb_by_page = get_current_page(num_page, nb_by_page, searched) #@UnusedVariable
+ current_page, p, num_page, nb_by_page = get_current_page(num_page, nb_by_page, alpha, searched) #@UnusedVariable
return render_to_response("partial/all_tags_table.html",
- {'tags':current_page.object_list},
+ {'tags':current_page.object_list, 'nb_by_page':nb_by_page, 'searched':searched},
context_instance=RequestContext(request))
-def get_current_page(num_page=None, nb_by_page=None, searched=None):
+def get_current_page(num_page=None, nb_by_page=None, alpha="false", searched=None):
base_queryset = Tag.objects
@@ -285,7 +285,12 @@
regex = "^%s$" % (re.escape(searched).replace(re.escape(settings.SEARCH_STAR_CHARACTER),".*"))
base_queryset = base_queryset.filter(normalized_label__iregex=regex)
- alltags = base_queryset.annotate(num_ds=Count('datasheet')).order_by('-popularity','-num_ds','normalized_label', 'label')
+ alltags = base_queryset.annotate(num_ds=Count('datasheet'))
+ if alpha and (alpha=="true" or alpha=="1") :
+ alltags = alltags.order_by('normalized_label', 'label')
+ else :
+ alltags = alltags.order_by('-popularity','-num_ds', 'normalized_label', 'label')
+ #alltags = alltags.order_by('-popularity','label')
# We build the paginator for the requested list
if nb_by_page :
@@ -359,7 +364,7 @@
if old_pageid != pageid:
TaggedSheet.objects.filter(tag=tag).update(wikipedia_revision_id=revision_id)
- return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], searched=request.POST["searched"])
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], alpha=request.POST["alpha"], searched=request.POST["searched"])
@login_required
@@ -420,7 +425,7 @@
if u"datasheet_id" in request.POST :
return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
else :
- return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], searched=request.POST["searched"])
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], alpha=request.POST["alpha"], searched=request.POST["searched"])
@login_required
@@ -477,7 +482,7 @@
if u"datasheet_id" in request.POST :
return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
else :
- return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], searched=request.POST["searched"])
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], alpha=request.POST["alpha"], searched=request.POST["searched"])
@login_required
@@ -523,7 +528,7 @@
if u"datasheet_id" in request.POST :
return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
else :
- return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], searched=request.POST["searched"])
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], alpha=request.POST["alpha"], searched=request.POST["searched"])
def get_categories():
@@ -549,7 +554,7 @@
if u"datasheet_id" in request.POST :
return get_tag_table(request=request, ds_id=request.POST["datasheet_id"], valid=0)
else :
- return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], searched=request.POST["searched"])
+ return get_all_tags_table(request=request, num_page=request.POST["num_page"], nb_by_page=request.POST["nb_by_page"], alpha=request.POST["alpha"], searched=request.POST["searched"])
@login_required
def reorder_tag_datasheet(request):