Skip to content

Commit 512f179

Browse files
committed
Check for WG approval before posting. Closes ietf-tools#596.
- Legacy-Id: 2848
1 parent 3942d63 commit 512f179

6 files changed

Lines changed: 97 additions & 39 deletions

File tree

ietf/submit/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,5 +464,5 @@ def send_mail_to_secretariat(self, request):
464464
if self.draft.group_acronym:
465465
cc += [i.person.email()[1] for i in self.draft.group_acronym.wgchair_set.all()]
466466
cc = list(set(cc))
467-
send_mail(request, from_email, to_email, subject, 'submit/manual_post_mail.txt',
467+
send_mail(request, to_email, from_email, subject, 'submit/manual_post_mail.txt',
468468
{'form': self, 'draft': self.draft }, cc=cc)

ietf/submit/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ class Meta:
4646
db_table = 'id_submission_detail'
4747

4848

49+
class IdApprovedDetail(models.Model):
50+
id = models.AutoField(primary_key=True)
51+
filename = models.CharField(null=True, blank=True, max_length=255)
52+
approved_status = models.IntegerField(null=True, blank=True)
53+
approved_person_tag = models.IntegerField(null=True, blank=True)
54+
approved_date = models.DateField(null=True, blank=True)
55+
recorded_by = models.IntegerField(null=True, blank=True)
56+
57+
class Meta:
58+
db_table = 'id_approved_detail'
59+
60+
4961
class TempIdAuthors(models.Model):
5062
id = models.AutoField(primary_key=True)
5163
id_document_tag = models.IntegerField()

ietf/submit/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
url(r'^status/(?P<submission_id>\d+)/edit/$', 'draft_edit', name='draft_edit'),
99
url(r'^status/(?P<submission_id>\d+)/confirm/(?P<auth_key>[a-f\d]+)/$', 'draft_confirm', name='draft_confirm'),
1010
url(r'^status/(?P<submission_id>\d+)/cancel/$', 'draft_cancel', name='draft_cancel'),
11+
url(r'^status/(?P<submission_id>\d+)/approve/$', 'draft_approve', name='draft_approve'),
1112
)
1213

