Ignore:
Timestamp:
14 Nov 2012, 18:40:59 (12 years ago)
Author:
uli
Message:

Basic statistics for kofa. Still the functionality is hidden - but available :-)

File:
1 edited

Legend:

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

    r9510 r9633  
    4444        """not when any output was created.""")
    4545
     46    title = schema.TextLine(
     47        title = u"A human readable short description for a report.",
     48        default = u'Untitled',
     49        )
     50
     51    description = schema.Text(
     52        title = u"A human readable text describing a report.",
     53        default = u'No description'
     54        )
     55
    4656    def create_pdf():
    4757        """Generate a PDF copy.
     
    121131        """
    122132
     133    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).
     141        """
     142
    123143    def delete_report_entry(entry):
    124144        """Delete the report job denoted by `entry`.
     
    162182class Report(object):
    163183    creation_dt = None
     184
     185    @property
     186    def title(self):
     187        return _(u'A report')
     188
     189    @property
     190    def description(self):
     191        return _(u'A dummy report')
    164192
    165193    def __init__(self, args=[], kwargs={}):
     
    170198    def create_pdf(self):
    171199        raise NotImplementedError()
     200
     201    def __repr__(self):
     202        return 'Report(args=%r, kwargs=%r)' % (self.args, self.kwargs)
     203
    172204
    173205@implementer(IReportGenerator)
     
    266298        str_repr = '(' + str_repr + ')'
    267299        try:
    268             generator = queryUtility(
     300            generator = getUtility(
    269301                IReportGenerator, name=self._generator_name)
    270             name = generator.name
     302            name = generator.title
    271303        except:
    272             name = _('Invalid Report Generator')
     304            name = _('Unregistered Report Generator')
    273305        return name + ' ' + str_repr
    274306
     
    351383        return result
    352384
     385    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).
     393        """
     394        entries = self.get_running_report_jobs(user_id)
     395        result = []
     396        for (job_id, gen_name, user_name) in entries:
     397            manager = getUtility(IJobManager)
     398            job = manager.get(job_id)
     399            status = JOB_STATUS_MAP.get(job.status, job.status)[1]
     400            if not hasattr(job, 'description'):
     401                continue
     402            result.append((job_id, job.description, status),)
     403        return result
     404
    353405    def delete_report_entry(self, entry):
    354406        """Delete the report job denoted by `entry`.
Note: See TracChangeset for help on using the changeset viewer.