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

Unified Diff: appengine/monorail/features/filterrules_views.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/features/filterrules_helpers.py ('k') | appengine/monorail/features/inboundemail.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/features/filterrules_views.py
diff --git a/appengine/monorail/features/filterrules_views.py b/appengine/monorail/features/filterrules_views.py
new file mode 100644
index 0000000000000000000000000000000000000000..ca21b2dc57fb9bc52d56eee4b6a16487f6c83c5f
--- /dev/null
+++ b/appengine/monorail/features/filterrules_views.py
@@ -0,0 +1,44 @@
+# 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 to display filter rules in templates."""
+
+import logging
+
+from framework import template_helpers
+
+
+class RuleView(template_helpers.PBProxy):
+ """Wrapper class that makes it easier to display a Rule via EZT."""
+
+ def __init__(self, rule_pb, users_by_id):
+ super(RuleView, self).__init__(rule_pb)
+
+ self.action_type = ''
+ self.action_value = ''
+
+ if rule_pb is None:
+ return # Just leave everything as ''
+
+ # self.predicate is automatically available.
+
+ # For the current UI, we assume that each rule has exactly
+ # one action, so we can determine the text value for it here.
+ if rule_pb.default_status:
+ self.action_type = 'default_status'
+ self.action_value = rule_pb.default_status
+ elif rule_pb.default_owner_id:
+ self.action_type = 'default_owner'
+ self.action_value = users_by_id[rule_pb.default_owner_id].email
+ elif rule_pb.add_cc_ids:
+ self.action_type = 'add_ccs'
+ usernames = [users_by_id[cc_id].email for cc_id in rule_pb.add_cc_ids]
+ self.action_value = ', '.join(usernames)
+ elif rule_pb.add_labels:
+ self.action_type = 'add_labels'
+ self.action_value = ', '.join(rule_pb.add_labels)
+ elif rule_pb.add_notify_addrs:
+ self.action_type = 'also_notify'
+ self.action_value = ', '.join(rule_pb.add_notify_addrs)
« no previous file with comments | « appengine/monorail/features/filterrules_helpers.py ('k') | appengine/monorail/features/inboundemail.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698