Skip to content
This repository
Browse code

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

…xcel functionality
  • Loading branch information...
commit 26cda479c9e1973ee1bf5f6ef9972e77b50ce585 1 parent 076e558
Or Arbel authored
4 auxiliary/tests.py
@@ -146,7 +146,9 @@ def test_internal_links(self):
146 146 self.failUnless(link, "There seems to be an empty link in %s (href='')" % page)
147 147 if (link in visited_links) or (link.startswith("http")) or link.startswith("#"):
148 148 continue
149   - if link.startswith("./"):
  149 + if link.startswith("../"):
  150 + link = '/' + '/'.join(link.split('/')[1:])
  151 + elif link.startswith("./"):
150 152 link = link[2:]
151 153 elif link.startswith("."):
152 154 link = link[1:]
5 hashnav/list.py
@@ -112,10 +112,15 @@ def get_context(self):
112 112 self.get_items()
113 113 self.paginate_items()
114 114 template_list_name = '%s_list' % self.template_object_name
  115 +
  116 + params = '' if len(self.request.GET) == 0 else self.request.GET.urlencode() + '&'
  117 + csv_path = 'api/v2' + self.request.path + '?' + params + 'format=csv&limit=0'
  118 +
115 119 context.update({
116 120 'paginator': self.paginator,
117 121 'page_obj': self.page,
118 122 'is_paginated': self.paginator is not None,
  123 + 'csv_path': csv_path,
119 124 template_list_name: self.items,
120 125 })
121 126 return context
4 laws/views.py
@@ -615,7 +615,7 @@ def get_context(self):
615 615 context['friend_pages'] = r
616 616 context['form'] = self._get_filter_form()
617 617 context['query_string'] = self.request.META['QUERY_STRING']
618   - context['csv_file'] = BillCsvView.filename if default_storage.exists(BillCsvView.filename) else None
  618 +
619 619 return context
620 620
621 621
@@ -652,7 +652,7 @@ def get_context(self):
652 652
653 653 context['form'] = self._get_filter_form()
654 654 context['query_string'] = self.request.META['QUERY_STRING']
655   - context['csv_file'] = VoteCsvView.filename if default_storage.exists(VoteCsvView.filename) else None
  655 +
656 656 return context
657 657
658 658
3  mks/views.py
@@ -16,7 +16,6 @@
16 16 from backlinks.pingback.server import default_server
17 17 from actstream import actor_stream
18 18 from actstream.models import Follow
19   -
20 19 from hashnav.detail import DetailView
21 20 from models import Member, Party, Knesset
22 21 from polyorg.models import CandidateList
@@ -77,7 +76,7 @@ def get_context_data(self, **kwargs):
77 76 context['friend_pages'] = self.pages
78 77 context['stat_type'] = info
79 78 context['title'] = dict(self.pages)[info]
80   -
  79 + context['csv_path'] = 'api/v2/member' + '?' + self.request.GET.urlencode() + '&format=csv&limit=0'
81 80 context['past_mks'] = Member.current_knesset.filter(is_current=False)
82 81
83 82 # We make sure qs are lists so that the template can get min/max
2  templates/laws/bill_list.html
@@ -14,7 +14,7 @@
14 14 <ul class="actions">
15 15 <li>
16 16 <span id="export-csv" class="awesome-button medium">
17   - <a href="{% if not csv_file %}./csv/?{% else %}{{MEDIA_URL}}{{csv_file}}{% endif %}">{% trans 'Export data to Excel' %}</a>
  17 + <a href="../{{csv_path}}">{% trans 'Export data to Excel' %}</a>
18 18 </span>
19 19 </li>
20 20 </ul>
2  templates/laws/vote_list.html
@@ -23,7 +23,7 @@
23 23 </div>
24 24 <div class="span3 social-details">
25 25 <div class="spacer actions-panel">
26   - <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>
  26 + <a class="btn btn-big" href="../{{csv_path}}">{% trans 'Export data to Excel' %}</a>
27 27 </div>
28 28 </div>
29 29 </div>
2  templates/mks/export_csv_link.html
@@ -2,7 +2,7 @@
4 templates/mks/member_list.html
@@ -102,5 +102,7 @@
102 102 </div>
103 103
104 104
105   - {% include "mks/export_csv_link.html" %}
  105 + <span id="export-csv" class="awesome-button medium">
  106 + <a href=" https://oknesset.org/{{csv_path}}">{% trans 'Export data to Excel' %}</a>
  107 + </span>
106 108 {% endblock %}
2  templates/mks/party_list.html
@@ -55,7 +55,7 @@
55 55 </div>
56 56 {% comment %} CSV button behavior is broken, doesn't take into account active data set
57 57 <p style="text-align:left">
58   - <a class="btn" href="./csv">{% trans "Export data to Excel" %}</a>
  58 + <a class="btn" href="../{{csv_path}}">{% trans "Export data to Excel" %}</a>
59 59 </p>
60 60
61 61 {% endcomment %}

0 comments on commit 26cda47

Please sign in to comment.
Something went wrong with that request. Please try again.