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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/framework/actionlimit.py ('k') | appengine/monorail/framework/artifactcollision.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/framework/alerts.py
diff --git a/appengine/monorail/framework/alerts.py b/appengine/monorail/framework/alerts.py
new file mode 100644
index 0000000000000000000000000000000000000000..ef939b199d97344fce16eb95c096ba60a705b4eb
--- /dev/null
+++ b/appengine/monorail/framework/alerts.py
@@ -0,0 +1,54 @@
+# 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
+
+"""Helpers for showing alerts at the top of the page.
+
+These alerts are then displayed by alerts.ezt.
+"""
+
+import time
+
+from third_party import ezt
+
+# Expiration time for special features of timestamped links.
+# This is not for security, just for informational messages that
+# make sense in the context of a user session, but that should
+# not appear days later if the user follows a bookmarked link.
+_LINK_EXPIRATION_SEC = 8
+
+
+class AlertsView(object):
+ """EZT object for showing alerts at the top of the page."""
+
+ def __init__(self, mr):
+ # Used to show message confirming item was updated
+ self.updated = mr.GetIntParam('updated')
+
+ # Used to show message confirming item was moved and the location of the new
+ # item.
+ self.moved_to_project = mr.GetParam('moved_to_project')
+ self.moved_to_id = mr.GetIntParam('moved_to_id')
+ self.moved = self.moved_to_project and self.moved_to_id
+
+ # Used to show message confirming item was copied and the location of the
+ # new item.
+ self.copied_from_id = mr.GetIntParam('copied_from_id')
+ self.copied_to_project = mr.GetParam('copied_to_project')
+ self.copied_to_id = mr.GetIntParam('copied_to_id')
+ self.copied = self.copied_to_project and self.copied_to_id
+
+ # Used to show message confirming items deleted
+ self.deleted = mr.GetParam('deleted')
+
+ # If present, we will show message confirming that data was saved
+ self.saved = mr.GetParam('saved')
+
+ link_generation_timestamp = mr.GetIntParam('ts', default_value=0)
+ now = int(time.time())
+ ts_links_are_valid = now - link_generation_timestamp < _LINK_EXPIRATION_SEC
+
+ show_alert = ts_links_are_valid and (
+ self.updated or self.moved or self.copied or self.deleted or self.saved)
+ self.show = ezt.boolean(show_alert)
« 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