Beispiel #1
0
 def testGroupVisibilityView(self):
     gvv_anyone = group_helpers.GroupVisibilityView(
         usergroup_pb2.MemberVisibility.ANYONE)
     gvv_members = group_helpers.GroupVisibilityView(
         usergroup_pb2.MemberVisibility.MEMBERS)
     gvv_owners = group_helpers.GroupVisibilityView(
         usergroup_pb2.MemberVisibility.OWNERS)
     self.assertEqual('Anyone on the Internet', gvv_anyone.name)
     self.assertEqual('Group Members', gvv_members.name)
     self.assertEqual('Group Owners', gvv_owners.name)
Beispiel #2
0
  def GatherPageData(self, _mr):
    """Build up a dictionary of data values to use when rendering the page."""
    visibility_levels = group_helpers.BuildUserGroupVisibilityOptions()
    initial_visibility = group_helpers.GroupVisibilityView(
        usergroup_pb2.MemberVisibility.ANYONE)
    group_types = group_helpers.BuildUserGroupTypeOptions()

    return {
        'groupadmin': '',
        'group_types': group_types,
        'import_group': '',
        'initial_friendprojects': '',
        'initial_group_type': '',
        'initial_name': '',
        'initial_visibility': initial_visibility,
        'visibility_levels': visibility_levels,
        }
Beispiel #3
0
  def GatherPageData(self, mr):
    """Build up a dictionary of data values to use when rendering the page."""
    group_id = mr.viewed_user_auth.user_id
    group_settings = self.services.usergroup.GetGroupSettings(
        mr.cnxn, group_id)
    visibility_levels = group_helpers.BuildUserGroupVisibilityOptions()
    initial_visibility = group_helpers.GroupVisibilityView(
        group_settings.who_can_view_members)
    group_types = group_helpers.BuildUserGroupTypeOptions()
    import_group = bool(group_settings.ext_group_type)
    if import_group:
      initial_group_type = group_helpers.GroupTypeView(
          group_settings.ext_group_type)
    else:
      initial_group_type = ''

    if group_settings.friend_projects:
      initial_friendprojects = ', '.join(
          self.services.project.LookupProjectNames(
              mr.cnxn, group_settings.friend_projects).values())
    else:
      initial_friendprojects = ''

    return {
        'admin_tab_mode': 'st2',
        'groupadmin': True,
        'groupid': group_id,
        'groupname': mr.viewed_username,
        'group_types': group_types,
        'import_group': import_group or '',
        'initial_friendprojects': initial_friendprojects,
        'initial_group_type': initial_group_type,
        'initial_visibility': initial_visibility,
        'offer_membership_editing': True,
        'visibility_levels': visibility_levels,
        }