Ejemplo n.º 1
0
  def GatherPageData(self, mr):
    """Build up a dictionary of data values to use when rendering the page.

    Args:
      mr: commonly usef info parsed from the request.

    Returns:
      Dict of values used by EZT for rendering the page.
    """
    with self.profiler.Phase('getting hotlist'):
      if mr.hotlist_id is None:
        self.abort(404, 'no hotlist specified')
    if mr.auth.user_id:
      self.services.user.AddVisitedHotlist(
          mr.cnxn, mr.auth.user_id, mr.hotlist_id)

    if mr.mode == 'grid':
      page_data = self.GetGridViewData(mr)
    else:
      page_data = self.GetTableViewData(mr)

    with self.profiler.Phase('making page perms'):
      owner_permissions = permissions.CanAdministerHotlist(
          mr.auth.effective_ids, mr.hotlist)
      editor_permissions = permissions.CanEditHotlist(
          mr.auth.effective_ids, mr.hotlist)
      # TODO(jojwang): each issue should have an individual
      # SetStar status based on its project to indicate whether or not
      # the star icon should be shown to the user.
      page_perms = template_helpers.EZTItem(
          EditIssue=None, SetStar=mr.auth.user_id)

    allow_rerank = (not mr.group_by_spec and mr.sort_spec.startswith(
        'rank') and (owner_permissions or editor_permissions))

    user_hotlists = self.services.features.GetHotlistsByUserID(
        mr.cnxn, mr.auth.user_id)
    try:
      user_hotlists.remove(self.services.features.GetHotlist(
          mr.cnxn, mr.hotlist_id))
    except ValueError:
      pass
    # Note: The HotlistView is created and returned in servlet.py
    page_data.update({'owner_permissions': ezt.boolean(owner_permissions),
                      'editor_permissions': ezt.boolean(editor_permissions),
                      'issue_tab_mode': 'issueList',
                      'grid_mode': ezt.boolean(mr.mode == 'grid'),
                      'set_star_token': '', # needed for shared ezt templates.
                      'page_perms': page_perms,
                      'colspec': mr.col_spec,
                      'allow_rerank': ezt.boolean(allow_rerank),
                      'csv_link': framework_helpers.FormatURL(
                          mr, '%d/csv' % mr.hotlist_id, num=100),
                      'is_hotlist': ezt.boolean(True),
                      'col_spec': mr.col_spec.lower(),
                      'user_hotlists': user_hotlists,
                      'viewing_user_page': ezt.boolean(True),
                      })
    return page_data
Ejemplo n.º 2
0
  def GatherPageData(self, mr):
    """Build up a dictionary of data values to use when rendering the page."""
    if mr.auth.user_id:
      self.services.user.AddVisitedHotlist(
          mr.cnxn, mr.auth.user_id, mr.hotlist_id)

    all_members = (mr.hotlist.owner_ids +
                   mr.hotlist.editor_ids + mr.hotlist.follower_ids)

    hotlist_url = hotlist_helpers.GetURLOfHotlist(
        mr.cnxn, mr.hotlist, self.services.user)

    with self.profiler.Phase('gathering members on this page'):
      users_by_id = framework_views.MakeAllUserViews(
          mr.cnxn, self.services.user, all_members)
      framework_views.RevealAllEmailsToMembers(mr, users_by_id)

    untrusted_user_group_proxies = []
    # TODO(jojwang): implement FindUntrustedGroups()

    with self.profiler.Phase('making member views'):
      owner_views = self._MakeMemberViews(mr, mr.hotlist.owner_ids, users_by_id)
      editor_views = self._MakeMemberViews(mr, mr.hotlist.editor_ids,
                                           users_by_id)
      follower_views = self._MakeMemberViews(mr, mr.hotlist.follower_ids,
                                             users_by_id)
      all_member_views = owner_views + editor_views + follower_views

    pagination = paginate.ArtifactPagination(
        mr, all_member_views, MEMBERS_PER_PAGE,'%s%s' % (
              hotlist_url, urls.HOTLIST_PEOPLE))

    offer_membership_editing = permissions.CanAdministerHotlist(
        mr.auth.effective_ids, mr.hotlist)

    newly_added_views = [mv for mv in all_member_views
                         if str(mv.user.user_id) in mr.GetParam('new', [])]

    return {
        'is_hotlist': ezt.boolean(True),
        'untrusted_user_groups': untrusted_user_group_proxies,
        'pagination': pagination,
        'initial_add_members': '',
        'subtab_mode': None,
        'initially_expand_form': ezt.boolean(False),
        'newly_added_views': newly_added_views,
        'offer_membership_editing': ezt.boolean(offer_membership_editing),
        'total_num_owners': len(mr.hotlist.owner_ids),
        'check_abandonment': ezt.boolean(True),
        'initial_new_owner_username': '',
        'placeholder': 'new-owner-username',
        'open_dialog': ezt.boolean(False),
        'viewing_user_page': ezt.boolean(True),
        }
Ejemplo n.º 3
0
 def ProcessFormData(self, mr, post_data):
   """Process the posted form."""
   permit_edit = permissions.CanAdministerHotlist(
       mr.auth.effective_ids, mr.hotlist)
   if not permit_edit:
     raise permissions.PermissionException(
         'User is not permitted to edit hotlist membership')
   hotlist_url = hotlist_helpers.GetURLOfHotlist(
       mr.cnxn, mr.hotlist, self.services.user)
   if 'addbtn' in post_data:
     return self.ProcessAddMembers(mr, post_data, hotlist_url)
   elif 'removebtn' in post_data:
     return self.ProcessRemoveMembers(mr, post_data, hotlist_url)
   elif 'changeowners' in post_data:
     return self.ProcessChangeOwnership(mr, post_data)
Ejemplo n.º 4
0
    def GatherPageData(self, mr):
        """Buil up a dictionary of data values to use when rendering the page."""
        if mr.auth.user_id:
            self.services.user.AddVisitedHotlist(mr.cnxn, mr.auth.user_id,
                                                 mr.hotlist_id)
        cant_administer_hotlist = not permissions.CanAdministerHotlist(
            mr.auth.effective_ids, mr.hotlist)

        return {
            'initial_summary': mr.hotlist.summary,
            'initial_description': mr.hotlist.description,
            'initial_name': mr.hotlist.name,
            'initial_default_col_spec': mr.hotlist.default_col_spec,
            'initial_is_private': ezt.boolean(mr.hotlist.is_private),
            'cant_administer_hotlist': ezt.boolean(cant_administer_hotlist),
            'viewing_user_page': ezt.boolean(True),
        }