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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « appengine/monorail/sitewide/userprojects.py ('k') | appengine/monorail/sitewide/userupdates.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 settings (preferences) page."""
7
8 import time
9 import urllib
10
11 from third_party import ezt
12
13 from framework import framework_helpers
14 from framework import permissions
15 from framework import servlet
16 from framework import template_helpers
17 from framework import urls
18
19
20 class UserSettings(servlet.Servlet):
21 """Shows a page with a simple form to edit user preferences."""
22
23 _PAGE_TEMPLATE = 'sitewide/user-settings-page.ezt'
24
25 def AssertBasePermission(self, mr):
26 """Assert that the user has the permissions needed to view this page."""
27 super(UserSettings, self).AssertBasePermission(mr)
28
29 if not mr.auth.user_id:
30 raise permissions.PermissionException(
31 'Anonymous users are not allowed to edit user settings')
32
33 def GatherPageData(self, mr):
34 """Build up a dictionary of data values to use when rendering the page."""
35 page_data = {
36 'user_tab_mode': 'st3',
37 'logged_in_user_pb': template_helpers.PBProxy(mr.auth.user_pb),
38 # When on /hosting/settings, the logged-in user is the viewed user.
39 'viewed_user': mr.auth.user_view,
40 'offer_saved_queries_subtab': ezt.boolean(True),
41 'viewing_self': ezt.boolean(True),
42 }
43 page_data.update(
44 framework_helpers.UserSettings.GatherUnifiedSettingsPageData(
45 mr.auth.user_id, mr.auth.user_view, mr.auth.user_pb))
46 return page_data
47
48 def ProcessFormData(self, mr, post_data):
49 """Process the posted form."""
50 framework_helpers.UserSettings.ProcessSettingsForm(
51 mr.cnxn, self.services.user, post_data,
52 mr.auth.user_id, mr.auth.user_pb)
53
54 url = framework_helpers.FormatAbsoluteURL(
55 mr, urls.USER_SETTINGS, include_project=False,
56 saved=1, ts=int(time.time()))
57
58 return url
OLDNEW
« 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