def jbofh_pquota_history(self, operator, person_id, when=None): ret = [] if when is None: when = cereconf.PQ_MAX_LIGHT_HISTORY_WHEN for r in self._pquota_history( operator, self.bu.find_person(person_id), when): tstamp = r['tstamp'] trace = r.get('trace', '') or "" # Only consider the last hop of the trace. if trace.count(","): trace = trace.split(",")[-1] # Ignore trace values including space, they're on the # obsoleted human-readable format. if trace.count(":") and not trace.count(" "): from mx.DateTime import DateTime, DateTimeDeltaFromSeconds # TODO: what is this code supposed to do? last_event # is not defiend. Fix! time_t = int(last_event.split(":")[-1]) tstamp = DateTime(1970) + DateTimeDeltaFromSeconds(time_t) tstamp += tstamp.gmtoffset() tmp = { 'job_id': r['job_id'], 'transaction_type': r['transaction_type'], 'tstamp': tstamp, 'pageunits_free': r['pageunits_free'], 'pageunits_accum': r['pageunits_accum'], 'pageunits_paid': r['pageunits_paid'], 'kroner': float(r['kroner'])} if not r['update_by']: r['update_by'] = r['update_program'] tmp['update_by'] = r['update_by'][:10] if r['transaction_type'] == six.text_type(self.const.pqtt_printout): tmp['data'] = ( "%s:%s" % (r['printer_queue'][:10], r['job_name']))[:20] elif r['transaction_type'] == six.text_type(self.const.pqtt_quota_fill_pay): tmp['data'] = "%s:%s kr" % (r['description'][:10], r['kroner']) elif r['transaction_type'] == six.text_type(self.const.pqtt_quota_fill_free): tmp['data'] = r['description'] elif r['transaction_type'] == six.text_type(self.const.pqtt_undo): tmp['data'] = ("undo %s: %s" % (r['target_job_id'], r['description']))[:20] elif r['transaction_type'] == six.text_type(self.const.pqtt_balance): tmp['data'] = "balance" ret.append(tmp) # Transaction order may be different from the job completion order ret.sort(lambda a, b: cmp(a['tstamp'], b['tstamp'])) return ret