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

Side by Side Diff: appengine/monorail/framework/alerts.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
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 """Helpers for showing alerts at the top of the page.
7
8 These alerts are then displayed by alerts.ezt.
9 """
10
11 import time
12
13 from third_party import ezt
14
15 # Expiration time for special features of timestamped links.
16 # This is not for security, just for informational messages that
17 # make sense in the context of a user session, but that should
18 # not appear days later if the user follows a bookmarked link.
19 _LINK_EXPIRATION_SEC = 8
20
21
22 class AlertsView(object):
23 """EZT object for showing alerts at the top of the page."""
24
25 def __init__(self, mr):
26 # Used to show message confirming item was updated
27 self.updated = mr.GetIntParam('updated')
28
29 # Used to show message confirming item was moved and the location of the new
30 # item.
31 self.moved_to_project = mr.GetParam('moved_to_project')
32 self.moved_to_id = mr.GetIntParam('moved_to_id')
33 self.moved = self.moved_to_project and self.moved_to_id
34
35 # Used to show message confirming item was copied and the location of the
36 # new item.
37 self.copied_from_id = mr.GetIntParam('copied_from_id')
38 self.copied_to_project = mr.GetParam('copied_to_project')
39 self.copied_to_id = mr.GetIntParam('copied_to_id')
40 self.copied = self.copied_to_project and self.copied_to_id
41
42 # Used to show message confirming items deleted
43 self.deleted = mr.GetParam('deleted')
44
45 # If present, we will show message confirming that data was saved
46 self.saved = mr.GetParam('saved')
47
48 link_generation_timestamp = mr.GetIntParam('ts', default_value=0)
49 now = int(time.time())
50 ts_links_are_valid = now - link_generation_timestamp < _LINK_EXPIRATION_SEC
51
52 show_alert = ts_links_are_valid and (
53 self.updated or self.moved or self.copied or self.deleted or self.saved)
54 self.show = ezt.boolean(show_alert)
OLDNEW
« no previous file with comments | « appengine/monorail/framework/actionlimit.py ('k') | appengine/monorail/framework/artifactcollision.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698