Skip to content

Commit 2427962

Browse files
committed
Form to edit or upload a protocol write-up. See ietf-tools#561
- Legacy-Id: 2745
1 parent d0e9d95 commit 2427962

10 files changed

Lines changed: 325 additions & 49 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{% extends "wginfo/wg_base.html" %}
2+
{% load ietf_filters wgchairs_tags %}
3+
4+
{% block title %}Chage shepherd for {{ doc }}{% endblock %}
5+
6+
{% block wg_content %}
7+
8+
<p>
9+
<a href="{% url manage_shepherds wg.group_acronym.acronym %}">Return to shepherd list</a>
10+
</p>
11+
12+
<h1>Updatting write-up for {{ doc }}</h1>
13+
14+
<p>
15+
Before you modify the protocol write-up <strong>please revise the 'Doc Shepherd Follow-up Underway' annotation tag and set or reset it if appropriate</strong>.
16+
</p>
17+
<p>
18+
Remember that you must provide a comment if you change the annotation tag state.
19+
</p>
20+
21+
<form action="" method="POST">
22+
<table style="width: 100%;"><tr style="vertical-align: top;"><td style="width: 50%;">
23+
<table class="ietf-table" style="width: 100%;">
24+
<tr><th>Doc Shepherd Follow-up Underway</th></tr>
25+
{% if form.message %}
26+
<tr><td class="message message-{{ form.message.type }}">
27+
{{ form.message.value }}
28+
</td></tr>
29+
{% endif %}
30+
31+
<tr><td>
32+
<input type="hidden" value="{{ form.get_writeup }}" name="writeup" />
33+
<input type="hidden" value="confirm" name="confirm" />
34+
<input type="checkbox" name="followup" id="followup_id" value="1"{% if followup %} checked="checked"{% endif %} />
35+
<label for="followup_id">Doc Shepherd Follow-up Underway</label>
36+
</td></tr><tr><td>
37+
{{ form.comment }}
38+
</td></tr>
39+
</table>
40+
<p>
41+
<strong>Change write-up and ...</strong><br />
42+
<input type="submit" name="modify_tag" value="Modify 'Doc Shepherd Follow-up Underway'" />
43+
<input type="submit" name="change_writeup" value="Leave 'Doc Shepherd Follow-up Underway' untouched" /><br />
44+
<a href="">Cancel, I don't want to do any change!</a>
45+
</p>
46+
47+
</td><td style="width: 50%;">
48+
<table class="ietf-table" style="width: 100%;">
49+
<tr><th>New protocol write-up</th></tr>
50+
<tr style="vertical-align: top;"><td>{{ form.get_writeup|linebreaksbr }}</td></tr>
51+
</table>
52+
53+
</td></tr></table>
54+
</form>
55+
{% endblock %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ state.name }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{% extends "wginfo/wg_base.html" %}
2+
{% load ietf_filters wgchairs_tags %}
3+
4+
{% block title %}Chage shepherd for {{ doc }}{% endblock %}
5+
6+
{% block wg_content %}
7+
8+
<p>
9+
<a href="{% url manage_shepherds wg.group_acronym.acronym %}">Return to shepherd list</a>
10+
</p>
11+
12+
<h1>Change protocol write-up for {{ doc }}</h1>
13+
14+
<table class="ietf-table" style="width: 100%;">
15+
<tr><th>Draft state</th><th>Actual protocol write-up</th><th>Last updated</th></tr>
16+
<tr style="vertical-align: top;"><td>{% show_state doc %}</td><td>{{ writeup.writeup|linebreaksbr }}</td><td>{% if writeup %}{{ writeup.date }} by {{ writeup.person }}{% endif %}</td></tr>
17+
</table>
18+
19+
<p>
20+
Please, <strong>note</strong> that the <strong>'Doc Shepherd Follow-up Underway'</strong> annotation tag is {% if not followup %}<strong>NOT</strong>{% endif %} setted for {{ doc }}.
21+
</p>
22+
23+
{% if can_edit %}
24+
<table style="width: 100%;"><tr style="vertical-align: top;"><td style="width: 75%;">
25+
<form action="" method="POST">
26+
<table class="ietf-table" style="width: 100%;">
27+
<tr><th>Edit protocol write-up</th></tr>
28+
{% if form.message %}
29+
<tr><td class="message message-{{ form.message.type }}">
30+
{{ form.message.value }}
31+
</td></tr>
32+
{% endif %}
33+
34+
<tr><td>
35+
<textarea name="writeup" style="border: 1px solid #cccccc; width: 100%; height: 15em;">{{ form.get_writeup }}</textarea></td></tr>
36+
</table>
37+
<input type="submit" name="change_writeup" value="Change write-up" />
38+
</form>
39+
40+
</td><td style="width: 25%;">
41+
42+
<form action="" method="POST" enctype="multipart/form-data">
43+
<table class="ietf-table" style="width: 100%;">
44+
<tr><th>Upload a new protocol write-up</th></tr>
45+
<tr><td>
46+
<p>Replace the current write-up with the contents of a plain ascii file:</p>
47+
<input type="file" name="uploaded_writeup" /></td></tr>
48+
</table>
49+
<input type="submit" name="upload_writeup" value="Upload write-up" />
50+
</form>
51+
</td></tr></table>
52+
{% else %}
53+
<table class="ietf-table" style="width: 100%;">
54+
<tr><th>Edit protocol write-up</th></tr>
55+
<tr><td>
56+
<p>
57+
You can not edit or upload the protocol write-up for {{ doc }} cause the draft is not on "WG Consensus: Waiting for Write-Up" state.
58+
</p>
59+
<p>
60+
Please contact with the {{ wg }} Working Group chair.
61+
</p>
62+
</td></tr>
63+
</table>
64+
{% endif %}
65+
{% endblock %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% load wgchairs_tags %}
2+
3+
<tr class="{% cycle oddrow,evenrow %}">
4+
<td class="title">
5+
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
6+
</td>
7+
<td class="status">
8+
{{ doc.status.status }}
9+
</td>
10+
<td class="writeup">
11+
{% writeup doc %}
12+
<a href="{% url doc_managing_writeup wg.group_acronym.acronym doc %}" style="display: block;" href="">[Edit]</a>
13+
</td>
14+
<td class="writeup_date">
15+
{% writeupdate doc %}
16+
</td>
17+
</tr>

