- Timestamp:
- 17 Nov 2012, 20:47:02 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/reports.py
r9661 r9670 151 151 152 152 def get_report_jobs_description(user_id=None): 153 """Get running/completed report jobs f ur `user_id` as list of tuples.153 """Get running/completed report jobs for `user_id` as list of tuples. 154 154 155 155 The results contain enough information to render a status page … … 348 348 kw = self.kwargs.get('kw', dict()) 349 349 args = ', '.join(["%r" % x for x in args]) 350 kw = ', '.join(['%s = %r' % (key, val) for key, val in kw.items()])350 kw = ', '.join(['%s' % val for val in kw.values()]) 351 351 if len(args) and len(kw): 352 352 str_repr = args + ', ' + kw … … 485 485 downloadable = job.finished and not job.failed 486 486 running = not (downloadable or discardable) 487 # XXX: starttime might be better included in description488 487 starttime = getattr(job, 'begin_after', None) 489 488 if starttime: 490 # XXX is it really neccessary to get a localized time here?491 489 starttime = starttime.astimezone(getUtility(IKofaUtils).tzinfo) 492 490 starttime = starttime.strftime("%Y-%m-%d %H:%M:%S %Z") -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports.py
r9668 r9670 134 134 self.args[0], self.mode, self.author) 135 135 136 def __str__(self): 137 """A nice human readable representation of a StudentsReport. 138 139 Includes infos about session, mode and creation datetime. 140 """ 141 return 'Students Report [session=%s, mode=%s] of %s ' % ( 136 #def __str__(self): 137 # """A nice human readable representation of a StudentsReport. 138 139 # Includes infos about session, mode and creation datetime. 140 # """ 141 # return 'Students Report [session=%s, mode=%s] of %s ' % ( 142 # self.session, self.mode, self._creation_dt_string) 143 144 @property 145 def title(self): 146 title = 'StudentsReport_%s_%s_%s' % ( 142 147 self.session, self.mode, self._creation_dt_string) 148 title = title.replace('/', '_').replace(' ','_') 149 return title 143 150 144 151 def create_pdf(self): … … 234 241 235 242 def render(self): 236 filename = "%s.pdf" % (self.context. __repr__())243 filename = "%s.pdf" % (self.context.title) 237 244 self.response.setHeader( 238 245 'Content-Type', 'application/pdf') -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_reports.py
r9669 r9670 33 33 return 34 34 35 def test_str(self): 36 # StudentsReport provide a nice string representation 35 #def test_str(self): 36 # # StudentsReport provide a nice string representation 37 # obj = StudentsReport(2010, 'Undergraduate Full-Time', author='Bob') 38 # self.assertEqual( 39 # obj.__str__()[:65], 40 # 'Students Report ' 41 # '[session=2010/2011, mode=Undergraduate Full-Time]') 42 # return 43 44 def test_title(self): 37 45 obj = StudentsReport(2010, 'Undergraduate Full-Time', author='Bob') 38 self.assertEqual( 39 obj.__str__()[:65], 40 'Students Report ' 41 '[session=2010/2011, mode=Undergraduate Full-Time]') 46 self.assertTrue( 47 obj.title.startswith( 48 'StudentsReport_2010_2011_Undergraduate_Full-Time_')) 42 49 return 43 50 -
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_reports.py
r9660 r9670 218 218 self.assertEqual( 219 219 job.description, 220 "Report 1 ('a', 'b', a = 1, b =2)")220 "Report 1 ('a', 'b', 1, 2)") 221 221 # w/o args nor kwargs 222 222 job = AsyncReportJob(self.root_folder, 'report1') … … 231 231 job = AsyncReportJob(self.root_folder, 'report1', kw=kw) 232 232 self.assertEqual( 233 job.description, "Report 1 ( a = 1, b =2)")233 job.description, "Report 1 (1, 2)") 234 234 return 235 235 … … 248 248 self.root_folder, 'NOT_EXISTENT', kw=dict(a=1, b=2)) 249 249 self.assertEqual( 250 job.description, u'Unregistered Report Generator ( a = 1, b =2)')250 job.description, u'Unregistered Report Generator (1, 2)') 251 251 # with args and kws set 252 252 job = AsyncReportJob( 253 253 self.root_folder, 'NOT_EXISTENT', args=['a'], kw=dict(b=2)) 254 254 self.assertEqual( 255 job.description, u"Unregistered Report Generator ('a', b =2)")255 job.description, u"Unregistered Report Generator ('a', 2)") 256 256 return 257 257
Note: See TracChangeset for help on using the changeset viewer.