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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/sitewide/userprofile.py ('k') | appengine/monorail/sitewide/usersettings.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/sitewide/userprojects.py
diff --git a/appengine/monorail/sitewide/userprojects.py b/appengine/monorail/sitewide/userprojects.py
new file mode 100644
index 0000000000000000000000000000000000000000..3dd52c2617cff504ba959c9ef01eadb66d027304
--- /dev/null
+++ b/appengine/monorail/sitewide/userprojects.py
@@ -0,0 +1,55 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Classes for the user projects feed."""
+
+from framework import jsonfeed
+from sitewide import sitewide_helpers
+
+
+class ProjectsJsonFeed(jsonfeed.JsonFeed):
+ """Servlet to get all of a user's projects in JSON format."""
+
+ def HandleRequest(self, mr):
+ """Retrieve list of a user's projects for the "My projects" menu.
+
+ Args:
+ mr: common information parsed from the HTTP request.
+
+ Returns:
+ Results dictionary in JSON format
+ """
+ if not mr.auth.user_id:
+ return {'error': 'User is not logged in.'}
+
+ json_data = {}
+
+ with self.profiler.Phase('page processing'):
+ json_data.update(self._GatherProjects(mr))
+
+ return json_data
+
+ def _GatherProjects(self, mr):
+ """Return a dict of project names the current user is involved in."""
+ with self.profiler.Phase('GetUserProjects'):
+ project_lists = sitewide_helpers.GetUserProjects(
+ mr.cnxn, self.services, mr.auth.user_pb, mr.auth.effective_ids,
+ mr.auth.effective_ids)
+ (visible_ownership, _visible_deleted, visible_membership,
+ visible_contrib) = project_lists
+
+ with self.profiler.Phase('GetStarredProjects'):
+ starred_projects = sitewide_helpers.GetViewableStarredProjects(
+ mr.cnxn, self.services, mr.auth.user_id,
+ mr.auth.effective_ids, mr.auth.user_pb)
+
+ projects_dict = {
+ 'memberof': [p.project_name for p in visible_membership],
+ 'ownerof': [p.project_name for p in visible_ownership],
+ 'contributorto': [p.project_name for p in visible_contrib],
+ 'starred_projects': [p.project_name for p in starred_projects],
+ }
+
+ return projects_dict
« 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