Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: appengine/monorail/sitewide/userprojects.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/monorail/sitewide/userprofile.py ('k') | appengine/monorail/sitewide/usersettings.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Classes for the user projects feed."""
7
8 from framework import jsonfeed
9 from sitewide import sitewide_helpers
10
11
12 class ProjectsJsonFeed(jsonfeed.JsonFeed):
13 """Servlet to get all of a user's projects in JSON format."""
14
15 def HandleRequest(self, mr):
16 """Retrieve list of a user's projects for the "My projects" menu.
17
18 Args:
19 mr: common information parsed from the HTTP request.
20
21 Returns:
22 Results dictionary in JSON format
23 """
24 if not mr.auth.user_id:
25 return {'error': 'User is not logged in.'}
26
27 json_data = {}
28
29 with self.profiler.Phase('page processing'):
30 json_data.update(self._GatherProjects(mr))
31
32 return json_data
33
34 def _GatherProjects(self, mr):
35 """Return a dict of project names the current user is involved in."""
36 with self.profiler.Phase('GetUserProjects'):
37 project_lists = sitewide_helpers.GetUserProjects(
38 mr.cnxn, self.services, mr.auth.user_pb, mr.auth.effective_ids,
39 mr.auth.effective_ids)
40 (visible_ownership, _visible_deleted, visible_membership,
41 visible_contrib) = project_lists
42
43 with self.profiler.Phase('GetStarredProjects'):
44 starred_projects = sitewide_helpers.GetViewableStarredProjects(
45 mr.cnxn, self.services, mr.auth.user_id,
46 mr.auth.effective_ids, mr.auth.user_pb)
47
48 projects_dict = {
49 'memberof': [p.project_name for p in visible_membership],
50 'ownerof': [p.project_name for p in visible_ownership],
51 'contributorto': [p.project_name for p in visible_contrib],
52 'starred_projects': [p.project_name for p in starred_projects],
53 }
54
55 return projects_dict
OLDNEW
« no previous file with comments | « appengine/monorail/sitewide/userprofile.py ('k') | appengine/monorail/sitewide/usersettings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698