provide party state field for use in work and qualification reports
This commit is contained in:
		
							parent
							
								
									f6f266acb5
								
							
						
					
					
						commit
						81dde67338
					
				
					 3 changed files with 43 additions and 8 deletions
				
			
		|  | @ -39,6 +39,9 @@ from loops import util | |||
| 
 | ||||
| class Field(BaseField): | ||||
| 
 | ||||
|     def getContext(self, row): | ||||
|         return row.context | ||||
| 
 | ||||
|     def getSelectValue(self, row): | ||||
|         return self.getValue(row) | ||||
| 
 | ||||
|  | @ -120,12 +123,13 @@ class StateField(Field): | |||
|     renderer = 'state' | ||||
| 
 | ||||
|     def getDisplayValue(self, row): | ||||
|         if IStateful.providedBy(row.context): | ||||
|             stf = row.context | ||||
|         elif row.context is None: | ||||
|         context = self.getContext(row) | ||||
|         if IStateful.providedBy(context): | ||||
|             stf = context | ||||
|         elif context is None: | ||||
|             return None | ||||
|         else: | ||||
|             stf = component.getAdapter(row.context, IStateful,  | ||||
|             stf = component.getAdapter(context, IStateful,  | ||||
|                                         name=self.statesDefinition) | ||||
|         stateObject = stf.getStateObject() | ||||
|         icon = stateObject.icon or 'led%s.png' % stateObject.color | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ from loops.organize.work.report import WorkRow | |||
| from loops.organize.work.report import deadline, day, task, party, state | ||||
| from loops.organize.work.report import dayStart, dayEnd | ||||
| from loops.organize.work.report import workTitle, workDescription | ||||
| from loops.organize.work.report import partyState | ||||
| from loops import util | ||||
| 
 | ||||
| 
 | ||||
|  | @ -38,7 +39,8 @@ class QualificationOverview(ReportInstance): | |||
| 
 | ||||
|     rowFactory = WorkRow | ||||
| 
 | ||||
|     fields = Jeep((task, party, workTitle, dayStart, dayEnd, state)) # +deadline? | ||||
|     fields = Jeep((task, party, workTitle, dayStart, dayEnd, state,)) | ||||
|                    #partyState,)) # +deadline? | ||||
| 
 | ||||
|     defaultOutputFields = fields | ||||
|     defaultSortCriteria = (party, task,) | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| # | ||||
| #  Copyright (c) 2014 Helmut Merz helmutm@cy55.de | ||||
| #  Copyright (c) 2015 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
|  | @ -22,13 +22,15 @@ Work report definitions. | |||
| 
 | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.component import adapter | ||||
| from zope.component import adapter, getAdapter | ||||
| 
 | ||||
| from cybertools.composer.report.base import Report | ||||
| from cybertools.composer.report.base import LeafQueryCriteria, CompoundQueryCriteria | ||||
| from cybertools.composer.report.field import CalculatedField | ||||
| from cybertools.composer.report.result import ResultSet, Row as BaseRow | ||||
| from cybertools.meta.interfaces import IOptions | ||||
| from cybertools.organize.interfaces import IWorkItems | ||||
| from cybertools.stateful.interfaces import IStateful | ||||
| from cybertools.util.date import timeStamp2Date, timeStamp2ISO | ||||
| from cybertools.util.jeep import Jeep | ||||
| from loops.common import adapted, baseObject | ||||
|  | @ -77,6 +79,19 @@ class DurationField(Field): | |||
|         return u'%02i:%02i' % divmod(value * 60, 60) | ||||
| 
 | ||||
| 
 | ||||
| class PartyStateField(StateField): | ||||
| 
 | ||||
|     def getContext(self, row): | ||||
|         if row.context is None: | ||||
|             return None | ||||
|         party = util.getObjectForUid(row.context.party) | ||||
|         ptype = adapted(party.conceptType) | ||||
|         stdefs = IOptions(ptype)('organize.stateful') or [] | ||||
|         if self.statesDefinition in stdefs: | ||||
|             return party | ||||
|         return None | ||||
| 
 | ||||
| 
 | ||||
| # common fields | ||||
| 
 | ||||
| tasks = Field('tasks', u'Tasks', | ||||
|  | @ -142,6 +157,11 @@ state = WorkItemStateField('state', u'State', | |||
|                 cssClass='center', | ||||
|                 statesDefinition='workItemStates', | ||||
|                 executionSteps=['query', 'output']) | ||||
| partyState = PartyStateField('partyState', u'Party State', | ||||
|                 description=u'State of the party, mainly for selection.', | ||||
|                 cssClass='center', | ||||
|                 statesDefinition='contact_states', | ||||
|                 executionSteps=['query', 'output']) | ||||
| 
 | ||||
| 
 | ||||
| # basic definitions and work report instance | ||||
|  | @ -177,10 +197,19 @@ class WorkRow(BaseRow): | |||
|             value = self.getDuration(attr) | ||||
|         return value | ||||
| 
 | ||||
|     def xx_getPartyState(self, attr): | ||||
|         party = util.getObjectForUid(self.context.party) | ||||
|         ptype = adapted(party.conceptType) | ||||
|         for std in IOptions(ptype)('organize.stateful') or []: | ||||
|             stf = getAdapter(party, IStateful, name=std) | ||||
|             return stf.state | ||||
|         return None | ||||
| 
 | ||||
|     attributeHandlers = dict(day=getDay,  | ||||
|                              dayStart=getStart, dayEnd=getEnd, | ||||
|                              dayFrom=getDay, dayTo=getDay, | ||||
|                              duration=getDuration, effort=getEffort) | ||||
|                              duration=getDuration, effort=getEffort,) | ||||
|                              #partyState=getPartyState) | ||||
| 
 | ||||
| 
 | ||||
| class WorkReportInstance(ReportInstance): | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue