correction pour créer les url dans template.
--- a/web/hdabo/templates/generic_sheet.html Thu Jul 07 16:10:14 2011 +0200
+++ b/web/hdabo/templates/generic_sheet.html Thu Jul 07 17:18:18 2011 +0200
@@ -56,14 +56,16 @@
{% block content %}
{{block.super}}
- <p>Fiche(s) {% if valid %}<b>validées</b>{% else %}<b>non validées</b>{% endif %}
- pour l'organisation <b>{{ orga_name }}</b> : {{nb_sheets}} fiche(s)</p>
+ <p>
+ {% if tag %} Fiche(s) concernées par le tag <b>{{ tag.label }}</b>
+ {% else %} Fiche(s) {% if valid %}<b>validées</b>{% else %}<b>non validées</b>{% endif %} pour l'organisation <b>{{ orga_name }}</b>
+ {% endif %} : {{nb_sheets}} fiche(s)</p>
<div id="count_nav_top">
- <p><a href="{% url hdabo.views.display_datasheet ds_id=zero_id %}{{param_str}}&index=0"><<</a>
- <a href="{% url hdabo.views.display_datasheet ds_id=prev_id%}{{param_str}}&index={{prev_index}}"><</a>
+ <p><a href="{% url hdabo.views.display_datasheet ds_id=zero_id %}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index=0"><<</a>
+ <a href="{% url hdabo.views.display_datasheet ds_id=prev_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{prev_index}}"><</a>
{{displayed_index}}/{{nb_sheets}}
- <a href="{% url hdabo.views.display_datasheet ds_id=next_id%}{{param_str}}&index={{next_index}}">></a>
- <a href="{% url hdabo.views.display_datasheet ds_id=last_id%}{{param_str}}&index={{last_index}}">>></a></p>
+ <a href="{% url hdabo.views.display_datasheet ds_id=next_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{next_index}}">></a>
+ <a href="{% url hdabo.views.display_datasheet ds_id=last_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{last_index}}">>></a></p>
</div>
<table>
<tr class="imageline {% cycle 'hdabosimpleevenline' 'hdabosimpleoddline' %}"><td>
@@ -71,10 +73,10 @@
</td></tr>
</table>
<div id="count_nav_bottom">
- <p><a href="{% url hdabo.views.display_datasheet ds_id=zero_id %}{{param_str}}"><<</a>
- <a href="{% url hdabo.views.display_datasheet ds_id=prev_id%}{{param_str}}"><</a>
+ <p><a href="{% url hdabo.views.display_datasheet ds_id=zero_id %}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index=0"><<</a>
+ <a href="{% url hdabo.views.display_datasheet ds_id=prev_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{prev_index}}"><</a>
{{displayed_index}}/{{nb_sheets}}
- <a href="{% url hdabo.views.display_datasheet ds_id=next_id%}{{param_str}}">></a>
- <a href="{% url hdabo.views.display_datasheet ds_id=last_id%}{{param_str}}">>></a></p>
+ <a href="{% url hdabo.views.display_datasheet ds_id=next_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{next_index}}">></a>
+ <a href="{% url hdabo.views.display_datasheet ds_id=last_id%}?{% if tag %}tag={{tag.id}}{% endif %}&nb_sheets={{nb_sheets}}&index={{last_index}}">>></a></p>
</div>
{% endblock %}
--- a/web/hdabo/views.py Thu Jul 07 16:10:14 2011 +0200
+++ b/web/hdabo/views.py Thu Jul 07 17:18:18 2011 +0200
@@ -71,10 +71,10 @@
else :
nb_sheets = None
# If there is tag parameter, it means that we display all the ds tagged by one particular tag
- param_str = None
+ tag = None
if "tag" in request.GET :
- param_str = "?tag=" + request.GET["tag"]
- datasheets_qs = Datasheet.objects.filter(tags__in=[Tag.objects.get(id=int(request.GET["tag"]))]).order_by("organisation__name","original_creation_date").select_related("format")
+ tag = Tag.objects.get(id=int(request.GET["tag"]))
+ datasheets_qs = Datasheet.objects.filter(tags__in=[tag]).order_by("organisation__name","original_creation_date").select_related("format")
# If tag is set and if ds_id is None, it means that we have to display the first ds
if not ds_id :
index = 0
@@ -109,12 +109,6 @@
else :
prev_index = next_index = 0
prev_id = next_id = datasheets_qs[0].hda_id
-
- if param_str :
- param_str += "&"
- else :
- param_str = "?"
- param_str += "nb_sheets=" + str(nb_sheets)
# We get the ORDERED tags if we display one sheet (case valid = 0 and 1)
ordered_tags = TaggedSheet.objects.filter(datasheet=ds).select_related("tag").order_by('order')
@@ -130,8 +124,8 @@
'zero_id':zero_id, 'prev_index':prev_index, 'prev_id':prev_id,
'next_index':next_index, 'next_id':next_id,
'last_index':last_index, 'last_id':last_id,
- 'displayed_index':displayed_index, 'valid':ds.validated,
- 'param_str':param_str, 'categories':json.dumps(get_categories())},
+ 'displayed_index':displayed_index, 'tag':tag, 'valid':ds.validated,
+ 'categories':json.dumps(get_categories())},
context_instance=RequestContext(request))