Advertisement
Guest User

ConnectionComponent.__init__()

a guest
Jun 11th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. def __init__(self, request, data, for_admin):
  2.     """Initializes this component.
  3.    """
  4.     self.for_admin = for_admin
  5.     self.idx = 7 if for_admin else 8
  6.     r = data.redirect
  7.  
  8.     list_config = lists.ListConfiguration(add_key_column=False)
  9.     list_config.addColumn('key', 'Key', (lambda ent, *args: "%s" % (
  10.         ent.keyName())), hidden=True)
  11.     list_config.addColumn('org', 'Organization',
  12.                   (lambda ent, *args: ent.organization.name))
  13.    
  14.     list_config.addColumn('role', 'Role',
  15.                   (lambda ent, *args: ent.role),
  16.                   options=[('mentor', 'Mentor'), ('org_admin', 'Org Admin')])
  17.     actions = [('pending', 'Action Required'),
  18.                ('accepted|rejected', 'Handled'),
  19.                ('delayed|needs_info', 'Standby'),
  20.                ('withdrawn', 'Withdrawn')]
  21.     list_config.addColumn('user', 'User',
  22.                   (lambda ent, *args: ent.user.name))
  23.     if self.for_admin:
  24.       list_config.addColumn('user_action', 'Status',
  25.                   (lambda ent, *args: ent.user_action),
  26.                   options=actions)
  27.     else:
  28.       list_config.addColumn('org_action', 'Status',
  29.                   (lambda ent, *args: ent.org_action),
  30.                   options=actions)
  31.     list_config.setRowAction(
  32.         lambda ent, *args: r.request(ent).url())
  33.     self._list_config = list_config
  34.  
  35.     super(ConnectionComponent, self).__init__(request, data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement