parent
d0e9d95150
commit
242796253e
55
ietf/templates/wgchairs/confirm_management_writeup.html
Normal file
55
ietf/templates/wgchairs/confirm_management_writeup.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
{% extends "wginfo/wg_base.html" %}
|
||||
{% load ietf_filters wgchairs_tags %}
|
||||
|
||||
{% block title %}Chage shepherd for {{ doc }}{% endblock %}
|
||||
|
||||
{% block wg_content %}
|
||||
|
||||
<p>
|
||||
<a href="{% url manage_shepherds wg.group_acronym.acronym %}">Return to shepherd list</a>
|
||||
</p>
|
||||
|
||||
<h1>Updatting write-up for {{ doc }}</h1>
|
||||
|
||||
<p>
|
||||
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>.
|
||||
</p>
|
||||
<p>
|
||||
Remember that you must provide a comment if you change the annotation tag state.
|
||||
</p>
|
||||
|
||||
<form action="" method="POST">
|
||||
<table style="width: 100%;"><tr style="vertical-align: top;"><td style="width: 50%;">
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>Doc Shepherd Follow-up Underway</th></tr>
|
||||
{% if form.message %}
|
||||
<tr><td class="message message-{{ form.message.type }}">
|
||||
{{ form.message.value }}
|
||||
</td></tr>
|
||||
{% endif %}
|
||||
|
||||
<tr><td>
|
||||
<input type="hidden" value="{{ form.get_writeup }}" name="writeup" />
|
||||
<input type="hidden" value="confirm" name="confirm" />
|
||||
<input type="checkbox" name="followup" id="followup_id" value="1"{% if followup %} checked="checked"{% endif %} />
|
||||
<label for="followup_id">Doc Shepherd Follow-up Underway</label>
|
||||
</td></tr><tr><td>
|
||||
{{ form.comment }}
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<strong>Change write-up and ...</strong><br />
|
||||
<input type="submit" name="modify_tag" value="Modify 'Doc Shepherd Follow-up Underway'" />
|
||||
<input type="submit" name="change_writeup" value="Leave 'Doc Shepherd Follow-up Underway' untouched" /><br />
|
||||
<a href="">Cancel, I don't want to do any change!</a>
|
||||
</p>
|
||||
|
||||
</td><td style="width: 50%;">
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>New protocol write-up</th></tr>
|
||||
<tr style="vertical-align: top;"><td>{{ form.get_writeup|linebreaksbr }}</td></tr>
|
||||
</table>
|
||||
|
||||
</td></tr></table>
|
||||
</form>
|
||||
{% endblock %}
|
1
ietf/templates/wgchairs/draft_state.html
Normal file
1
ietf/templates/wgchairs/draft_state.html
Normal file
|
@ -0,0 +1 @@
|
|||
{{ state.name }}
|
65
ietf/templates/wgchairs/edit_management_writeup.html
Normal file
65
ietf/templates/wgchairs/edit_management_writeup.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
{% extends "wginfo/wg_base.html" %}
|
||||
{% load ietf_filters wgchairs_tags %}
|
||||
|
||||
{% block title %}Chage shepherd for {{ doc }}{% endblock %}
|
||||
|
||||
{% block wg_content %}
|
||||
|
||||
<p>
|
||||
<a href="{% url manage_shepherds wg.group_acronym.acronym %}">Return to shepherd list</a>
|
||||
</p>
|
||||
|
||||
<h1>Change protocol write-up for {{ doc }}</h1>
|
||||
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>Draft state</th><th>Actual protocol write-up</th><th>Last updated</th></tr>
|
||||
<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>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
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 }}.
|
||||
</p>
|
||||
|
||||
{% if can_edit %}
|
||||
<table style="width: 100%;"><tr style="vertical-align: top;"><td style="width: 75%;">
|
||||
<form action="" method="POST">
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>Edit protocol write-up</th></tr>
|
||||
{% if form.message %}
|
||||
<tr><td class="message message-{{ form.message.type }}">
|
||||
{{ form.message.value }}
|
||||
</td></tr>
|
||||
{% endif %}
|
||||
|
||||
<tr><td>
|
||||
<textarea name="writeup" style="border: 1px solid #cccccc; width: 100%; height: 15em;">{{ form.get_writeup }}</textarea></td></tr>
|
||||
</table>
|
||||
<input type="submit" name="change_writeup" value="Change write-up" />
|
||||
</form>
|
||||
|
||||
</td><td style="width: 25%;">
|
||||
|
||||
<form action="" method="POST" enctype="multipart/form-data">
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>Upload a new protocol write-up</th></tr>
|
||||
<tr><td>
|
||||
<p>Replace the current write-up with the contents of a plain ascii file:</p>
|
||||
<input type="file" name="uploaded_writeup" /></td></tr>
|
||||
</table>
|
||||
<input type="submit" name="upload_writeup" value="Upload write-up" />
|
||||
</form>
|
||||
</td></tr></table>
|
||||
{% else %}
|
||||
<table class="ietf-table" style="width: 100%;">
|
||||
<tr><th>Edit protocol write-up</th></tr>
|
||||
<tr><td>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
Please contact with the {{ wg }} Working Group chair.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endblock %}
|
17
ietf/templates/wgchairs/shepherd_document_row.html
Normal file
17
ietf/templates/wgchairs/shepherd_document_row.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
{% load wgchairs_tags %}
|
||||
|
||||
<tr class="{% cycle oddrow,evenrow %}">
|
||||
<td class="title">
|
||||
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
|
||||
</td>
|
||||
<td class="status">
|
||||
{{ doc.status.status }}
|
||||
</td>
|
||||
<td class="writeup">
|
||||
{% writeup doc %}
|
||||
<a href="{% url doc_managing_writeup wg.group_acronym.acronym doc %}" style="display: block;" href="">[Edit]</a>
|
||||
</td>
|
||||
<td class="writeup_date">
|
||||
{% writeupdate doc %}
|
||||
</td>
|
||||
</tr>
|
|
@ -56,25 +56,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
<table class="ietf-table ietf-doctable" style="margin-top:16px; width: 100%;">
|
||||
<tr>
|
||||
<th class="title">Document</th>
|
||||
<th class="date">Date</th>
|
||||
<th class="status">Status</th>
|
||||
<th class="ad">Area Director</th>
|
||||
<th class="writeup">Protocol write-up</th>
|
||||
<th class="writeup_date">Protocol write-up last update</th>
|
||||
</tr>
|
||||
|
||||
{% for doc in no_shepherd %}
|
||||
<tr class="{% cycle oddrow,evenrow %}">
|
||||
<td class="title">
|
||||
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
|
||||
</td>
|
||||
<td class="date">
|
||||
{{ doc.status.start_date|date:"Y-m" }}
|
||||
</td>
|
||||
<td class="status">
|
||||
{{ doc.status.status }}
|
||||
</td>
|
||||
<td class="ad">{{ doc.ad_name|default:"" }}</td>
|
||||
|
||||
</tr>
|
||||
{% include "wgchairs/shepherd_document_row.html" %}
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
|
@ -84,25 +72,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
<table class="ietf-table ietf-doctable" style="margin-top:16px; width: 100%;">
|
||||
<tr>
|
||||
<th class="title">Document</th>
|
||||
<th class="date">Date</th>
|
||||
<th class="status">Status</th>
|
||||
<th class="ad">Area Director</th>
|
||||
<th class="writeup">Protocol write-up</th>
|
||||
<th class="writeup_date">Protocol write-up last update</th>
|
||||
</tr>
|
||||
|
||||
{% for doc in my_documents %}
|
||||
<tr class="{% cycle oddrow,evenrow %}">
|
||||
<td class="title">
|
||||
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
|
||||
</td>
|
||||
<td class="date">
|
||||
{{ doc.status.start_date|date:"Y-m" }}
|
||||
</td>
|
||||
<td class="status">
|
||||
{{ doc.status.status }}
|
||||
</td>
|
||||
<td class="ad">{{ doc.ad_name|default:"" }}</td>
|
||||
|
||||
</tr>
|
||||
{% include "wgchairs/shepherd_document_row.html" %}
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
|
@ -115,23 +91,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
<table class="ietf-table ietf-doctable" style="width: 100%;">
|
||||
<tr>
|
||||
<th class="title">Document</th>
|
||||
<th class="date">Date</th>
|
||||
<th class="status">Status</th>
|
||||
<th class="ad">Area Director</th>
|
||||
<th class="writeup">Protocol write-up</th>
|
||||
<th class="writeup_date">Protocol write-up last update</th>
|
||||
</tr>
|
||||
{% for doc in documents.list %}
|
||||
<tr class="{% cycle oddrow,evenrow %}">
|
||||
<td class="title">
|
||||
<a href="{% url doc_managing_shepherd wg.group_acronym.acronym doc %}">{{ doc.title }}</a>
|
||||
</td>
|
||||
<td class="date">
|
||||
{{ doc.status.start_date|date:"Y-m" }}
|
||||
</td>
|
||||
<td class="status">
|
||||
{{ doc.status.status }}
|
||||
</td>
|
||||
<td class="ad">{{ doc.ad_name|default:"" }}</td>
|
||||
</tr>
|
||||
{% include "wgchairs/shepherd_document_row.html" %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
def is_area_director_for_group(person, group):
|
||||
return bool(group.area.area.areadirector_set.filter(person=person).count())
|
||||
|
||||
|
||||
def is_group_chair(person, group):
|
||||
if group.chairs().filter(person=person):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_group_delegate(person, group):
|
||||
return bool(group.wgdelegate_set.filter(person=person).count())
|
||||
|
||||
|
||||
def is_document_shepherd(person, document):
|
||||
return person == document.shepherd
|
||||
|
||||
|
||||
def get_person_for_user(user):
|
||||
try:
|
||||
return user.get_profile().person()
|
||||
|
@ -51,3 +63,22 @@ def can_manage_shepherd_of_a_document(user, document):
|
|||
if not person or not document.group:
|
||||
return False
|
||||
return can_manage_shepherds_in_group(user, document.group.ietfwg)
|
||||
|
||||
|
||||
def can_manage_writeup_of_a_document_no_state(user, document):
|
||||
person = get_person_for_user(user)
|
||||
if not person or not document.group:
|
||||
return False
|
||||
group = document.group.ietfwg
|
||||
return (is_group_chair(person, group) or
|
||||
is_areadirector_for_group(person, group) or
|
||||
is_group_delegate(person, group))
|
||||
|
||||
|
||||
def can_manage_writeup_of_a_document(user, document):
|
||||
person = get_person_for_user(user)
|
||||
if not person or not document.group:
|
||||
return False
|
||||
group = document.group.ietfwg
|
||||
return (can_manage_writeup_of_a_document_no_state(user, document) or
|
||||
is_document_shepherd(person, doc))
|
||||
|
|
|
@ -6,9 +6,10 @@ from django.forms.models import BaseModelFormSet
|
|||
from django.template.loader import render_to_string
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from ietf.wgchairs.models import WGDelegate
|
||||
from ietf.wgchairs.models import WGDelegate, ProtoWriteUp
|
||||
from ietf.wgchairs.accounts import get_person_for_user
|
||||
from ietf.ietfworkflows.utils import get_default_workflow_for_wg, get_workflow_for_wg
|
||||
from ietf.ietfworkflows.utils import (get_default_workflow_for_wg, get_workflow_for_wg,
|
||||
update_tags, FOLLOWUP_TAG)
|
||||
from ietf.idtracker.models import PersonOrOrgInfo
|
||||
|
||||
from workflows.models import Transition
|
||||
|
@ -328,3 +329,48 @@ def add_form_factory(request, wg, user, shepherd=False):
|
|||
return AddDelegateForm(wg=wg, user=user, data=request.POST.copy(), shepherd=shepherd)
|
||||
|
||||
return AddDelegateForm(wg=wg, user=user, shepherd=shepherd)
|
||||
|
||||
|
||||
class WriteUpEditForm(RelatedWGForm):
|
||||
|
||||
writeup = forms.CharField(widget=forms.Textarea, required=False)
|
||||
followup = forms.BooleanField(required=False)
|
||||
comment = forms.CharField(widget=forms.Textarea, required=False)
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.doc = kwargs.pop('doc', None)
|
||||
self.doc_writeup = self.doc.protowriteup_set.all()
|
||||
if self.doc_writeup.count():
|
||||
self.doc_writeup=self.doc_writeup[0]
|
||||
else:
|
||||
self.doc_writeup=None
|
||||
super(WriteUpEditForm, self).__init__(*args, **kwargs)
|
||||
|
||||
def get_writeup(self):
|
||||
return self.data.get('writeup', self.doc_writeup and self.doc_writeup.writeup or '')
|
||||
|
||||
def save(self):
|
||||
if not self.doc_writeup:
|
||||
self.doc_writeup = ProtoWriteUp.objects.create(
|
||||
person=get_person_for_user(self.user),
|
||||
draft=self.doc,
|
||||
writeup=self.cleaned_data['writeup'])
|
||||
else:
|
||||
self.doc_writeup.writeup = self.cleaned_data['writeup']
|
||||
self.doc_writeup.save()
|
||||
if self.data.get('modify_tag', False):
|
||||
followup = self.cleaned_data.get('followup', False)
|
||||
comment = self.cleaned_data.get('comment', False)
|
||||
if followup:
|
||||
update_tags(self.doc, comment, set_tags=[FOLLOWUP_TAG])
|
||||
else:
|
||||
update_tags(self.doc, comment, reset_tags=[FOLLOWUP_TAG])
|
||||
return self.doc_writeup
|
||||
|
||||
def is_valid(self):
|
||||
if self.data.get('confirm', False) and self.data.get('modify_tag', False):
|
||||
self.fields['comment'].required = True
|
||||
else:
|
||||
self.fields['comment'].required = False
|
||||
return super(WriteUpEditForm, self).is_valid()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django import template
|
||||
|
||||
from ietf.ietfworkflows.utils import get_state_for_draft
|
||||
from ietf.wgchairs.accounts import (can_manage_workflow_in_group,
|
||||
can_manage_delegates_in_group,
|
||||
can_manage_shepherds_in_group)
|
||||
|
@ -19,3 +20,27 @@ def wgchairs_admin_options(context, wg):
|
|||
'wg': wg,
|
||||
'selected': context.get('selected', None),
|
||||
}
|
||||
|
||||
@register.simple_tag
|
||||
def writeup(doc):
|
||||
writeup = doc.protowriteup_set.all()
|
||||
if not writeup.count():
|
||||
return ''
|
||||
else:
|
||||
return writeup[0].writeup
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def writeupdate(doc):
|
||||
writeup = doc.protowriteup_set.all()
|
||||
if not writeup.count():
|
||||
return ''
|
||||
else:
|
||||
return writeup[0].date
|
||||
|
||||
|
||||
@register.inclusion_tag('wgchairs/draft_state.html', takes_context=True)
|
||||
def show_state(context, doc):
|
||||
return {'doc': doc,
|
||||
'state': get_state_for_draft(doc),
|
||||
}
|
||||
|
|
|
@ -7,4 +7,5 @@ urlpatterns = patterns('ietf.wgchairs.views',
|
|||
url(r'^delegates/$', 'manage_delegates', name='manage_delegates'),
|
||||
url(r'^shepherds/$', 'wg_shepherd_documents', name='manage_shepherds'),
|
||||
url(r'^shepherds/(?P<name>[^/]+)/$', 'managing_shepherd', name='doc_managing_shepherd'),
|
||||
url(r'^shepherds/(?P<name>[^/]+)/writeup/$', 'managing_writeup', name='doc_managing_writeup'),
|
||||
)
|
||||
|
|
|
@ -5,13 +5,21 @@ from django.http import HttpResponseForbidden, Http404
|
|||
|
||||
from ietf.idrfc.views_search import SearchForm, search_query
|
||||
from ietf.wgchairs.forms import (RemoveDelegateForm, add_form_factory,
|
||||
workflow_form_factory, TransitionFormSet)
|
||||
workflow_form_factory, TransitionFormSet,
|
||||
WriteUpEditForm)
|
||||
from ietf.wgchairs.accounts import (can_manage_delegates_in_group, get_person_for_user,
|
||||
can_manage_shepherds_in_group,
|
||||
can_manage_workflow_in_group,
|
||||
can_manage_shepherd_of_a_document)
|
||||
can_manage_shepherd_of_a_document,
|
||||
can_manage_writeup_of_a_document,
|
||||
can_manage_writeup_of_a_document_no_state,
|
||||
)
|
||||
from ietf.ietfworkflows.utils import (get_workflow_for_wg,
|
||||
get_default_workflow_for_wg)
|
||||
get_default_workflow_for_wg,
|
||||
get_state_by_name,
|
||||
get_annotation_tags_for_draft,
|
||||
get_state_for_draft, WAITING_WRITEUP,
|
||||
FOLLOWUP_TAG)
|
||||
|
||||
|
||||
def manage_delegates(request, acronym):
|
||||
|
@ -136,3 +144,65 @@ def wg_shepherd_documents(request, acronym):
|
|||
'wg': wg,
|
||||
}
|
||||
return render_to_response('wgchairs/wg_shepherd_documents.html', context, RequestContext(request))
|
||||
|
||||
def managing_writeup(request, acronym, name):
|
||||
wg = get_object_or_404(IETFWG, group_acronym__acronym=acronym, group_type=1)
|
||||
user = request.user
|
||||
person = get_person_for_user(user)
|
||||
doc = get_object_or_404(InternetDraft, filename=name)
|
||||
if not can_manage_writeup_of_a_document(user, doc):
|
||||
raise Http404
|
||||
current_state = get_state_for_draft(doc)
|
||||
can_edit = True
|
||||
if current_state != get_state_by_name(WAITING_WRITEUP) and not can_manage_writeup_of_a_document_no_state(user,doc):
|
||||
can_edit = False
|
||||
writeup = doc.protowriteup_set.all()
|
||||
if writeup.count():
|
||||
writeup = writeup[0]
|
||||
else:
|
||||
writeup = None
|
||||
error = False
|
||||
followup_tag = get_annotation_tags_for_draft(doc).filter(annotation_tag__name=FOLLOWUP_TAG)
|
||||
followup = bool(followup_tag.count())
|
||||
if request.method == 'POST':
|
||||
form = WriteUpEditForm(wg=wg, doc=doc, user=user, data=request.POST, files=request.FILES)
|
||||
if request.FILES.get('uploaded_writeup', None):
|
||||
try:
|
||||
newwriteup = request.FILES['uploaded_writeup'].read().encode('ascii')
|
||||
form.data.update({'writeup': newwriteup})
|
||||
except:
|
||||
form.set_message('error', 'You have try to upload a non ascii file')
|
||||
error = True
|
||||
valid = form.is_valid()
|
||||
if (valid and not error and not request.POST.get('confirm', None)) or (not valid and not error):
|
||||
if not valid:
|
||||
form.set_message('error', 'You have to specify a comment')
|
||||
return render_to_response('wgchairs/confirm_management_writeup.html',
|
||||
dict(doc=doc,
|
||||
user=user,
|
||||
selected='manage_shepherds',
|
||||
wg=wg,
|
||||
followup=followup,
|
||||
form=form,
|
||||
writeup=writeup,
|
||||
can_edit=can_edit,
|
||||
),
|
||||
context_instance=RequestContext(request))
|
||||
elif valid and not error:
|
||||
writeup = form.save()
|
||||
form = WriteUpEditForm(wg=wg, doc=doc, user=user)
|
||||
followup_tag = get_annotation_tags_for_draft(doc).filter(annotation_tag__name=FOLLOWUP_TAG)
|
||||
followup = bool(followup_tag.count())
|
||||
else:
|
||||
form = WriteUpEditForm(wg=wg, doc=doc, user=user)
|
||||
return render_to_response('wgchairs/edit_management_writeup.html',
|
||||
dict(doc=doc,
|
||||
user=user,
|
||||
selected='manage_shepherds',
|
||||
wg=wg,
|
||||
form=form,
|
||||
writeup=writeup,
|
||||
followup=followup,
|
||||
can_edit=can_edit,
|
||||
),
|
||||
context_instance=RequestContext(request))
|
||||
|
|
Loading…
Reference in a new issue