ietf/templates/wgchairs/wg_shepherd_documents.html

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,13 @@ <h2>Documets by its shepherd</h2>
5656
<table class="ietf-table ietf-doctable" style="margin-top:16px; width: 100%;">
5757
<tr>
5858
<th class="title">Document</th>
59-
<th class="date">Date</th>
6059
<th class="status">Status</th>
61-
<th class="ad">Area Director</th>
60+
<th class="writeup">Protocol write-up</th>
61+
<th class="writeup_date">Protocol write-up last update</th>
6262
</tr>
6363

6464
{% for doc in no_shepherd %}
65-
<tr class="{% cycle oddrow,evenrow %}">
66-
<td class="title">
67-
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
68-
</td>
69-
<td class="date">
70-
{{ doc.status.start_date|date:"Y-m" }}
71-
</td>
72-
<td class="status">
73-
{{ doc.status.status }}
74-
</td>
75-
<td class="ad">{{ doc.ad_name|default:"" }}</td>
76-
77-
</tr>
65+
{% include "wgchairs/shepherd_document_row.html" %}
7866
{% endfor %}
7967

8068
</table>
@@ -84,25 +72,13 @@ <h2>Documets by its shepherd</h2>
8472
<table class="ietf-table ietf-doctable" style="margin-top:16px; width: 100%;">
8573
<tr>
8674
<th class="title">Document</th>
87-
<th class="date">Date</th>
8875
<th class="status">Status</th>
89-
<th class="ad">Area Director</th>
76+
<th class="writeup">Protocol write-up</th>
77+
<th class="writeup_date">Protocol write-up last update</th>
9078
</tr>
9179

