From 7932a75363fa40379c03aeaad4cbf884455866f1 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Tue, 17 Apr 2012 16:22:30 +0000 Subject: [PATCH] Fix ballot_icon templatetag bugs so it can handle other document types too. - Legacy-Id: 4284 --- ietf/idrfc/templatetags/ballot_icon.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ietf/idrfc/templatetags/ballot_icon.py b/ietf/idrfc/templatetags/ballot_icon.py index 6182d5529..bdbf752dc 100644 --- a/ietf/idrfc/templatetags/ballot_icon.py +++ b/ietf/idrfc/templatetags/ballot_icon.py @@ -60,9 +60,13 @@ def render_ballot_icon(user, doc): if not doc: return "" - s = doc.get_state("draft-iesg") - if s and s.name not in BALLOT_ACTIVE_STATES: - return "" + if doc.type_id == "draft": + s = doc.get_state("draft-iesg") + if s and s.name not in BALLOT_ACTIVE_STATES: + return "" + elif doc.type_id == "charter": + if doc.get_state_slug() not in ("intrev", "iesgrev"): + return "" ballot = doc.latest_event(BallotDocEvent, type="created_ballot") if not ballot: @@ -112,7 +116,10 @@ class BallotIconNode(template.Node): self.doc_var = doc_var def render(self, context): doc = template.resolve_variable(self.doc_var, context) - return render_ballot_icon(context.get("user"), doc._idinternal) + if hasattr(doc, "_idinternal"): + # hack for old schema + doc = doc._idinternal + return render_ballot_icon(context.get("user"), doc) def do_ballot_icon(parser, token): try: