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

Unified Diff: appengine/monorail/sitewide/usersettings.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/userprojects.py ('k') | appengine/monorail/sitewide/userupdates.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/sitewide/usersettings.py
diff --git a/appengine/monorail/sitewide/usersettings.py b/appengine/monorail/sitewide/usersettings.py
new file mode 100644
index 0000000000000000000000000000000000000000..23841b2fc5ed0e1e9307c04385151bd11643d63a
--- /dev/null
+++ b/appengine/monorail/sitewide/usersettings.py
@@ -0,0 +1,58 @@
+# 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 settings (preferences) page."""
+
+import time
+import urllib
+
+from third_party import ezt
+
+from framework import framework_helpers
+from framework import permissions
+from framework import servlet
+from framework import template_helpers
+from framework import urls
+
+
+class UserSettings(servlet.Servlet):
+ """Shows a page with a simple form to edit user preferences."""
+
+ _PAGE_TEMPLATE = 'sitewide/user-settings-page.ezt'
+
+ def AssertBasePermission(self, mr):
+ """Assert that the user has the permissions needed to view this page."""
+ super(UserSettings, self).AssertBasePermission(mr)
+
+ if not mr.auth.user_id:
+ raise permissions.PermissionException(
+ 'Anonymous users are not allowed to edit user settings')
+
+ def GatherPageData(self, mr):
+ """Build up a dictionary of data values to use when rendering the page."""
+ page_data = {
+ 'user_tab_mode': 'st3',
+ 'logged_in_user_pb': template_helpers.PBProxy(mr.auth.user_pb),
+ # When on /hosting/settings, the logged-in user is the viewed user.
+ 'viewed_user': mr.auth.user_view,
+ 'offer_saved_queries_subtab': ezt.boolean(True),
+ 'viewing_self': ezt.boolean(True),
+ }
+ page_data.update(
+ framework_helpers.UserSettings.GatherUnifiedSettingsPageData(
+ mr.auth.user_id, mr.auth.user_view, mr.auth.user_pb))
+ return page_data
+
+ def ProcessFormData(self, mr, post_data):
+ """Process the posted form."""
+ framework_helpers.UserSettings.ProcessSettingsForm(
+ mr.cnxn, self.services.user, post_data,
+ mr.auth.user_id, mr.auth.user_pb)
+
+ url = framework_helpers.FormatAbsoluteURL(
+ mr, urls.USER_SETTINGS, include_project=False,
+ saved=1, ts=int(time.time()))
+
+ return url
« no previous file with comments | « appengine/monorail/sitewide/userprojects.py ('k') | appengine/monorail/sitewide/userupdates.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698