Skip to content

Commit cd43df8

Browse files
author
Richard Jones
committed
fix bug introduced into CSV export and view (issue 2550529)
1 parent 5613dbe commit cd43df8

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2009-03-?? 1.4.8
5+
6+
Fixes:
7+
- bug introduced into CVS export and view
8+
9+
410
2009-03-13 1.4.7 (r4202)
511

612
Features:

roundup/cgi/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def handle(self):
10411041
row = []
10421042
for name in columns:
10431043
# check permission to view this property on this item
1044-
if exists and not self.hasPermission('View', itemid=itemid,
1044+
if not self.hasPermission('View', itemid=itemid,
10451045
classname=request.classname, property=name):
10461046
raise exceptions.Unauthorised, self._(
10471047
'You do not have permission to view %(class)s'

roundup/cgi/templating.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def csv(self):
624624
classname=self._klass.classname, property=name):
625625
raise Unauthorised('view', self._klass.classname,
626626
translator=self._client.translator)
627-
row.append(str(klass.get(itemid, name)))
628627
value = self._klass.get(nodeid, name)
629628
if value is None:
630629
l.append('')

share/roundup/templates/classic/html/user.index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<td tal:content="python:user.address.email() or default">&nbsp;</td>
3535
<td tal:content="python:user.phone.plain() or default">&nbsp;</td>
3636
<td tal:condition="context/is_retire_ok">
37-
<form style="padding:0"
37+
<form style="padding:0" method="POST"
3838
tal:attributes="action string:user${user/id}">
3939
<input type="hidden" name="@template" value="index">
4040
<input type="hidden" name="@action" value="retire">

test/test_cgi.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
#
1111
# $Id: test_cgi.py,v 1.36 2008-08-07 06:12:57 richard Exp $
1212

13-
import unittest, os, shutil, errno, sys, difflib, cgi, re
13+
import unittest, os, shutil, errno, sys, difflib, cgi, re, StringIO
1414

1515
from roundup.cgi import client, actions, exceptions
1616
from roundup.cgi.exceptions import FormError
1717
from roundup.cgi.templating import HTMLItem
1818
from roundup.cgi.form_parser import FormParser
1919
from roundup import init, instance, password, hyperdb, date
2020

21+
from mocknull import MockNull
22+
2123
import db_test_base
2224

2325
NEEDS_INSTANCE = 1
@@ -614,13 +616,13 @@ def testBackwardsCompat(self):
614616
# SECURITY
615617
#
616618
# XXX test all default permissions
617-
def _make_client(self, form, classname='user', nodeid='2', userid='2'):
619+
def _make_client(self, form, classname='user', nodeid='1', userid='2'):
618620
cl = client.Client(self.instance, None, {'PATH_INFO':'/',
619621
'REQUEST_METHOD':'POST'}, makeForm(form))
620622
cl.classname = 'user'
621-
cl.nodeid = '1'
623+
cl.nodeid = nodeid
622624
cl.db = self.db
623-
cl.userid = '2'
625+
cl.userid = userid
624626
cl.language = ('en',)
625627
return cl
626628

@@ -646,6 +648,33 @@ def own_record(db, userid, itemid): return userid == itemid
646648
self.failUnlessRaises(exceptions.Unauthorised,
647649
actions.EditItemAction(cl).handle)
648650

651+
def testCSVExport(self):
652+
cl = self._make_client({'@columns': 'id,name'}, nodeid=None,
653+
userid='1')
654+
cl.classname = 'status'
655+
output = StringIO.StringIO()
656+
cl.request = MockNull()
657+
cl.request.wfile = output
658+
actions.ExportCSVAction(cl).handle()
659+
self.assertEquals('id,name\r\n1,unread\r\n2,deferred\r\n3,chatting\r\n'
660+
'4,need-eg\r\n5,in-progress\r\n6,testing\r\n7,done-cbb\r\n'
661+
'8,resolved\r\n',
662+
output.getvalue())
663+
664+
def testCSVExportFailPermission(self):
665+
cl = self._make_client({'@columns': 'id,email,password'}, nodeid=None,
666+
userid='2')
667+
cl.classname = 'user'
668+
output = StringIO.StringIO()
669+
cl.request = MockNull()
670+
cl.request.wfile = output
671+
self.assertRaises(exceptions.Unauthorised,
672+
actions.ExportCSVAction(cl).handle)
673+
674+
675+
def test_suite():
676+
suite = unittest.TestSuite()
677+
649678
def test_suite():
650679
suite = unittest.TestSuite()
651680
suite.addTest(unittest.makeSuite(FormTestCase))

0 commit comments

Comments
 (0)