From 26705dee99fd3412b60aa20a9de85aa7971bd7ad Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz
Date: Tue, 3 Jul 2012 21:35:51 +0000
Subject: [PATCH] When logged in as secretariat, at /iesg/agenda/ or
/iesg/agenda/documents/, and clicking on the position matrix for a document,
the overlay window would give a code 500 error, because of a missing ballot
id in the templates' url lookup. Fix this by providing the ballot id. -
Legacy-Id: 4576
---
ietf/idrfc/views_doc.py | 63 ++++++++-----------
ietf/templates/idrfc/doc_ballot.html | 32 +++++-----
ietf/templates/idrfc/doc_ballot_list.html | 2 +-
.../idrfc/document_ballot_content.html | 4 +-
4 files changed, 46 insertions(+), 55 deletions(-)
diff --git a/ietf/idrfc/views_doc.py b/ietf/idrfc/views_doc.py
index f9ee5e0e2..75389f89d 100644
--- a/ietf/idrfc/views_doc.py
+++ b/ietf/idrfc/views_doc.py
@@ -544,55 +544,46 @@ def _get_versions(draft, include_replaced=True):
return ov
def get_ballot(name):
- r = re.compile("^rfc([1-9][0-9]*)$")
- m = r.match(name)
-
- if settings.USE_DB_REDESIGN_PROXY_CLASSES:
- from ietf.doc.models import DocAlias
- alias = get_object_or_404(DocAlias, name=name)
- d = get_object_or_404(InternetDraft, name=alias.document.name)
- try:
- if not d.ballot.ballot_issued:
- raise Http404
- except BallotInfo.DoesNotExist:
- raise Http404
-
- bw = BallotWrapper(d)
- if m:
- d.viewing_as_rfc = True
- dw = RfcWrapper(d)
- else:
- dw = IdWrapper(d)
-
- return (bw, dw)
-
- if m:
- rfc_number = int(m.group(1))
- rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
- id = get_object_or_404(IDInternal, rfc_flag=1, draft=rfc_number)
- doc = RfcWrapper(rfci, idinternal=id)
- else:
- id = get_object_or_404(IDInternal, rfc_flag=0, draft__filename=name)
- doc = IdWrapper(id)
+ from ietf.doc.models import DocAlias
+ alias = get_object_or_404(DocAlias, name=name)
+ d = alias.document
+ id = get_object_or_404(InternetDraft, name=d.name)
try:
if not id.ballot.ballot_issued:
raise Http404
except BallotInfo.DoesNotExist:
raise Http404
- ballot = BallotWrapper(id)
- return ballot, doc
+ try:
+ b = d.latest_event(BallotDocEvent, type="created_ballot")
+ except BallotDocEvent.DoesNotExist:
+ raise Http404
+
+ bw = BallotWrapper(id) # XXX Fixme: Eliminate this as we go forward
+
+ # Python caches ~100 regex'es -- explicitly compiling it inside a method
+ # (where you then throw away the compiled version!) doesn't make sense at
+ # all.
+ if re.search("^rfc([1-9][0-9]*)$", name):
+ id.viewing_as_rfc = True
+ dw = RfcWrapper(id)
+ else:
+ dw = IdWrapper(id)
+ # XXX Fixme: Eliminate 'dw' as we go forward
+
+
+ return (bw, dw, b, d)
def ballot_html(request, name):
- ballot, doc = get_ballot(name)
- return render_to_response('idrfc/doc_ballot.html', {'ballot':ballot, 'doc':doc}, context_instance=RequestContext(request))
+ bw, dw, ballot, doc = get_ballot(name)
+ return render_to_response('idrfc/doc_ballot.html', {'bw':bw, 'dw':dw, 'ballot':ballot, 'doc':doc}, context_instance=RequestContext(request))
def ballot_tsv(request, name):
- ballot, doc = get_ballot(name)
+ ballot, doc, b, d = get_ballot(name)
return HttpResponse(render_to_string('idrfc/ballot.tsv', {'ballot':ballot}, RequestContext(request)), content_type="text/plain")
def ballot_json(request, name):
- ballot, doc = get_ballot(name)
+ ballot, doc, b, d = get_ballot(name)
response = HttpResponse(mimetype='text/plain')
response.write(json.dumps(ballot.dict(), indent=2))
return response
diff --git a/ietf/templates/idrfc/doc_ballot.html b/ietf/templates/idrfc/doc_ballot.html
index 9a985088f..225afcd0c 100644
--- a/ietf/templates/idrfc/doc_ballot.html
+++ b/ietf/templates/idrfc/doc_ballot.html
@@ -36,52 +36,52 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% if doc_ballot_edit_button and user|in_group:"Area_Director,Secretariat" %}
{% if user|in_group:"Area_Director" %}
-
+
{% endif %}
-{% if ballot.was_deferred %}
-
-Ballot deferred by {{ ballot.deferred_by }} on {{ ballot.deferred_date }}.
+{% if bw.was_deferred %}
+
+Ballot deferred by {{ bw.deferred_by }} on {{ bw.deferred_date }}.
{% else %}
-
+
{% endif %}
{% endif %}
{% if doc_ballot_edit_button and user|in_group:"Secretariat" %}
-
+
{% endif %}
Discuss
-{% with ballot.get_discuss as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_discuss as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
Yes
-{% with ballot.get_yes as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_yes as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
No Objection
-{% with ballot.get_no_objection as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_no_objection as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
Abstain
-{% with ballot.get_abstain as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_abstain as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
Recuse
-{% with ballot.get_recuse as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_recuse as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
No Record
-{% with ballot.get_no_record as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
+{% with bw.get_no_record as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}
Discusses and other comments
-{% if ballot.is_ballot_set %}Other documents in this ballot set: {% for x in ballot.ballot_set_other%}{{x|urlize_ietf_docs}}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}
+{% if bw.is_ballot_set %}Other documents in this ballot set: {% for x in bw.ballot_set_other%}{{x|urlize_ietf_docs}}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}
-{% if doc.in_ietf_process and doc.ietf_process.has_active_iesg_ballot %}
-Summary: {{ doc.ietf_process.iesg_ballot_needed }}
+{% if dw.in_ietf_process and dw.ietf_process.has_active_iesg_ballot %}
+Summary: {{ dw.ietf_process.iesg_ballot_needed }}
{% endif %}
-{% for pos in ballot.get_texts|dictsort:"is_old_ad" %}
+{% for pos in bw.get_texts|dictsort:"is_old_ad" %}
{% ifequal pos.position "Discuss" %}
diff --git a/ietf/templates/idrfc/doc_ballot_list.html b/ietf/templates/idrfc/doc_ballot_list.html
index 49534b98d..5e2c1f342 100644
--- a/ietf/templates/idrfc/doc_ballot_list.html
+++ b/ietf/templates/idrfc/doc_ballot_list.html
@@ -1,6 +1,6 @@
{% load ietf_filters %}
{% for p in positions %}
-{% if p.is_old_ad %}[{%endif%}{{p.ad_name}}{% if p.is_old_ad %}]{%endif%}{% if p.has_text %} {% endif %}
+{% if p.is_old_ad %}[{%endif%}{{p.ad_name}}{% if p.is_old_ad %}]{%endif%}{% if p.has_text %} {% endif %}
{% if p.old_positions %}(was {{p.old_positions|join:", "}}) {%endif%}
{% empty %}
none
diff --git a/ietf/templates/idrfc/document_ballot_content.html b/ietf/templates/idrfc/document_ballot_content.html
index d30d6ef3a..7660f59e5 100644
--- a/ietf/templates/idrfc/document_ballot_content.html
+++ b/ietf/templates/idrfc/document_ballot_content.html
@@ -4,7 +4,7 @@
{% if editable and user|has_role:"Area Director,Secretariat" %}
{% if user|has_role:"Area Director" %}
-
+
{% endif %}
{% if doc.type_id == "draft" %}
@@ -25,7 +25,7 @@
{{ n.name }}
{% for p in positions %}
- {% if p.old_ad %}[{% endif %} {{ p.ad.plain_name }}{% if p.old_ad %}]{% endif %}{% if p.comment_text or p.discuss_text %}  {% endif %}
+ {% if p.old_ad %}[{% endif %} {{ p.ad.plain_name }}{% if p.old_ad %}]{% endif %}{% if p.comment_text or p.discuss_text %}  {% endif %}
{% if p.old_positions %} (was {{ p.old_positions|join:", " }}) {% endif %}
{% empty %}
none
|