Changeset 9670 for main/waeup.kofa/trunk


Ignore:
Timestamp:
17 Nov 2012, 20:47:02 (12 years ago)
Author:
Henrik Bettermann
Message:

See email 'Re: AsyncReportJob?'.

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  
    151151
    152152    def get_report_jobs_description(user_id=None):
    153         """Get running/completed report jobs fur `user_id` as list of tuples.
     153        """Get running/completed report jobs for `user_id` as list of tuples.
    154154
    155155        The results contain enough information to render a status page
     
    348348        kw = self.kwargs.get('kw', dict())
    349349        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()])
    351351        if len(args) and len(kw):
    352352            str_repr = args + ', ' + kw
     
    485485            downloadable = job.finished and not job.failed
    486486            running = not (downloadable or discardable)
    487             # XXX: starttime might be better included in description
    488487            starttime = getattr(job, 'begin_after', None)
    489488            if starttime:
    490                 # XXX is it really neccessary to get a localized time here?
    491489                starttime = starttime.astimezone(getUtility(IKofaUtils).tzinfo)
    492490                starttime = starttime.strftime("%Y-%m-%d %H:%M:%S %Z")
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports.py

    r9668 r9670  
    134134            self.args[0], self.mode, self.author)
    135135
    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' % (
    142147            self.session, self.mode, self._creation_dt_string)
     148        title = title.replace('/', '_').replace(' ','_')
     149        return title
    143150
    144151    def create_pdf(self):
     
    234241
    235242    def render(self):
    236         filename = "%s.pdf" % (self.context.__repr__())
     243        filename = "%s.pdf" % (self.context.title)
    237244        self.response.setHeader(
    238245            'Content-Type', 'application/pdf')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_reports.py

    r9669 r9670  
    3333        return
    3434
    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):
    3745        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_'))
    4249        return
    4350
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_reports.py

    r9660 r9670  
    218218        self.assertEqual(
    219219            job.description,
    220             "Report 1 ('a', 'b', a = 1, b = 2)")
     220            "Report 1 ('a', 'b', 1, 2)")
    221221        # w/o args nor kwargs
    222222        job = AsyncReportJob(self.root_folder, 'report1')
     
    231231        job = AsyncReportJob(self.root_folder, 'report1', kw=kw)
    232232        self.assertEqual(
    233             job.description, "Report 1 (a = 1, b = 2)")
     233            job.description, "Report 1 (1, 2)")
    234234        return
    235235
     
    248248            self.root_folder, 'NOT_EXISTENT', kw=dict(a=1, b=2))
    249249        self.assertEqual(
    250             job.description, u'Unregistered Report Generator (a = 1, b = 2)')
     250            job.description, u'Unregistered Report Generator (1, 2)')
    251251        # with args and kws set
    252252        job = AsyncReportJob(
    253253            self.root_folder, 'NOT_EXISTENT', args=['a'], kw=dict(b=2))
    254254        self.assertEqual(
    255             job.description, u"Unregistered Report Generator ('a', b = 2)")
     255            job.description, u"Unregistered Report Generator ('a', 2)")
    256256        return
    257257
Note: See TracChangeset for help on using the changeset viewer.