Changeset 9638


Ignore:
Timestamp:
15 Nov 2012, 15:18:35 (12 years ago)
Author:
uli
Message:

ReportContainers? should provide more usable infos about jobs.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/reports.py

    r9633 r9638  
    132132
    133133    def get_report_jobs_description(user_id=None):
    134         """Get running/completed report jobs fur ?user_id` as list of tuples.
    135 
    136         Each tuple holds ``<job_id>, <description>,
    137         <status_translated>`` in that order, where ``<description>``
    138         is a human readable description of the report run and
    139         ``<status_translated>`` is the report jobs' status
    140         (translated).
     134        """Get running/completed report jobs fur `user_id` as list of tuples.
     135
     136        The results contain enough information to render a status page
     137        or similar. Each tuple holds::
     138
     139          (``<job_id>, <description>, <status_translated>,
     140          <discardable>, <downloadable>``)
     141
     142        in that order, with
     143
     144        ``<job_id>``
     145            The job id of the represented job. A string.
     146
     147        ``<description>``
     148            A human readable description of the report run.
     149
     150        ``<status_translated>``
     151            The status of report jobs' status (translated)
     152
     153        ``<discardable>``
     154            Boolean indicating whether the job can be discarded.
     155            Only completed jobs can be discarded.
     156
     157        ``<downloadable>``
     158            Boolean indicating whether the job result can be
     159            downloaded. This is only true if the job finished and
     160            didn't raised exceptions.
     161
     162        If ``user_id`` is ``None``, all jobs are returned.
    141163        """
    142164
     
    274296        if not self.finished:
    275297            return None
    276         if not IReport.providedBy(self.result):
     298        if not IReport.providedBy(getattr(self, 'result', None)):
    277299            return True
    278300        return False
     
    384406
    385407    def get_report_jobs_description(self, user_id=None):
    386         """Get running/completed report jobs fur ?user_id` as list of tuples.
    387 
    388         Each tuple holds ``<job_id>, <description>,
    389         <status_translated>`` in that order, where ``<description>``
    390         is a human readable description of the report run and
    391         ``<status_translated>`` is the report jobs' status
    392         (translated).
     408        """Get running/completed report jobs fur `user_id` as list of tuples.
     409
     410        The results contain enough information to render a status page
     411        or similar. Each tuple holds::
     412
     413          (``<job_id>, <description>, <status_translated>,
     414          <discardable>, <downloadable>``)
     415
     416        in that order, with
     417
     418        ``<job_id>``
     419            The job id of the represented job. A string.
     420
     421        ``<description>``
     422            A human readable description of the report run.
     423
     424        ``<status_translated>``
     425            The status of report jobs' status (translated)
     426
     427        ``<discardable>``
     428            Boolean indicating whether the job can be discarded.
     429            Only completed jobs can be discarded.
     430
     431        ``<downloadable>``
     432            Boolean indicating whether the job result can be
     433            downloaded. This is only true if the job finished and
     434            didn't raised exceptions.
     435
     436        If ``user_id`` is ``None``, all jobs are returned.
    393437        """
    394438        entries = self.get_running_report_jobs(user_id)
     
    398442            job = manager.get(job_id)
    399443            status = JOB_STATUS_MAP.get(job.status, job.status)[1]
     444            discardable = job.finished
     445            downloadable = job.finished and not job.failed
    400446            if not hasattr(job, 'description'):
    401447                continue
    402             result.append((job_id, job.description, status),)
     448            result.append((job_id, job.description, status,
     449                           discardable, downloadable),)
    403450        return result
    404451
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_reports.py

    r9633 r9638  
    368368        self.assertEqual(
    369369            result,
    370             [('2', 'Report 1 ()', u'new'),]
     370            [('2', 'Report 1 ()', u'new', False, False),]
    371371            )
    372372        return
Note: See TracChangeset for help on using the changeset viewer.