Clean up and polish charter branch code, fix some subtle bugs with
revision and approved charter lookup. - Legacy-Id: 4290
This commit is contained in:
parent
a72b933bfc
commit
b9a90f35e1
|
@ -196,7 +196,7 @@ class DocHistoryAuthor(models.Model):
|
|||
|
||||
class DocHistory(DocumentInfo):
|
||||
doc = models.ForeignKey(Document, related_name="history_set")
|
||||
name = models.CharField(max_length=255) # WG charter names can change if the group acronym changes
|
||||
name = models.CharField(max_length=255) # WG charter canonical names can change if the group acronym changes
|
||||
related = models.ManyToManyField('DocAlias', through=RelatedDocHistory, blank=True)
|
||||
authors = models.ManyToManyField(Email, through=DocHistoryAuthor, blank=True)
|
||||
def __unicode__(self):
|
||||
|
|
|
@ -54,10 +54,10 @@ def needed_ballot_positions(doc, active_positions):
|
|||
'''Returns text answering the question "what does this document
|
||||
need to pass?". The return value is only useful if the document
|
||||
is currently in IESG evaluation.'''
|
||||
yes = [p for p in active_positions if p.pos_id == "yes"]
|
||||
noobj = [p for p in active_positions if p.pos_id == "noobj"]
|
||||
blocking = [p for p in active_positions if p.pos.blocking]
|
||||
recuse = [p for p in active_positions if p.pos_id == "recuse"]
|
||||
yes = [p for p in active_positions if p and p.pos_id == "yes"]
|
||||
noobj = [p for p in active_positions if p and p.pos_id == "noobj"]
|
||||
blocking = [p for p in active_positions if p and p.pos.blocking]
|
||||
recuse = [p for p in active_positions if p and p.pos_id == "recuse"]
|
||||
|
||||
answer = []
|
||||
if yes < 1:
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from ietf.utils.proxy import TranslatingManager, proxy_role_email
|
||||
|
||||
from models import *
|
||||
from ietf.doc.models import Document # for charter text
|
||||
from ietf.wgcharter.utils import get_charter_for_revision, approved_revision
|
||||
|
||||
class Acronym(Group):
|
||||
class LazyIndividualSubmitter(object):
|
||||
|
@ -203,15 +201,19 @@ class IETFWG(Group):
|
|||
# get file path from settings. Syntesize file name from path, acronym, and suffix
|
||||
try:
|
||||
# Try getting charter from new charter tool
|
||||
charter = Document.objects.get(docalias__name="charter-ietf-%s" % self.acronym)
|
||||
ch = get_charter_for_revision(charter, charter.rev)
|
||||
name = ch.name
|
||||
rev = approved_revision(ch.rev)
|
||||
filename = os.path.join(charter.get_file_path(), "%s-%s.txt" % (name, rev))
|
||||
desc_file = open(filename)
|
||||
desc = desc_file.read()
|
||||
return desc
|
||||
except:
|
||||
c = self.charter
|
||||
|
||||
# find the latest, preferably approved, revision
|
||||
for h in self.charter.history_set.exclude(rev="").order_by("time"):
|
||||
h_appr = "-" not in h.rev
|
||||
c_appr = "-" not in c.rev
|
||||
if (h.rev > c.rev and not (c_appr and not h_appr)) or (h_appr and not c_appr):
|
||||
c = h
|
||||
|
||||
filename = os.path.join(c.get_file_path(), "%s-%s.txt" % (c.canonical_name(), c.rev))
|
||||
with open(filename) as f:
|
||||
return f.read()
|
||||
except IOError:
|
||||
try:
|
||||
filename = os.path.join(settings.IETFWG_DESCRIPTIONS_PATH, self.acronym) + ".desc.txt"
|
||||
desc_file = open(filename)
|
||||
|
|
|
@ -50,7 +50,7 @@ from ietf.idrfc.models import RfcIndex, DraftVersions
|
|||
from ietf.idrfc.idrfc_wrapper import BallotWrapper, IdWrapper, RfcWrapper
|
||||
from ietf.ietfworkflows.utils import get_full_info_for_draft
|
||||
from ietf.doc.models import *
|
||||
from ietf.doc.utils import get_chartering_type, needed_ballot_positions
|
||||
from ietf.doc.utils import get_chartering_type, needed_ballot_positions, active_ballot_positions
|
||||
from ietf.utils.history import find_history_active_at
|
||||
from ietf.ietfauth.decorators import has_role
|
||||
|
||||
|
@ -90,10 +90,11 @@ def document_main(request, name, rev=None):
|
|||
return document_main_idrfc(request, name, tab="document")
|
||||
|
||||
doc = get_object_or_404(Document, docalias__name=name)
|
||||
group = doc.group
|
||||
|
||||
revisions = [ doc.rev ]
|
||||
for h in doc.history_set.order_by("-time"):
|
||||
if not h.rev in revisions:
|
||||
if h.rev and not h.rev in revisions:
|
||||
revisions.append(h.rev)
|
||||
|
||||
snapshot = False
|
||||
|
@ -115,17 +116,23 @@ def document_main(request, name, rev=None):
|
|||
# find old group, too
|
||||
gh = find_history_active_at(doc.group, doc.time)
|
||||
if gh:
|
||||
doc.group = gh
|
||||
group = gh
|
||||
|
||||
top = render_document_top(request, doc, "document")
|
||||
|
||||
|
||||
telechat = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat")
|
||||
if telechat and telechat.telechat_date < datetime.date.today():
|
||||
telechat = None
|
||||
|
||||
if doc.type_id == "charter":
|
||||
filename = "%s-%s.txt" % (doc.canonical_name(), doc.rev)
|
||||
|
||||
content = _get_html(filename, os.path.join(settings.CHARTER_PATH, filename), split=False)
|
||||
|
||||
telechat = doc.latest_event(TelechatDocEvent, type="scheduled_for_telechat")
|
||||
ballot_summary = None
|
||||
if doc.get_state_slug() in ("intrev", "iesgrev"):
|
||||
ballot_summary = needed_ballot_positions(doc, active_ballot_positions(doc).values())
|
||||
|
||||
return render_to_response("idrfc/document_charter.html",
|
||||
dict(doc=doc,
|
||||
|
@ -136,6 +143,8 @@ def document_main(request, name, rev=None):
|
|||
revisions=revisions,
|
||||
snapshot=snapshot,
|
||||
telechat=telechat,
|
||||
ballot_summary=ballot_summary,
|
||||
group=group,
|
||||
),
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -24,55 +24,67 @@
|
|||
<div>
|
||||
{% if snapshot %}Snapshot of{% endif %}
|
||||
{% if doc.get_state_slug != "approved" %}Proposed{% endif %}
|
||||
Charter for {{ doc.group.name }}
|
||||
(<a href="{% url wginfo.views.wg_charter acronym=doc.group.acronym %}">{{ doc.group.acronym }} {{ doc.group.type.name }}</a>)
|
||||
Charter for {{ group.name }}
|
||||
(<a href="{% url wginfo.views.wg_charter acronym=group.acronym %}">{{ group.acronym }} {{ group.type.name }}</a>)
|
||||
</div>
|
||||
|
||||
<table id="metatable" width="100%">
|
||||
<tr>
|
||||
<td>WG State:</td>
|
||||
<td>{{ doc.group.state.name }}</td>
|
||||
<td>{{ group.state.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/wgcharter/help/state/">Charter State</a>:</td>
|
||||
<td>
|
||||
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
|
||||
{% if chartering == "initial" %}(Initial Chartering){% endif %}
|
||||
{% if chartering == "rechartering" %}(Rechartering){% endif %}
|
||||
<div>
|
||||
<a title="{{ doc.get_state.desc }}"{% if not snapshot and user|has_role:"Area Director,Secretariat" %} href="{% url charter_change_state name=doc.name %}"{% endif %}>{{ doc.get_state.name }}</a>
|
||||
{% if chartering == "initial" %}(Initial Chartering){% endif %}
|
||||
{% if chartering == "rechartering" %}(Rechartering){% endif %}
|
||||
|
||||
{% if not snapshot and user|has_role:"Area Director,Secretariat" %}
|
||||
- <a href="{% url wg_change_state name=doc.name %}">Change state</a>
|
||||
{% if not snapshot and user|has_role:"Area Director,Secretariat" %}
|
||||
|
||||
{% if chartering %}
|
||||
- <a href="{% url wg_startstop_process name=doc.name option='abandon' %}">Abandon effort</a>
|
||||
{% else %}
|
||||
- <a href="{% url wg_startstop_process name=doc.name option='recharter' %}">Recharter</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if chartering %}
|
||||
- <a href="{% url charter_startstop_process name=doc.name option='abandon' %}">Abandon effort</a>
|
||||
|
||||
{% if chartering and doc.group.comments %}
|
||||
<tr>
|
||||
{% if chartering == "initial" %}<td>Reason for chartering:</td>{% endif %}
|
||||
{% if chartering == "rechartering" %}<td>Reason for rechartering:</td>{% endif %}
|
||||
<td>{{ doc.group.comments }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if request.user|has_role:"Secretariat" %}
|
||||
- <a href="{% url charter_approve name=doc.name %}">Approve charter</a>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
- <a href="{% url charter_startstop_process name=doc.name option='recharter' %}">Recharter</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if not snapshot and chartering %}
|
||||
<div class="telechat">
|
||||
{% if not telechat %}Not on agenda of IESG telechat{% else %}On agenda of {{ telechat.telechat_date|date:"Y-m-d" }} IESG telechat{% endif %}
|
||||
{% if user|has_role:"Area Director,Secretariat" %}
|
||||
- <a href="{% url charter_telechat_date name=doc.name %}">Change</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if ballot_summary %}
|
||||
<div class="ballot-summary">
|
||||
({{ ballot_summary }})
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not snapshot %}
|
||||
<tr>
|
||||
<td>IESG telechat:</td>
|
||||
<td>
|
||||
{% if not telechat %}Not on agenda{% else %}{{ telechat.telechat_date|date:"Y-m-d" }}{% endif %}
|
||||
{% if user|has_role:"Area Director,Secretariat" %}
|
||||
- <a href="{% url charter_telechat_date name=doc.name %}">Change</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% if chartering and group.comments %}
|
||||
<tr>
|
||||
{% if chartering == "initial" %}<td>Reason for chartering:</td>{% endif %}
|
||||
{% if chartering == "rechartering" %}<td>Reason for rechartering:</td>{% endif %}
|
||||
<td>{{ group.comments }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<tr><td colspan='2'><hr size='1' noshade /></td></tr>
|
||||
|
||||
<tr><td>Last updated:</td><td> {{ doc.time|date:"Y-m-d" }}</td></tr>
|
||||
|
@ -81,7 +93,7 @@
|
|||
</table>
|
||||
|
||||
<div class="actions">
|
||||
<a href="/feed/wgchanges/{{ doc.group.acronym }}/">Atom feed</a>
|
||||
<a href="/feed/wgchanges/{{ group.acronym }}/">Atom feed</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -94,8 +106,8 @@
|
|||
No text for {{ doc.name }} submitted yet
|
||||
{% endif %}
|
||||
|
||||
{% if user|has_role:"Area Director,Secretariat" and chartering and doc.group.state_id != "conclude" %}
|
||||
<a class="edit" href="{% url wg_submit name=doc.name %}">Change charter text</a>
|
||||
{% if user|has_role:"Area Director,Secretariat" and chartering and group.state_id != "conclude" %}
|
||||
<a class="edit" href="{% url charter_submit name=doc.name %}">Change charter text</a>
|
||||
{% endif %}
|
||||
</h3>
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Approve ballot for {{ wg.acronym }}{% endblock %}
|
||||
{% block title %}Approve {{ charter.canonical_name }}{% endblock %}
|
||||
|
||||
{% block morecss %}
|
||||
form.approve-ballot pre {
|
||||
form.approve pre {
|
||||
margin: 0;
|
||||
padding: 4px;
|
||||
border-top: 4px solid #eee;
|
||||
border-bottom: 4px solid #eee;
|
||||
}
|
||||
form.approve-ballot .announcement {
|
||||
form.approve .announcement {
|
||||
overflow-x: auto;
|
||||
overflow-y: scroll;
|
||||
width: 800px;
|
||||
|
@ -19,18 +19,18 @@ form.approve-ballot .announcement {
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Approve Ballot for {{ wg.acronym }}</h1>
|
||||
<h1>Approve {{ charter.canonical_name }}</h1>
|
||||
|
||||
<div>IETF announcement:</div>
|
||||
|
||||
<form class="approve-ballot" action="" method="POST">
|
||||
<form class="approve" action="" method="POST">
|
||||
|
||||
<div class="announcement">
|
||||
<pre>{{ announcement }}</pre>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<a href="{% url doc_ballot name=wg.charter.name %}">Back</a>
|
||||
<a href="{% url doc_view name=charter.name %}">Back</a>
|
||||
<input type="submit" value="Send out the announcement, close ballot and update revision"/>
|
||||
</div>
|
||||
</form>
|
|
@ -38,7 +38,7 @@ class EditCharterTestCase(django.test.TestCase):
|
|||
group = Group.objects.get(acronym="ames")
|
||||
charter = group.charter
|
||||
|
||||
url = urlreverse('wg_change_state', kwargs=dict(name=charter.name))
|
||||
url = urlreverse('charter_change_state', kwargs=dict(name=charter.name))
|
||||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
||||
first_state = charter.get_state()
|
||||
|
@ -121,7 +121,7 @@ class EditCharterTestCase(django.test.TestCase):
|
|||
group = Group.objects.get(acronym="mars")
|
||||
charter = group.charter
|
||||
|
||||
url = urlreverse('wg_submit', kwargs=dict(name=charter.name))
|
||||
url = urlreverse('charter_submit', kwargs=dict(name=charter.name))
|
||||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
||||
# normal get
|
||||
|
@ -153,16 +153,16 @@ class CharterApproveBallotTestCase(django.test.TestCase):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.charter_dir)
|
||||
|
||||
def test_approve_ballot(self):
|
||||
def test_approve(self):
|
||||
make_test_data()
|
||||
|
||||
group = Group.objects.get(acronym="ames")
|
||||
charter = group.charter
|
||||
|
||||
url = urlreverse('wg_approve_ballot', kwargs=dict(name=charter.name))
|
||||
url = urlreverse('charter_approve', kwargs=dict(name=charter.name))
|
||||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
||||
with open(os.path.join(self.charter_dir, "charter-ietf-%s-%s.txt" % (group.acronym, charter.rev)), "w") as f:
|
||||
with open(os.path.join(self.charter_dir, "%s-%s.txt" % (charter.canonical_name(), charter.rev)), "w") as f:
|
||||
f.write("This is a charter.")
|
||||
|
||||
p = Person.objects.get(name="Aread Irector")
|
||||
|
|
|
@ -7,12 +7,12 @@ urlpatterns = patterns('django.views.generic.simple',
|
|||
url(r'^help/state/$', 'direct_to_template', { 'template': 'wgcharter/states.html', 'extra_context': { 'states': State.objects.filter(type="charter") } }, name='help_charter_states'),
|
||||
)
|
||||
urlpatterns += patterns('',
|
||||
url(r'^state/$', "ietf.wgcharter.views.change_state", name='wg_change_state'),
|
||||
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='wg_startstop_process'),
|
||||
url(r'^state/$', "ietf.wgcharter.views.change_state", name='charter_change_state'),
|
||||
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.wgcharter.views.change_state", name='charter_startstop_process'),
|
||||
url(r'^telechat/$', "ietf.wgcharter.views.telechat_date", name='charter_telechat_date'),
|
||||
url(r'^(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text", name='wg_announcement_text'),
|
||||
url(r'^ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes", name='wg_ballot_writeupnotes'),
|
||||
url(r'^approveballot/$', "ietf.wgcharter.views.approve_ballot", name='wg_approve_ballot'),
|
||||
url(r'^submit/$', "ietf.wgcharter.views.submit", name='wg_submit'),
|
||||
url(r'^(?P<ann>action|review)/$', "ietf.wgcharter.views.announcement_text"),
|
||||
url(r'^ballotwriteupnotes/$', "ietf.wgcharter.views.ballot_writeupnotes"),
|
||||
url(r'^approve/$', "ietf.wgcharter.views.approve", name='charter_approve'),
|
||||
url(r'^submit/$', "ietf.wgcharter.views.submit", name='charter_submit'),
|
||||
|
||||
)
|
||||
|
|
|
@ -6,29 +6,6 @@ from ietf.group.models import GroupEvent, ChangeStateGroupEvent
|
|||
from ietf.doc.models import Document, DocAlias, DocHistory, RelatedDocument, DocumentAuthor, DocEvent
|
||||
from ietf.utils.history import find_history_active_at
|
||||
|
||||
def set_or_create_charter(wg):
|
||||
try:
|
||||
charter = Document.objects.get(docalias__name="charter-ietf-%s" % wg.acronym)
|
||||
except Document.DoesNotExist:
|
||||
charter = Document.objects.create(
|
||||
name="charter-ietf-" + wg.acronym,
|
||||
time=datetime.datetime.now(),
|
||||
type_id="charter",
|
||||
title=wg.name,
|
||||
group=wg,
|
||||
abstract=wg.name,
|
||||
rev="",
|
||||
)
|
||||
# Create an alias as well
|
||||
DocAlias.objects.create(
|
||||
name=charter.name,
|
||||
document=charter
|
||||
)
|
||||
if wg.charter != charter:
|
||||
wg.charter = charter
|
||||
wg.save()
|
||||
return charter
|
||||
|
||||
def log_state_changed(request, doc, by, prev_state):
|
||||
e = DocEvent(doc=doc, by=by)
|
||||
e.type = "changed_document"
|
||||
|
@ -41,24 +18,24 @@ def log_state_changed(request, doc, by, prev_state):
|
|||
def get_charter_for_revision(charter, r):
|
||||
if r == None:
|
||||
return None
|
||||
else:
|
||||
l = list(charter.history_set.filter(rev=r).order_by('-time'))
|
||||
if l != []:
|
||||
return l[0]
|
||||
else:
|
||||
# Get the lastest history entry
|
||||
l = list(charter.history_set.all().order_by('-time'))
|
||||
if l != []:
|
||||
class FakeHistory(object):
|
||||
def __init__(self, name, rev, time):
|
||||
self.name = name
|
||||
self.rev = rev
|
||||
self.time = time
|
||||
|
||||
return FakeHistory(l[0].name, charter.rev, charter.time)
|
||||
else:
|
||||
# no history, just return charter
|
||||
return charter
|
||||
l = charter.history_set.filter(rev=r).order_by('-time')
|
||||
if l:
|
||||
return l[0]
|
||||
|
||||
# Get the lastest history entry
|
||||
l = charter.history_set.all().order_by('-time')
|
||||
if not l:
|
||||
# no history, just return charter
|
||||
return charter
|
||||
|
||||
class FakeHistory(object):
|
||||
def __init__(self, name, rev, time):
|
||||
self.name = name
|
||||
self.rev = rev
|
||||
self.time = time
|
||||
|
||||
return FakeHistory(l[0].name, charter.rev, charter.time)
|
||||
|
||||
def get_group_for_revision(wg, r):
|
||||
if r == None:
|
||||
|
@ -111,8 +88,8 @@ def read_charter_text(doc):
|
|||
return "Error: couldn't read charter text"
|
||||
|
||||
def update_telechat(request, doc, by, new_telechat_date):
|
||||
# FIXME: fix auto-setting returning item problem and reuse
|
||||
# function in idrfc/utils.py instead of this one
|
||||
# FIXME: reuse function in idrfc/utils.py instead of this one
|
||||
# (need to fix auto-setting returning item problem first though)
|
||||
from ietf.doc.models import TelechatDocEvent
|
||||
|
||||
on_agenda = bool(new_telechat_date)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import re, os, string, datetime
|
||||
import re, os, string, datetime, shutil
|
||||
|
||||
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
||||
from django.shortcuts import render_to_response, get_object_or_404, redirect
|
||||
|
@ -57,13 +57,15 @@ def change_state(request, name, option=None):
|
|||
clean = form.cleaned_data
|
||||
if option == "initcharter" or option == "recharter":
|
||||
charter_state = State.objects.get(type="charter", slug="infrev")
|
||||
charter_rev = charter.rev
|
||||
charter_rev = ""
|
||||
elif option == "abandon":
|
||||
if wg.state_id == "proposed":
|
||||
charter_state = State.objects.get(type="charter", slug="notrev")
|
||||
else:
|
||||
charter_state = State.objects.get(type="charter", slug="approved")
|
||||
charter_rev = approved_revision(charter.rev)
|
||||
if charter_rev == "00":
|
||||
charter_rev = ""
|
||||
else:
|
||||
charter_state = clean['charter_state']
|
||||
charter_rev = charter.rev
|
||||
|
@ -216,19 +218,13 @@ class UploadForm(forms.Form):
|
|||
|
||||
def save(self, wg, rev):
|
||||
fd = self.cleaned_data['txt']
|
||||
filename = os.path.join(settings.CHARTER_PATH, 'charter-ietf-%s-%s.txt' % (wg.acronym, rev))
|
||||
if fd:
|
||||
# A file was specified. Save it.
|
||||
destination = open(filename, 'wb+')
|
||||
for chunk in fd.chunks():
|
||||
destination.write(chunk)
|
||||
destination.close()
|
||||
else:
|
||||
# No file, save content
|
||||
destination = open(filename, 'wb+')
|
||||
content = self.cleaned_data['content']
|
||||
destination.write(content)
|
||||
destination.close()
|
||||
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (wg.charter.canonical_name(), rev))
|
||||
with open(filename, 'wb+') as destination:
|
||||
if fd:
|
||||
for chunk in fd.chunks():
|
||||
destination.write(chunk)
|
||||
else:
|
||||
destination.write(self.cleaned_data['content'])
|
||||
|
||||
@role_required('Area Director','Secretariat')
|
||||
def submit(request, name):
|
||||
|
@ -237,6 +233,17 @@ def submit(request, name):
|
|||
|
||||
login = request.user.get_profile()
|
||||
|
||||
if charter.rev == "":
|
||||
prev_revs = charter.history_set.exclude(rev="").order_by('-rev').values_list('rev', flat=True)
|
||||
if prev_revs:
|
||||
charter.rev = prev_revs[0]
|
||||
|
||||
# Search history for possible collisions with abandoned efforts
|
||||
prev_revs = set(charter.history_set.order_by('-time').values_list('rev', flat=True))
|
||||
next_rev = next_revision(charter.rev)
|
||||
while next_rev in prev_revs:
|
||||
next_rev = next_revision(next_rev)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = UploadForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
|
@ -244,19 +251,13 @@ def submit(request, name):
|
|||
# Also save group history so we can search for it
|
||||
save_group_in_history(wg)
|
||||
|
||||
# Search history for possible collisions with abandoned efforts
|
||||
rev_list = list(charter.history_set.order_by('-time').values_list('rev', flat=True))
|
||||
next_rev = next_revision(charter.rev)
|
||||
while next_rev in rev_list:
|
||||
next_rev = next_revision(next_rev)
|
||||
|
||||
charter.rev = next_rev
|
||||
|
||||
e = DocEvent()
|
||||
e.type = "new_revision"
|
||||
e.by = login
|
||||
e.doc = charter
|
||||
e.desc = "New version available: <b>charter-ietf-%s-%s.txt</b>" % (wg.acronym, charter.rev)
|
||||
e.desc = "New version available: <b>%s-%s.txt</b>" % (charter.canonical_name(), charter.rev)
|
||||
e.save()
|
||||
|
||||
# Save file on disk
|
||||
|
@ -267,17 +268,18 @@ def submit(request, name):
|
|||
|
||||
return HttpResponseRedirect(reverse('doc_view', kwargs={'name': charter.name}))
|
||||
else:
|
||||
filename = os.path.join(settings.CHARTER_PATH, 'charter-ietf-%s-%s.txt' % (wg.acronym, wg.charter.rev))
|
||||
init = { "content": ""}
|
||||
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev))
|
||||
try:
|
||||
charter_text = open(filename, 'r')
|
||||
init = dict(content=charter_text.read())
|
||||
with open(filename, 'r') as f:
|
||||
init["content"] = f.read()
|
||||
except IOError:
|
||||
init = {}
|
||||
form = UploadForm(initial = init)
|
||||
pass
|
||||
form = UploadForm(initial=init)
|
||||
return render_to_response('wgcharter/submit.html',
|
||||
{'form': form,
|
||||
'next_rev': next_revision(wg.charter.rev),
|
||||
'wg': wg},
|
||||
'next_rev': next_rev,
|
||||
'wg': wg },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
class AnnouncementTextForm(forms.Form):
|
||||
|
@ -429,8 +431,8 @@ def ballot_writeupnotes(request, name):
|
|||
context_instance=RequestContext(request))
|
||||
|
||||
@role_required("Secretariat")
|
||||
def approve_ballot(request, name):
|
||||
"""Approve ballot, changing state, copying charter"""
|
||||
def approve(request, name):
|
||||
"""Approve charter, changing state, fixing revision, copying file to final location."""
|
||||
charter = get_object_or_404(Document, type="charter", name=name)
|
||||
wg = charter.group
|
||||
|
||||
|
@ -446,15 +448,10 @@ def approve_ballot(request, name):
|
|||
announcement = e.text
|
||||
|
||||
if request.method == 'POST':
|
||||
new_state = GroupStateName.objects.get(slug="active")
|
||||
new_charter_state = State.objects.get(type="charter", slug="approved")
|
||||
prev_charter_state = charter.get_state()
|
||||
|
||||
save_document_in_history(charter)
|
||||
save_group_in_history(wg)
|
||||
|
||||
prev_state = wg.state
|
||||
prev_charter_state = charter.get_state()
|
||||
wg.state = new_state
|
||||
charter.set_state(new_charter_state)
|
||||
|
||||
close_open_ballots(charter, login)
|
||||
|
@ -463,29 +460,30 @@ def approve_ballot(request, name):
|
|||
e.type = "iesg_approved"
|
||||
e.desc = "IESG has approved the charter"
|
||||
e.save()
|
||||
|
||||
change_description = e.desc + " and WG state has been changed to %s" % new_state.name
|
||||
|
||||
e = log_state_changed(request, charter, login, prev_state)
|
||||
|
||||
wg.time = e.time
|
||||
wg.save()
|
||||
|
||||
ch = get_charter_for_revision(wg.charter, wg.charter.rev)
|
||||
change_description = e.desc
|
||||
|
||||
filename = os.path.join(charter.get_file_path(), ch.name+"-"+ch.rev+".txt")
|
||||
new_state = GroupStateName.objects.get(slug="active")
|
||||
if wg.state != new_state:
|
||||
save_group_in_history(wg)
|
||||
prev_state = wg.state
|
||||
wg.state = new_state
|
||||
wg.time = e.time
|
||||
wg.save()
|
||||
change_description += " and WG state has been changed to %s" % new_state.name
|
||||
|
||||
e = log_state_changed(request, charter, login, prev_charter_state)
|
||||
|
||||
# copy file
|
||||
try:
|
||||
source = open(filename, 'rb')
|
||||
raw_content = source.read()
|
||||
|
||||
new_filename = os.path.join(charter.get_file_path(), 'charter-ietf-%s-%s.txt' % (wg.acronym, next_approved_revision(ch.rev)))
|
||||
destination = open(new_filename, 'wb+')
|
||||
destination.write(raw_content)
|
||||
destination.close()
|
||||
old = os.path.join(charter.get_file_path(), '%s-%s.txt' % (charter.canonical_name(), charter.rev))
|
||||
new = os.path.join(charter.get_file_path(), '%s-%s.txt' % (charter.canonical_name(), next_approved_revision(charter.rev)))
|
||||
shutil.copy(old, new)
|
||||
except IOError:
|
||||
raise Http404("Charter text %s" % filename)
|
||||
|
||||
charter.rev = next_approved_revision(charter.rev)
|
||||
charter.time = e.time
|
||||
charter.save()
|
||||
|
||||
email_secretariat(request, wg, "state-%s" % new_charter_state.slug, change_description)
|
||||
|
@ -495,7 +493,7 @@ def approve_ballot(request, name):
|
|||
|
||||
return HttpResponseRedirect(charter.get_absolute_url())
|
||||
|
||||
return render_to_response('wgcharter/approve_ballot.html',
|
||||
return render_to_response('wgcharter/approve.html',
|
||||
dict(charter=charter,
|
||||
announcement=announcement,
|
||||
wg=wg),
|
||||
|
|
|
@ -15,7 +15,6 @@ from ietf.name.models import *
|
|||
from ietf.person.models import *
|
||||
from ietf.group.models import *
|
||||
from ietf.group.utils import save_group_in_history
|
||||
from ietf.wgcharter.utils import set_or_create_charter
|
||||
from ietf.wgcharter.mails import email_secretariat
|
||||
from ietf.person.forms import EmailsField
|
||||
|
||||
|
@ -77,13 +76,14 @@ def edit(request, acronym=None, action="edit"):
|
|||
if action == "edit":
|
||||
# Editing. Get group
|
||||
wg = get_object_or_404(Group, acronym=acronym)
|
||||
charter = set_or_create_charter(wg)
|
||||
if not wg.charter:
|
||||
raise Http404
|
||||
new_wg = False
|
||||
elif action == "create":
|
||||
wg = None
|
||||
new_wg = True
|
||||
else:
|
||||
raise Http404()
|
||||
raise Http404
|
||||
|
||||
login = request.user.get_profile()
|
||||
|
||||
|
@ -91,9 +91,7 @@ def edit(request, acronym=None, action="edit"):
|
|||
form = WGForm(request.POST, cur_acronym=wg.acronym if wg else None)
|
||||
if form.is_valid():
|
||||
r = form.cleaned_data
|
||||
if not new_wg:
|
||||
gh = save_group_in_history(wg)
|
||||
else:
|
||||
if new_wg:
|
||||
# Create WG
|
||||
wg = Group(name=r["name"],
|
||||
acronym=r["acronym"],
|
||||
|
@ -107,19 +105,32 @@ def edit(request, acronym=None, action="edit"):
|
|||
e.state_id = "proposed"
|
||||
e.desc = "Proposed group"
|
||||
e.save()
|
||||
else:
|
||||
gh = save_group_in_history(wg)
|
||||
|
||||
if not wg.charter:
|
||||
# Create adjoined charter
|
||||
charter = set_or_create_charter(wg)
|
||||
charter.set_state(State.objects.get(type="charter", slug="infrev"))
|
||||
charter.save()
|
||||
|
||||
e = DocEvent(doc=charter, type="started_iesg_process")
|
||||
e.time = datetime.datetime.now()
|
||||
e.by = login
|
||||
e.desc = "Started IESG process on charter"
|
||||
e.save()
|
||||
|
||||
try:
|
||||
charter = Document.objects.get(docalias__name="charter-ietf-%s" % wg.acronym)
|
||||
except Document.DoesNotExist:
|
||||
charter = Document(
|
||||
name="charter-ietf-" + wg.acronym,
|
||||
type_id="charter",
|
||||
title=wg.name,
|
||||
group=wg,
|
||||
abstract=wg.name,
|
||||
rev="",
|
||||
)
|
||||
charter.save()
|
||||
charter.set_state(State.objects.get(type="charter", slug="infrev"))
|
||||
|
||||
# Create an alias as well
|
||||
DocAlias.objects.create(
|
||||
name=charter.name,
|
||||
document=charter
|
||||
)
|
||||
|
||||
wg.charter = charter
|
||||
|
||||
changes = []
|
||||
|
||||
def desc(attr, new, old):
|
||||
|
@ -140,7 +151,7 @@ def edit(request, acronym=None, action="edit"):
|
|||
# and add a DocAlias
|
||||
DocAlias.objects.create(
|
||||
name="charter-ietf-%s" % r['acronym'],
|
||||
document=charter,
|
||||
document=c,
|
||||
)
|
||||
|
||||
# update the attributes, keeping track of what we're doing
|
||||
|
@ -189,7 +200,7 @@ def edit(request, acronym=None, action="edit"):
|
|||
wg.save()
|
||||
|
||||
if new_wg:
|
||||
return redirect('wg_startstop_process', name=wg.charter.name, option="initcharter")
|
||||
return redirect('charter_startstop_process', name=wg.charter.name, option="initcharter")
|
||||
|
||||
return redirect('wg_charter', acronym=wg.acronym)
|
||||
else: # form.is_valid()
|
||||
|
@ -200,7 +211,6 @@ def edit(request, acronym=None, action="edit"):
|
|||
chairs=Email.objects.filter(role__group=wg, role__name="chair"),
|
||||
secretaries=Email.objects.filter(role__group=wg, role__name="secr"),
|
||||
techadv=Email.objects.filter(role__group=wg, role__name="techadv"),
|
||||
charter=wg.charter.name if wg.charter else None,
|
||||
ad=wg.ad_id if wg.ad else None,
|
||||
parent=wg.parent.id if wg.parent else None,
|
||||
list_email=wg.list_email if wg.list_email else None,
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
.snapshots .revisions a:first-child { font-weight: bold }
|
||||
|
||||
.metabox .actions a { display: inline-block; margin-right: 0.4em; }
|
||||
.metabox .ballot-summary { font-style: italic; }
|
||||
.metabox .telechat { margin-top: 0.2em; }
|
||||
|
||||
.diffTool { padding: 8px 4px; margin: 8px 0;}
|
||||
.diffTool h2 { margin-top:0;margin-bottom:4px; }
|
||||
|
|
Loading…
Reference in a new issue