9280
{% for doc in my_documents %}
93-
<tr class="{% cycle oddrow,evenrow %}">
94-
<td class="title">
95-
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
96-
</td>
97-
<td class="date">
98-
{{ doc.status.start_date|date:"Y-m" }}
99-
</td>
100-
<td class="status">
101-
{{ doc.status.status }}
102-
</td>
103-
<td class="ad">{{ doc.ad_name|default:"" }}</td>
104-
105-
</tr>
81+
{% include "wgchairs/shepherd_document_row.html" %}
10682
{% endfor %}
10783

10884
</table>
@@ -115,23 +91,12 @@ <h3 style="margin-bottom: 0px;">{{ documents.grouper }}</h3>
11591
<table class="ietf-table ietf-doctable" style="width: 100%;">
11692
<tr>
11793
<th class="title">Document</th>
118-
<th class="date">Date</th>
11994
<th class="status">Status</th>
120-
<th class="ad">Area Director</th>
95+
<th class="writeup">Protocol write-up</th>
96+
<th class="writeup_date">Protocol write-up last update</th>
12197
</tr>
12298
{% for doc in documents.list %}
123-
<tr class="{% cycle oddrow,evenrow %}">
124-
<td class="title">
125-
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
126-
</td>
127-
<td class="date">
128-
{{ doc.status.start_date|date:"Y-m" }}
129-
</td>
130-
<td class="status">
131-
{{ doc.status.status }}
132-
</td>
133-
<td class="ad">{{ doc.ad_name|default:"" }}</td>
134-
</tr>
99+
{% include "wgchairs/shepherd_document_row.html" %}
135100
{% endfor %}
136101
</table>
137102
{% endfor %}

ietf/wgchairs/accounts.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
def is_area_director_for_group(person, group):
2+
return bool(group.area.area.areadirector_set.filter(person=person).count())
3+
4+
15
def is_group_chair(person, group):
26
if group.chairs().filter(person=person):
37
return True
48
return False
59

610

11+
def is_group_delegate(person, group):
12+
return bool(group.wgdelegate_set.filter(person=person).count())
13+
14+
15+
def is_document_shepherd(person, document):
16+
return person == document.shepherd
17+
18+
719
def get_person_for_user(user):
820
try:
921
return user.get_profile().person()
@@ -51,3 +63,22 @@ def can_manage_shepherd_of_a_document(user, document):
5163
if not person or not document.group:
5264
return False
5365
return can_manage_shepherds_in_group(user, document.group.ietfwg)
66+
67+
68+
def can_manage_writeup_of_a_document_no_state(user, document):
69+
person = get_person_for_user(user)
70+
if not person or not document.group:
71+
return False
72+
group = document.group.ietfwg
73+
return (is_group_chair(person, group) or
74+
is_areadirector_for_group(person, group) or
75+
is_group_delegate(person, group))
76+
77+
78+
def can_manage_writeup_of_a_document(user, document):
79+
person = get_person_for_user(user)
80+
if not person or not document.group:
81+
return False
82+
group = document.group.ietfwg
83+
return (can_manage_writeup_of_a_document_no_state(user, document) or
84+
is_document_shepherd(person, doc))

ietf/wgchairs/forms.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
from django.template.loader import render_to_string
77
from django.utils.safestring import mark_safe
88

9-
from ietf.wgchairs.models import WGDelegate
9+
from ietf.wgchairs.models import WGDelegate, ProtoWriteUp
1010
from ietf.wgchairs.accounts import get_person_for_user
11-
from ietf.ietfworkflows.utils import get_default_workflow_for_wg, get_workflow_for_wg
11+
from ietf.ietfworkflows.utils import (get_default_workflow_for_wg, get_workflow_for_wg,
12+
update_tags, FOLLOWUP_TAG)
1213
from ietf.idtracker.models import PersonOrOrgInfo
1314

