Fix ballot_icon templatetag bugs so it can handle other document types

too.
 - Legacy-Id: 4284
This commit is contained in:
Ole Laursen 2012-04-17 16:22:30 +00:00
parent 9fe98c88e5
commit 7932a75363

View file

@ -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: