Ignore:
Timestamp:
16 Nov 2012, 08:30:20 (12 years ago)
Author:
Henrik Bettermann
Message:

Display start time of job in table.

File:
1 edited

Legend:

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

    r9642 r9644  
    2222from persistent.list import PersistentList
    2323from zope import schema
    24 from zope.component import getUtility, getUtilitiesFor, queryUtility
     24from zope.component import (
     25    getUtility, getUtilitiesFor, queryUtility, ComponentLookupError)
    2526from zope.component.hooks import setSite
    2627from zope.interface import implementer
     
    2829from waeup.kofa.async import AsyncJob
    2930from waeup.kofa.interfaces import (
    30     IJobManager, JOB_STATUS_MAP, IKofaPluggable, IKofaObject)
     31    IJobManager, JOB_STATUS_MAP, IKofaPluggable, IKofaObject, IKofaUtils)
    3132from waeup.kofa.interfaces import MessageFactory as _
    3233from waeup.kofa.utils.helpers import now
     
    104105        )
    105106
     107    starttime = schema.TextLine(
     108        title = u'Human readable start datetime')
     109
    106110    def __init__(site, generator_name):
    107111        """Create a report job via generator."""
     
    177181            downloaded. This is only true if the job finished and
    178182            didn't raised exceptions.
     183
     184        ``<starttime>``
     185            Datetime string indicating when the job was started.
    179186
    180187        If ``user_id`` is ``None``, all jobs are returned.
     
    291298    def __init__(self, site, generator_name, args=[], kw={}):
    292299        self._generator_name = generator_name
     300        try:
     301            tz = getUtility(IKofaUtils).tzinfo
     302            self.starttime = now(tz).strftime("%Y-%m-%d %H:%M:%S %Z")
     303        except ComponentLookupError:
     304            self.starttime = None
    293305        super(AsyncReportJob, self).__init__(
    294306            report_job, site, generator_name, args=args, kw=kw)
     
    461473            didn't raised exceptions.
    462474
     475        ``<starttime>``
     476            Datetime object indicating when the job was started.
     477
    463478        If ``user_id`` is ``None``, all jobs are returned.
    464479        """
     
    471486            discardable = job.finished
    472487            downloadable = job.finished and not job.failed
     488            starttime = job.starttime
    473489            if not hasattr(job, 'description'):
    474490                continue
    475491            result.append((job_id, job.description, status,
    476                            discardable, downloadable),)
     492                           discardable, downloadable, starttime),)
    477493        return result
    478494
Note: See TracChangeset for help on using the changeset viewer.