1415
from workflows.models import Transition
@@ -328,3 +329,48 @@ def add_form_factory(request, wg, user, shepherd=False):
328329
return AddDelegateForm(wg=wg, user=user, data=request.POST.copy(), shepherd=shepherd)
329330

330331
return AddDelegateForm(wg=wg, user=user, shepherd=shepherd)
332+
333+
334+
class WriteUpEditForm(RelatedWGForm):
335+
336+
writeup = forms.CharField(widget=forms.Textarea, required=False)
337+
followup = forms.BooleanField(required=False)
338+
comment = forms.CharField(widget=forms.Textarea, required=False)
339+
340+
341+
def __init__(self, *args, **kwargs):
342+
self.doc = kwargs.pop('doc', None)
343+
self.doc_writeup = self.doc.protowriteup_set.all()
344+
if self.doc_writeup.count():
345+
self.doc_writeup=self.doc_writeup[0]
346+
else:
347+
self.doc_writeup=None
348+
super(WriteUpEditForm, self).__init__(*args, **kwargs)
349+
350+
def get_writeup(self):
351+
return self.data.get('writeup', self.doc_writeup and self.doc_writeup.writeup or '')
352+
353+
def save(self):
354+
if not self.doc_writeup:
355+
self.doc_writeup = ProtoWriteUp.objects.create(
356+
person=get_person_for_user(self.user),
357+
draft=self.doc,
358+
writeup=self.cleaned_data['writeup'])
359+
else:
360+
self.doc_writeup.writeup = self.cleaned_data['writeup']
361+
self.doc_writeup.save()
362+
if self.data.get('modify_tag', False):
363+
followup = self.cleaned_data.get('followup', False)
364+
comment = self.cleaned_data.get('comment', False)
365+
if followup:
366+
update_tags(self.doc, comment, set_tags=[FOLLOWUP_TAG])
367+
else:
368+
update_tags(self.doc, comment, reset_tags=[FOLLOWUP_TAG])
369+
return self.doc_writeup
370+
371+
def is_valid(self):
372+
if self.data.get('confirm', False) and self.data.get('modify_tag', False):
373+
self.fields['comment'].required = True
374+
else:
375+
self.fields['comment'].required = False
376+
return super(WriteUpEditForm, self).is_valid()

ietf/wgchairs/templatetags/wgchairs_tags.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django import template
22

3+
from ietf.ietfworkflows.utils import get_state_for_draft
34
from ietf.wgchairs.accounts import (can_manage_workflow_in_group,
45
can_manage_delegates_in_group,
56
can_manage_shepherds_in_group)
@@ -19,3 +20,27 @@ def wgchairs_admin_options(context, wg):
1920
'wg': wg,
2021
'selected': context.get('selected', None),
2122
}
23+
24+
@register.simple_tag
25+
def writeup(doc):
26+
writeup = doc.protowriteup_set.all()
27+
if not writeup.count():
28+
return ''
29+
else:
30+
return writeup[0].writeup
31+
32+
33+
@register.simple_tag
34+
def writeupdate(doc):
35+
writeup = doc.protowriteup_set.all()
36+
if not writeup.count():
37+
return ''
38+
else:
39+
return writeup[0].date
40+
41+
42+
@register.inclusion_tag('wgchairs/draft_state.html', takes_context=True)
43+
def show_state(context, doc):
44+
return {'doc': doc,
45+
'state': get_state_for_draft(doc),
46+
}

ietf/wgchairs/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
url(r'^delegates/$', 'manage_delegates', name='manage_delegates'),
88
url(r'^shepherds/$', 'wg_shepherd_documents', name='manage_shepherds'),
99
url(r'^shepherds/(?P<name>[^/]+)/$', 'managing_shepherd', name='doc_managing_shepherd'),
10+
url(r'^shepherds/(?P<name>[^/]+)/writeup/$', 'managing_writeup', name='doc_managing_writeup'),
1011
)

0 commit comments

Comments
 (0)