1314
urlpatterns += patterns('django.views.generic.simple',

ietf/submit/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import datetime
44

5+
from django.conf import settings
56
from ietf.idtracker.models import InternetDraft, EmailAddress, PersonOrOrgInfo
67

78

@@ -12,6 +13,7 @@
1213
POSTED = -1
1314
POSTED_BY_SECRETARIAT = -2
1415
CANCELED = -4
16+
INITIAL_VERSION_APPROVAL_REQUESTED = 10
1517

1618

1719
# Not a real WG

ietf/submit/views.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
2+
from django.conf import settings
23
from django.core.urlresolvers import reverse
34
from django.http import HttpResponseRedirect, Http404
45
from django.shortcuts import get_object_or_404
56
from django.shortcuts import render_to_response
67
from django.template import RequestContext
8+
from django.core.exceptions import ObjectDoesNotExist
79

8-
from ietf.submit.models import IdSubmissionDetail
10+
from ietf.submit.models import IdSubmissionDetail, IdApprovedDetail
911
from ietf.submit.forms import UploadForm, AutoPostForm, MetaDataForm
10-
from ietf.submit.utils import (DraftValidation, UPLOADED, WAITING_AUTHENTICATION, CANCELED,
11-
perform_post)
12+
from ietf.submit.utils import (DraftValidation, perform_post,
13+
UPLOADED, WAITING_AUTHENTICATION, CANCELED, INITIAL_VERSION_APPROVAL_REQUESTED)
14+
from ietf.utils.mail import send_mail
15+
1216

1317

1418
def submit_index(request):
@@ -53,12 +57,33 @@ def draft_status(request, submission_id, message=None):
5357
message=('error', 'This submission has been canceled, modification is no longer possible')
5458
status = detail.status
5559
allow_edit = None
60+
5661
if request.method=='POST' and allow_edit:
5762
if request.POST.get('autopost', False):
58-
auto_post_form = AutoPostForm(draft=detail, validation=validation, data=request.POST)
59-
if auto_post_form.is_valid():
60-
auto_post_form.save(request)
61-
return HttpResponseRedirect(reverse(draft_status, None, kwargs={'submission_id': detail.submission_id}))
63+
try:
64+
approved_detail = IdApprovedDetail.objects.get(filename=detail.filename)
65+
except ObjectDoesNotExist:
66+
approved_detail = None
67+
detail.status_id = INITIAL_VERSION_APPROVAL_REQUESTED
68+
detail.save()
69+
70+
if detail.revision == '00' and not approved_detail:
71+
subject = 'New draft waiting for approval: %s' % detail.filename
72+
from_email = settings.IDST_FROM_EMAIL
73+
to_email = []
74+
if detail.group_acronym:
75+
to_email += [i.person.email()[1] for i in detail.group_acronym.wgchair_set.all()]
76+
to_email = list(set(to_email))
77+
if to_email:
78+
metadata_form = MetaDataForm(draft=detail, validation=validation)
79+
send_mail(request, to_email, from_email, subject, 'submit/manual_post_mail.txt',
80+
{'form': metadata_form, 'draft': detail})
81+
else:
82+
auto_post_form = AutoPostForm(draft=detail, validation=validation, data=request.POST)
83+
if auto_post_form.is_valid():
84+
auto_post_form.save(request)
85+
return HttpResponseRedirect(reverse(draft_status, None, kwargs={'submission_id': detail.submission_id}))
86+
6287
else:
6388
return HttpResponseRedirect(reverse(draft_edit, None, kwargs={'submission_id': detail.submission_id}))
6489
else:
@@ -114,3 +139,12 @@ def draft_confirm(request, submission_id, auth_key):
114139
message = ('success', 'Authorization key accepted. Auto-Post complete')
115140
perform_post(detail)
116141
return draft_status(request, submission_id, message)
142+
143+
144+
def draft_approve(request, submission_id):
145+
detail = get_object_or_404(IdSubmissionDetail, submission_id=submission_id)
146+
if detail.status_id == INITIAL_VERSION_APPROVAL_REQUESTED:
147+
validation = DraftValidation(detail)
148+
approved_detail = IdApprovedDetail()
149+
perform_post(detail)
150+
return HttpResponseRedirect(reverse(draft_status, None, kwargs={'submission_id': submission_id}))

ietf/templates/submit/draft_status.html

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<script type="text/javascript">
2323
function confirmCancelation(){
2424
if (confirm("Cancel this submission?"))
25-
document.location = "cancel";
25+
document.location = "/submit/status/{{ detail.submission_id }}/cancel/";
2626
}
2727

2828
(function ($) {
@@ -146,40 +146,49 @@ <h3>Meta-Data errors found</h3>
146146
</table>
147147

148148
{% if allow_edit %}
149-
<form method="post" action="" name="auto_post_form">
150-
<input type="submit" value="Adjust Meta-Data" value="adjust" /> (Leads to manual post by the Secretariat)
151-
</form>
152-
{% if is_valid %}
153-
<h2>Please edit the following meta-data before proceeding to Auto-Post</h2>
154-
<p>
155-
If you are one of the authors of this document, then please click the button with your name on it to automatically fill in the submitter information as requested below. Otherwise, please manually enter your information.
156-
</p>
157-
<form method="post" action="">
158-
{{ auto_post_form.get_author_buttons|safe }}
159-
<table class="metadata-table">
160-
{{ auto_post_form }}
161-
</table>
162-
<input type="submit" value="Post" name="autopost" />
163-
</form>
164-
{% endif %}
149+
<form method="post" action="" name="auto_post_form">
150+
<input type="submit" value="Adjust Meta-Data" value="adjust" /> (Leads to manual post by the Secretariat)
151+
</form>
152+
153+
{% if is_valid %}
154+
<h2>Please edit the following meta-data before proceeding to Auto-Post</h2>
155+
<p>
156+
If you are one of the authors of this document, then please click the button with your name on it to automatically fill in the submitter information as requested below. Otherwise, please manually enter your information.
157+
</p>
158+
<form method="post" action="">
159+
{{ auto_post_form.get_author_buttons|safe }}
160+
<table class="metadata-table">
161+
{{ auto_post_form }}
162+
</table>
163+
<input type="submit" value="Post" name="autopost" />
164+
</form>
165+
{% endif %}
166+
167+
<h2>Cancel submission</h2>
168+
<p>
169+
<input type="button" onclick="confirmCancelation();" value="Cancel Submission" /><br>
170+
This submission will be canceled, and its uploaded document(s) permanently deleted.
171+
</p>
165172

166-
<h2>Cancel submission</h2>
167-
<p>
168-
<input type="button" onclick="confirmCancelation();" value="Cancel Submission" /><br>
169-
This submission will be canceled, and its uploaded document(s) permanently deleted.
170-
</p>
171173
{% else %}
172-
{% if validation.submitter %}
173-
<h3>Submitter information</h3>
174-
<table class="metadata-table">
175-
<tr><th>First name</th><td>{{ validation.submitter.first_name }}</td></tr>
176-
<tr><th>Last name</th><td>{{ validation.submitter.last_name }}</td></tr>
177-
<tr><th>Email address</th><td>{{ validation.submitter.email_address|default:validation.submitter.email.1 }}</td></tr>
178-
</table>
179-
{% endif %}
180-
174+
{% if validation.submitter %}
175+
<h3>Submitter information</h3>
176+
<table class="metadata-table">
177+
<tr><th>First name</th><td>{{ validation.submitter.first_name }}</td></tr>
178+
<tr><th>Last name</th><td>{{ validation.submitter.last_name }}</td></tr>
179+
<tr><th>Email address</th><td>{{ validation.submitter.email_address|default:validation.submitter.email.1 }}</td></tr>
180+
</table>
181+
{% endif %}
181182
{% endif %}
182183

184+
{% ifequal status.status_value "Initial Version Approval Requested" %}
185+
<p>
186+
<form method="post" action="/submit/status/{{ detail.submission_id }}/approve/">
187+
<input type="submit" value="Approve this submission" />
188+
</form>
189+
</p>
190+
{% endifequal %}
191+
183192
<p>
184193
The IETF is an organized activity of the <a href="http://www.isoc.org">Internet Society</a>
185194
<br>Please send problem reports to <a href="mailto:ietf-action@ietf.org">ietf-action@ietf.org</a>.

0 commit comments

Comments
 (0)