Permalink
Browse files

- Issue #129 - Use API v2 with ?format=csv to restore the export to e…

…xcel functionality
  • Loading branch information...
1 parent 076e558 commit 26cda479c9e1973ee1bf5f6ef9972e77b50ce585 Or Arbel committed Jul 12, 2013
View
4 auxiliary/tests.py
@@ -146,7 +146,9 @@ def test_internal_links(self):
self.failUnless(link, "There seems to be an empty link in %s (href='')" % page)
if (link in visited_links) or (link.startswith("http")) or link.startswith("#"):
continue
- if link.startswith("./"):
+ if link.startswith("../"):
+ link = '/' + '/'.join(link.split('/')[1:])
+ elif link.startswith("./"):
link = link[2:]
elif link.startswith("."):
link = link[1:]
View
5 hashnav/list.py
@@ -112,10 +112,15 @@ def get_context(self):
self.get_items()
self.paginate_items()
template_list_name = '%s_list' % self.template_object_name
+
+ params = '' if len(self.request.GET) == 0 else self.request.GET.urlencode() + '&'
+ csv_path = 'api/v2' + self.request.path + '?' + params + 'format=csv&limit=0'
+
context.update({
'paginator': self.paginator,
'page_obj': self.page,
'is_paginated': self.paginator is not None,
+ 'csv_path': csv_path,
template_list_name: self.items,
})
return context
View
4 laws/views.py
@@ -615,7 +615,7 @@ def get_context(self):
context['friend_pages'] = r
context['form'] = self._get_filter_form()
context['query_string'] = self.request.META['QUERY_STRING']
- context['csv_file'] = BillCsvView.filename if default_storage.exists(BillCsvView.filename) else None
+
return context
@@ -652,7 +652,7 @@ def get_context(self):
context['form'] = self._get_filter_form()
context['query_string'] = self.request.META['QUERY_STRING']
- context['csv_file'] = VoteCsvView.filename if default_storage.exists(VoteCsvView.filename) else None
+
return context
View
3 mks/views.py
@@ -16,7 +16,6 @@
from backlinks.pingback.server import default_server
from actstream import actor_stream
from actstream.models import Follow
-
from hashnav.detail import DetailView
from models import Member, Party, Knesset
from polyorg.models import CandidateList
@@ -77,7 +76,7 @@ def get_context_data(self, **kwargs):
context['friend_pages'] = self.pages
context['stat_type'] = info
context['title'] = dict(self.pages)[info]
-
+ context['csv_path'] = 'api/v2/member' + '?' + self.request.GET.urlencode() + '&format=csv&limit=0'
context['past_mks'] = Member.current_knesset.filter(is_current=False)
# We make sure qs are lists so that the template can get min/max
View
2 templates/laws/bill_list.html
@@ -14,7 +14,7 @@
<ul class="actions">
<li>
<span id="export-csv" class="awesome-button medium">
- <a href="{% if not csv_file %}./csv/?{% else %}{{MEDIA_URL}}{{csv_file}}{% endif %}">{% trans 'Export data to Excel' %}</a>
+ <a href="../{{csv_path}}">{% trans 'Export data to Excel' %}</a>
</span>
</li>
</ul>
View
2 templates/laws/vote_list.html
@@ -23,7 +23,7 @@
</div>
<div class="span3 social-details">
<div class="spacer actions-panel">
- <a class="btn btn-big" href="{% if query_string or not csv_file %}./csv/?{{ query_string }}{% else %}{{MEDIA_URL}}{{csv_file}}{% endif %}">{% trans 'Export data to Excel' %}</a>
+ <a class="btn btn-big" href="../{{csv_path}}">{% trans 'Export data to Excel' %}</a>
</div>
</div>
</div>
View
2 templates/mks/export_csv_link.html
@@ -2,7 +2,7 @@
<ul class="actions">
<li>
<span id="export-csv" class="awesome-button medium">
- <a href="./csv">{% trans "Export data to Excel" %}</a>
+ <a href="../{{csv_path}}">{% trans "Export data to Excel" %}</a>
</span>
</li>
</ul>
View
4 templates/mks/member_list.html
@@ -102,5 +102,7 @@
</div>
- {% include "mks/export_csv_link.html" %}
+ <span id="export-csv" class="awesome-button medium">
+ <a href=" https://oknesset.org/{{csv_path}}">{% trans 'Export data to Excel' %}</a>
+ </span>
{% endblock %}
View
2 templates/mks/party_list.html
@@ -55,7 +55,7 @@
</div>
{% comment %} CSV button behavior is broken, doesn't take into account active data set
<p style="text-align:left">
- <a class="btn" href="./csv">{% trans "Export data to Excel" %}</a>
+ <a class="btn" href="../{{csv_path}}">{% trans "Export data to Excel" %}</a>
</p>
{% endcomment %}

0 comments on commit 26cda47

Please sign in to comment.