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
This commit is contained in:
Henrik Levkowetz 2012-07-03 21:35:51 +00:00
parent 6a58f8ec20
commit 26705dee99
4 changed files with 46 additions and 55 deletions

View file

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

View file

@ -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" %}
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_edit_position name=doc.draft_name %}">Edit position</a></span></span></div>
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url idrfc.views_ballot.edit_position name=doc.name,ballot_id=ballot.pk %}">Edit position</a></span></span></div>
{% endif %}
{% if ballot.was_deferred %}
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_undefer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_undefer_ballot name=doc.draft_name %}">Undefer ballot</a></span></span></div>
<div style="margin-top:8px; margin-bottom:8px;">Ballot deferred by {{ ballot.deferred_by }} on {{ ballot.deferred_date }}.</div>
{% if bw.was_deferred %}
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_undefer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_undefer_ballot name=doc.name,ballot_id=ballot.pk %}">Undefer ballot</a></span></span></div>
<div style="margin-top:8px; margin-bottom:8px;">Ballot deferred by {{ bw.deferred_by }} on {{ bw.deferred_date }}.</div>
{% else %}
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_defer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_defer_ballot name=doc.draft_name %}">Defer ballot</a></span></span></div>
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_defer_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_defer_ballot name=doc.name,ballot_id=ballot.pk %}">Defer ballot</a></span></span></div>
{% endif %}
{% endif %}
{% if doc_ballot_edit_button and user|in_group:"Secretariat" %}
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_clear_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_clear_ballot name=doc.draft_name %}">Clear ballot</a></span></span></div>
<div style="margin-top:8px; margin-bottom:8px;"><span id="doc_clear_ballot_button" class="yui-button yui-link-button"><span class="first-child"><a href="{% url doc_clear_ballot name=doc.name,ballot_id=ballot.pk %}">Clear ballot</a></span></span></div>
{% endif %}
<p style="margin-top:1em;"><span class="square" style="background:#c00000;"></span><b>Discuss</b><br/>
{% with ballot.get_discuss as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_discuss as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
<p><span class="square" style="background:#80ff80;"></span><b>Yes</b><br/>
{% with ballot.get_yes as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_yes as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
<p><span class="square" style="background:#80ff80;"></span><b>No Objection</b><br/>
{% with ballot.get_no_objection as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_no_objection as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
<p><span class="square" style="background:#ffff00;"></span><b>Abstain</b><br/>
{% with ballot.get_abstain as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_abstain as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
<p><span class="square" style="background:#c0c0c0;"></span><b>Recuse</b><br/>
{% with ballot.get_recuse as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_recuse as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
<p><span class="square" style="background:white;"></span><b>No Record</b><br/>
{% with ballot.get_no_record as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
{% with bw.get_no_record as positions %}{% include "idrfc/doc_ballot_list.html" %}{% endwith %}</p>
</td>
<td class="right">
<h2 style="margin-top:12px;">Discusses and other comments</h2>
{% if ballot.is_ballot_set %}<p>Other documents in this ballot set: {% for x in ballot.ballot_set_other%}{{x|urlize_ietf_docs}}{% if not forloop.last %}, {% endif %}{% endfor %}</p>{% endif %}
{% if bw.is_ballot_set %}<p>Other documents in this ballot set: {% for x in bw.ballot_set_other%}{{x|urlize_ietf_docs}}{% if not forloop.last %}, {% endif %}{% endfor %}</p>{% endif %}
{% if doc.in_ietf_process and doc.ietf_process.has_active_iesg_ballot %}
<p>Summary: <i>{{ doc.ietf_process.iesg_ballot_needed }}</i></p>
{% if dw.in_ietf_process and dw.ietf_process.has_active_iesg_ballot %}
<p>Summary: <i>{{ dw.ietf_process.iesg_ballot_needed }}</i></p>
{% endif %}
{% for pos in ballot.get_texts|dictsort:"is_old_ad" %}
{% for pos in bw.get_texts|dictsort:"is_old_ad" %}
<h2 class="ballot_ad"><a name="{{pos.ad_name|slugify}}">{% if pos.is_old_ad %}[{%endif%}{{pos.ad_name|escape}}{% if pos.is_old_ad %}]{%endif%}</a></h2>
{% ifequal pos.position "Discuss" %}

View file

@ -1,6 +1,6 @@
{% load ietf_filters %}
{% for p in positions %}
{% if p.is_old_ad %}[{%endif%}<a{% if user|in_group:"Secretariat" %} href="{% url doc_edit_position name=doc.draft_name %}?ad={{ p.ad_username }}" title="Click to edit the position of {{ p.ad_name }}"{% endif %}>{{p.ad_name}}</a>{% if p.is_old_ad %}]{%endif%}{% if p.has_text %}&nbsp;<a href="#{{p.ad_name|slugify}}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}<br/>
{% if p.is_old_ad %}[{%endif%}<a{% if user|in_group:"Secretariat" %} href="{% url idrfc.views_ballot.edit_position name=doc.name,ballot_id=ballot.pk %}?ad={{ p.ad_username }}" title="Click to edit the position of {{ p.ad_name }}"{% endif %}>{{p.ad_name}}</a>{% if p.is_old_ad %}]{%endif%}{% if p.has_text %}&nbsp;<a href="#{{p.ad_name|slugify}}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}<br/>
{% if p.old_positions %}<span class="was">(was {{p.old_positions|join:", "}})</span><br/>{%endif%}
{% empty %}
<i>none</i>

View file

@ -4,7 +4,7 @@
{% if editable and user|has_role:"Area Director,Secretariat" %}
<div class="ballot-actions">
{% if user|has_role:"Area Director" %}
<div class="action"><a href="{% url doc_edit_position name=doc.name,ballot_id=ballot.pk %}">Edit position</a></div>
<div class="action"><a href="{% url idrfc.views_ballot.edit_position name=doc.name,ballot_id=ballot.pk %}">Edit position</a></div>
{% endif %}
{% if doc.type_id == "draft" %}
@ -25,7 +25,7 @@
<div class="position-group">
<div class="heading"><span class="square position-{{ n.slug }}"></span> {{ n.name }}</div>
{% for p in positions %}
<div>{% if p.old_ad %}[{% endif %}<a{% if user|has_role:"Secretariat" %} href="{% url doc_edit_position name=doc.name,ballot_id=ballot.pk %}?ad={{ p.ad.pk }}" title="Click to edit the position of {{ p.ad.plain_name }}"{% endif %}>{{ p.ad.plain_name }}</a>{% if p.old_ad %}]{% endif %}{% if p.comment_text or p.discuss_text %}&nbsp;<a href="#{{ p.ad.plain_name|slugify }}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}</div>
<div>{% if p.old_ad %}[{% endif %}<a{% if user|has_role:"Secretariat" %} href="{% url idrfc.views_ballot.edit_position name=doc.name,ballot_id=ballot.pk %}?ad={{ p.ad.pk }}" title="Click to edit the position of {{ p.ad.plain_name }}"{% endif %}>{{ p.ad.plain_name }}</a>{% if p.old_ad %}]{% endif %}{% if p.comment_text or p.discuss_text %}&nbsp;<a href="#{{ p.ad.plain_name|slugify }}"><img src="/images/comment.png" width="14" height="12" alt="*" border="0"/></a>{% endif %}</div>
{% if p.old_positions %}<div class="was">(was {{ p.old_positions|join:", " }})</div>{% endif %}
{% empty %}
<i>none</i>