forms: avoid hidden status when listing user forms (#1775)

This commit is contained in:
Frédéric Péters 2012-10-12 09:40:26 +02:00
parent 8efb42690d
commit f12f236dff
4 changed files with 29 additions and 4 deletions

View File

@ -182,6 +182,22 @@ class FormData(StorableObject):
return _('Unknown')
return wf_status.name
def get_visible_status(self, user=None):
if not self.evolution:
return self.get_status()
if not user:
user = get_request().user
for evo in reversed(self.evolution):
if not evo.status:
continue
wf_status = self.get_status(evo.status)
if not wf_status:
continue
if not wf_status.is_visible(self, user):
continue
return wf_status
return None
def get_workflow_form(self, user):
wf_status = self.get_workflow_status()
return wf_status.get_action_form(self, user)

View File

@ -314,8 +314,10 @@ class FormStatusPage(Directory):
if show_status and self.formdef.is_user_allowed_read_status_and_history(
get_request().user, self.filled):
'<p><span class="label">%s</span> ' % _('Status')
'<span class="value">%s</span></p>' % self.filled.get_status_label()
wf_status = self.filled.get_visible_status()
if wf_status:
'<p><span class="label">%s</span> ' % _('Status')
'<span class="value">%s</span></p>' % wf_status.name
'</div>'

View File

@ -1142,9 +1142,10 @@ class RootDirectory(AccessControlled, Directory):
for workflow in workflows:
# XXX: seperate endpoints from non-endpoints
for status in workflow.possible_status:
fms = [x for x in user_forms if x.status == 'wf-%s' % status.id and \
fms = [x for x in user_forms if \
not x.formdef.private_status_and_history and \
x.formdef.workflow.id == workflow.id and \
not x.formdef.private_status_and_history]
(x.get_visible_status() == status)]
if not fms:
continue
'<h2>%s</h2>' % _('Your forms with status "%s"') % status.name

View File

@ -321,6 +321,12 @@ class WorkflowStatus:
self.name = name
self.items = []
def __eq__(self, other):
if other is None:
return False
# this assumes both status are from the same workflow
return self.id == other.id
def append_item(self, type):
for klass in item_classes:
if klass.key == type: