3383
3383
target_link_title = None
3384
3384
many_bugtasks = False
3386
template = ViewPageTemplateFile(
3387
'../templates/bugtask-tasks-and-nominations-table-row.pt')
3386
3389
def __init__(self, context, request):
3387
3390
super(BugTaskTableRowView, self).__init__(context, request)
3388
3391
self.milestone_source = MilestoneVocabulary
3393
def initialize(self):
3394
super(BugTaskTableRowView, self).initialize()
3395
link = canonical_url(self.context)
3396
edit_link = link + '/+editstatus'
3397
view_link = link + '/+viewstatus'
3398
can_edit = check_permission('launchpad.Edit', self.context)
3399
task_link = edit_link if can_edit else view_link
3400
bugtask_id = self.context.id
3401
launchbag = getUtility(ILaunchBag)
3402
is_primary = self.context.id == launchbag.bugtask.id
3404
# Looking at many_bugtasks is an important optimization. With
3405
# 150+ bugtasks, it can save three or four seconds of rendering
3407
expandable=(not self.many_bugtasks and self.canSeeTaskDetails()),
3408
indent_task=ISeriesBugTarget.providedBy(self.context.target),
3409
is_conjoined_slave=self.is_conjoined_slave,
3410
task_link=task_link,
3411
edit_link=edit_link,
3412
view_link=view_link,
3416
row_id='tasksummary%d' % bugtask_id,
3417
form_row_id='task%d' % bugtask_id,
3418
row_css_class='highlight' if is_primary else None,
3419
target_link=canonical_url(self.context.target),
3420
target_link_title=self.target_link_title,
3421
user_can_edit_importance=self.context.userCanEditImportance(
3423
importance_css_class='importance' + self.context.importance.name,
3424
importance_title=self.context.importance.title,
3425
# We always look up all milestones, so there's no harm
3426
# using len on the list here and avoid the COUNT query.
3427
target_has_milestones=len(self._visible_milestones) > 0,
3390
3430
def canSeeTaskDetails(self):
3391
3431
"""Whether someone can see a task's status details.
3405
3445
self.context.bug.duplicateof is None and
3406
3446
not self.is_converted_to_question)
3408
def expandable(self):
3409
"""Can the task's details be expanded?
3411
They can if there are not too many bugtasks, and if the user can see
3412
the task details."""
3413
# Looking at many_bugtasks is an important optimization. With 150+
3414
# bugtasks, it can save three or four seconds of rendering time.
3415
return not self.many_bugtasks and self.canSeeTaskDetails()
3417
def getTaskRowCSSClass(self):
3418
"""The appropriate CSS class for the row in the Affects table.
3420
Currently this consists solely of highlighting the current context.
3422
bugtask = self.context
3423
if bugtask == getUtility(ILaunchBag).bugtask:
3428
def shouldIndentTask(self):
3429
"""Should this task be indented in the task listing on the bug page?
3431
Returns True or False.
3433
return ISeriesBugTarget.providedBy(self.context.target)
3436
"""Return the proper link to the bugtask whether it's editable."""
3437
user = getUtility(ILaunchBag).user
3438
bugtask = self.context
3439
if check_permission('launchpad.Edit', user):
3440
return canonical_url(bugtask) + "/+editstatus"
3442
return canonical_url(bugtask) + "/+viewstatus"
3444
3448
def _getSeriesTargetNameHelper(self, bugtask):
3445
3449
"""Return the short name of bugtask's targeted series."""
3446
3450
series = bugtask.distroseries or bugtask.productseries
3602
3597
'title': filter.title,
3603
3598
'description': filter.description,
3606
3600
# Display the search field only if the user can set any person
3608
user = getUtility(ILaunchBag).user
3609
3603
hide_assignee_team_selection = (
3610
3604
not self.context.userCanSetAnyAssignee(user) and
3611
3605
(user is None or user.teams_participated_in.count() == 0))
3613
'row_id': 'tasksummary%s' % self.context.id,
3614
'bugtask_path': '/'.join(
3615
[''] + canonical_url(self.context).split('/')[3:]),
3616
'prefix': get_prefix(self.context),
3617
'assignee_value': self.context.assignee
3618
and self.context.assignee.name,
3619
'assignee_is_team': self.context.assignee
3620
and self.context.assignee.is_team,
3621
'assignee_vocabulary': assignee_vocabulary,
3622
'assignee_vocabulary_filters': filter_details,
3623
'hide_assignee_team_selection': hide_assignee_team_selection,
3624
'user_can_unassign': self.context.userCanUnassign(user),
3625
'target_is_product': IProduct.providedBy(self.context.target),
3626
'status_widget_items': self.status_widget_items,
3627
'status_value': self.context.status.title,
3628
'importance_widget_items': self.importance_widget_items,
3629
'importance_value': self.context.importance.title,
3630
'milestone_widget_items': self.milestone_widget_items,
3631
'milestone_value': (self.context.milestone and
3633
self.context.milestone,
3634
request=IWebServiceClientRequest(
3637
'user_can_edit_assignee': self.user_can_edit_assignee,
3638
'user_can_edit_milestone': self.user_can_edit_milestone,
3639
'user_can_edit_status': not self.context.bugwatch,
3640
'user_can_edit_importance': (
3641
self.user_can_edit_importance and
3642
not self.context.bugwatch)})
3608
row_id=self.data['row_id'],
3609
bugtask_path='/'.join([''] + self.data['link'].split('/')[3:]),
3610
prefix=get_prefix(cx),
3611
assignee_value=cx.assignee and cx.assignee.name,
3612
assignee_is_team=cx.assignee and cx.assignee.is_team,
3613
assignee_vocabulary=assignee_vocabulary,
3614
assignee_vocabulary_filters=filter_details,
3615
hide_assignee_team_selection=hide_assignee_team_selection,
3616
user_can_unassign=cx.userCanUnassign(user),
3617
target_is_product=IProduct.providedBy(cx.target),
3618
status_widget_items=self.status_widget_items,
3619
status_value=cx.status.title,
3620
importance_widget_items=self.importance_widget_items,
3621
importance_value=cx.importance.title,
3622
milestone_widget_items=self.milestone_widget_items,
3626
request=IWebServiceClientRequest(self.request))
3627
if cx.milestone else None),
3628
user_can_edit_assignee=self.user_can_edit_assignee,
3629
user_can_edit_milestone=self.user_can_edit_milestone,
3630
user_can_edit_status=not cx.bugwatch,
3631
user_can_edit_importance=(
3632
self.user_can_edit_importance and not cx.bugwatch)
3645
3636
class BugsBugTaskSearchListingView(BugTaskSearchListingView):