Show approved milestones on /doc/charter-xyz/ page if the charter is
approved instead of only showing proposed milestones for proposed charters - Legacy-Id: 5794
This commit is contained in:
parent
bf81451a6c
commit
a603b8e056
ietf
|
@ -55,6 +55,7 @@ from ietf.doc.utils import *
|
|||
from ietf.utils.history import find_history_active_at
|
||||
from ietf.ietfauth.decorators import has_role
|
||||
from ietf.doc.views_status_change import RELATION_SLUGS as status_change_relationships
|
||||
from ietf.wgcharter.utils import historic_milestones_for_charter
|
||||
|
||||
def render_document_top(request, doc, tab, name):
|
||||
tabs = []
|
||||
|
@ -92,7 +93,7 @@ def document_main(request, name, rev=None):
|
|||
raise Http404()
|
||||
return document_main_idrfc(request, name, tab="document")
|
||||
|
||||
doc = get_object_or_404(Document, docalias__name=name)
|
||||
orig_doc = doc = get_object_or_404(Document, docalias__name=name)
|
||||
group = doc.group
|
||||
if doc.type_id == 'conflrev':
|
||||
conflictdoc = doc.relateddocument_set.get(relationship__slug='conflrev').target.document
|
||||
|
@ -153,9 +154,7 @@ def document_main(request, name, rev=None):
|
|||
chartering = get_chartering_type(doc)
|
||||
|
||||
# inject milestones from group
|
||||
milestones = None
|
||||
if chartering and not snapshot:
|
||||
milestones = doc.group.groupmilestone_set.filter(state="charter")
|
||||
milestones = historic_milestones_for_charter(orig_doc, doc.rev)
|
||||
|
||||
return render_to_response("idrfc/document_charter.html",
|
||||
dict(doc=doc,
|
||||
|
|
|
@ -139,9 +139,8 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not snapshot and chartering %}
|
||||
<h3>Proposed Milestones
|
||||
{% if user|has_role:"Area Director,Secretariat" %}
|
||||
<h3>{% if chartering %}Proposed{% endif %} Milestones
|
||||
{% if not snapshot and user|has_role:"Area Director,Secretariat" %}
|
||||
<a class="edit" href="{% url wg_edit_charter_milestones acronym=doc.group.acronym %}">Edit charter milestones</a>
|
||||
{% endif %}
|
||||
</h3>
|
||||
|
@ -151,7 +150,6 @@
|
|||
{% else %}
|
||||
<p>No milestones for charter found.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ import re, datetime, os
|
|||
from django.conf import settings
|
||||
|
||||
from ietf.group.models import GroupEvent, ChangeStateGroupEvent
|
||||
from ietf.doc.models import Document, DocAlias, DocHistory, RelatedDocument, DocumentAuthor, DocEvent
|
||||
from ietf.doc.models import Document, DocAlias, DocHistory, RelatedDocument, DocumentAuthor, DocEvent, NewRevisionDocEvent
|
||||
from ietf.utils.history import find_history_active_at
|
||||
|
||||
def log_state_changed(request, doc, by, prev_state):
|
||||
e = DocEvent(doc=doc, by=by)
|
||||
|
@ -43,6 +44,44 @@ def read_charter_text(doc):
|
|||
except IOError:
|
||||
return "Error: couldn't read charter text"
|
||||
|
||||
def historic_milestones_for_charter(charter, rev):
|
||||
"""Return GroupMilestone/GroupMilestoneHistory objects for charter
|
||||
document at rev by looking through the history."""
|
||||
|
||||
chartering = "-" in rev
|
||||
if chartering:
|
||||
need_state = "charter"
|
||||
else:
|
||||
need_state = "active"
|
||||
|
||||
# slight complication - we can assign milestones to a revision up
|
||||
# until the point where the next superseding revision is
|
||||
# published, so that time shall be our limit
|
||||
revision_event = charter.latest_event(NewRevisionDocEvent, type="new_revision", rev=rev)
|
||||
if not revision_event:
|
||||
return []
|
||||
|
||||
e = charter.docevent_set.filter(time__gt=revision_event.time, type="new_revision").order_by("time")
|
||||
if not chartering:
|
||||
e = e.exclude(newrevisiondocevent__rev__contains="-")
|
||||
|
||||
if e:
|
||||
# subtract a margen of error to avoid collisions with
|
||||
# milestones being published at the same time as the new
|
||||
# revision (when approving a charter)
|
||||
just_before_next_rev = e[0].time - datetime.timedelta(seconds=5)
|
||||
else:
|
||||
just_before_next_rev = datetime.datetime.now()
|
||||
|
||||
res = []
|
||||
for m in charter.chartered_group.groupmilestone_set.all():
|
||||
mh = find_history_active_at(m, just_before_next_rev)
|
||||
if mh and mh.state_id == need_state:
|
||||
res.append(mh)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def update_telechat(request, doc, by, new_telechat_date):
|
||||
# FIXME: reuse function in idrfc/utils.py instead of this one
|
||||
# (need to fix auto-setting returning item problem first though)
|
||||
|
|
|
@ -716,35 +716,12 @@ def charter_with_milestones_txt(request, name, rev):
|
|||
charter_text = "Error reading charter text %s" % filename
|
||||
|
||||
|
||||
# find milestones
|
||||
|
||||
chartering = "-" in rev
|
||||
if chartering:
|
||||
need_state = "charter"
|
||||
else:
|
||||
need_state = "active"
|
||||
|
||||
# slight complication - we can assign milestones to a revision up
|
||||
# until the point where the next superseding revision is
|
||||
# published, so that time shall be our limit
|
||||
e = charter.docevent_set.filter(time__gt=revision_event.time, type="new_revision").order_by("time")
|
||||
if not chartering:
|
||||
e = e.exclude(newrevisiondocevent__rev__contains="-")
|
||||
|
||||
if e:
|
||||
# subtract a margen of error
|
||||
just_before_next_rev = e[0].time - datetime.timedelta(seconds=5)
|
||||
else:
|
||||
just_before_next_rev = datetime.datetime.now()
|
||||
milestones = historic_milestones_for_charter(charter, rev)
|
||||
|
||||
# wrap the output nicely
|
||||
wrapper = textwrap.TextWrapper(initial_indent="", subsequent_indent=" " * 11, width=80, break_long_words=False)
|
||||
|
||||
milestones = []
|
||||
for m in charter.chartered_group.groupmilestone_set.all():
|
||||
mh = find_history_active_at(m, just_before_next_rev)
|
||||
if mh and mh.state_id == need_state:
|
||||
mh.desc_filled = wrapper.fill(mh.desc)
|
||||
milestones.append(mh)
|
||||
for m in milestones:
|
||||
m.desc_filled = wrapper.fill(m.desc)
|
||||
|
||||
return render_to_response('wgcharter/charter_with_milestones.txt',
|
||||
dict(charter_text=charter_text,
|
||||
|
|
Loading…
Reference in a new issue