(-r5194:5465 from branch/iola/shimfree). Copying relevant commit messages here: - Removed .related many to many relationship, it's not really useful since we always have to restrict on the relationship type anyway, instead add two helpers for doing the necessary queries (in both directions) - Added migration for transforming the .desc on the new_revision events into something more akin to what is actually shown in the history page - Added migration for blanking IESG notes that just consist of "RFC XXXX", these have been superfluous for some time - Grant stream chairs access to changing the stream on a draft - Hacked the format_history_text filter to be less weird, using the same formatting for snippets and full text, also link up legacy ballot set events - Moved the decoraters + utilities to new ietfauth/utils.py file - Added simple helper to Email to identify invalid email addresses (from legacy author entries) - Used new new_revision .desc format for when drafts are submitted - Improved the looks of the button class by adding extra contrast and a linear gradient. Currently the gradient is only visible in fairly recent browsers. - Rewrote draft and RFC tabs in terms of the new schema, porting write-up and history tabs as well - Fixed two bugs in RFC Editor syncing: make sure documents we don't know beforehand get a "draft" type and make sure individually submitted drafts get the type="individ" group instead of NULL - Made the CSS-styled button feel a bit nicer to use by flattening the active state, also introduce some temporary styles until browsers catch up with the standard syntax - Added migrations for fixing 1) a dummy RFC entry, 2) three stand-alone RFCs that didn't get their doc.type set, 3) a big bunch of historic stand-alone RFCs that have doc.group=None - set these to the individual submission "none" group for the time being so the view code doesn't have to deal with a special case. In some cases this is wrong since there actually was a WG associated but unfortunately fixing them properly requires detective work (probably parsing the RFCs) and in at least some cases recreating historic WGs. In case someone ends up doing this, the documents to check can still be found with Document.objects.filter(name__startswith="rfc", group__type="individ") since there are almost no new RFCs that didn't went through the I-D process. - Merged the I-D and RFC views by showing I-D information on RFCs too. I-Ds that have been published as RFCs redirect to the RFC URL. Also support alias URLs so e.g. /doc/bcpXXXX redirects to /doc/rfcXXXX. - Fixed revision augmentation so events after RFC publication gets a "RFC" designation - Fixed a bug with tabs not using provided name but rather doc.name - Displaying draft-iesg state rather than doc.friendly_state as IESG state, also show a notice that the IESG state refers to post-RFC processing if it does, like the old separate RFC page did - Fixed the RFC number doc.note migration to catch combined "RFC XXX; BCP XXX" notes too, use the opportunity to remove inserted HTML tags from notes and rely on linebreaksbr filter instead (the other thing was a left-over from the Perl days), update the various uses of the note to reflect that - Refactored slightly to make views_doc.py independent of other idrfc code - Moveed idrfc/views_doc.py to doc/ with associated templates, replace the somewhat fragile simple URL tests for views_doc.py with ordinary unit tests. The new tests are still fairly basic but at least test more than the URL tests did. - Made sure RFC's (and BCP/STD/FYI) are stored as RFC123 instead of RFC0123 in the alias table with a new migration and a change to the RFC Editor sync, this in turn makes /doc/std1/ do the right thing - Now /doc/std1/ works, we can actually do a local link in urlize_ietf_docs rather than linking to the tools.ietf.org server - Fixed history text formatter: sanitize HTML before adding linebreaks and non-breaking spaces, this cuts the time to render a history page with long comments in half - Added a test crawler that walks through the crawlable part of the site, reporting errors and slow pages - Got rid of initial "No record" positions when showing old positions, it's just noise - Added a .select_related() to the document main tab to reduce the number of DB queries, unfortunately it seems it doesn't really help with Django 1.2.x due to a bug (Document inherits from DocumentInfo which makes things a bit more complicated) - Introduced a simple cache in doc.get_state so repeated reads don't cause a DB query - Cleaned up the search code in preparation for removal of the shim-layer; use a static button and don't send extraneous GET parameters - Removed dead code in several places - Legacy-Id: 5830
201 lines
9 KiB
Python
201 lines
9 KiB
Python
from django.conf import settings
|
|
from ietf.idtracker.models import IETFWG, InternetDraft
|
|
from django.shortcuts import get_object_or_404, render_to_response
|
|
from django.template import RequestContext
|
|
from django.http import HttpResponseForbidden, Http404
|
|
|
|
from ietf.wgchairs.forms import (RemoveDelegateForm, add_form_factory,
|
|
workflow_form_factory, TransitionFormSet,
|
|
WriteUpEditForm, assign_shepherd)
|
|
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_writeup_of_a_document,
|
|
can_manage_writeup_of_a_document_no_state,
|
|
)
|
|
from ietf.ietfworkflows.constants import REQUIRED_STATES
|
|
from ietf.ietfworkflows.utils import (get_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)
|
|
from ietf.name.models import DocTagName
|
|
from ietf.doc.models import State
|
|
from ietf.doc.utils import get_tags_for_stream_id
|
|
|
|
def manage_delegates(request, acronym):
|
|
wg = get_object_or_404(IETFWG, group_acronym__acronym=acronym, group_type=1)
|
|
user = request.user
|
|
if not can_manage_delegates_in_group(user, wg):
|
|
return HttpResponseForbidden('You have no permission to access this view')
|
|
delegates = wg.wgdelegate_set.all()
|
|
add_form = add_form_factory(request, wg, user)
|
|
if request.method == 'POST':
|
|
if request.POST.get('remove', None):
|
|
form = RemoveDelegateForm(wg=wg, data=request.POST.copy())
|
|
if form.is_valid():
|
|
form.save()
|
|
elif add_form.is_valid():
|
|
add_form.save()
|
|
add_form = add_form.get_next_form()
|
|
max_delegates = getattr(settings, 'MAX_WG_DELEGATES', 3)
|
|
return render_to_response('wgchairs/manage_delegates.html',
|
|
{'wg': wg,
|
|
'delegates': delegates,
|
|
'selected': 'manage_delegates',
|
|
'can_add': delegates.count() < max_delegates,
|
|
'max_delegates': max_delegates,
|
|
'add_form': add_form,
|
|
}, RequestContext(request))
|
|
|
|
|
|
def manage_workflow(request, acronym):
|
|
wg = get_object_or_404(IETFWG, group_acronym__acronym=acronym, group_type=1)
|
|
user = request.user
|
|
if not can_manage_workflow_in_group(user, wg):
|
|
return HttpResponseForbidden("You don't have permission to access this view")
|
|
workflow = get_workflow_for_wg(wg)
|
|
default_workflow = get_default_workflow_for_wg()
|
|
formset = None
|
|
if request.method == 'POST':
|
|
form = workflow_form_factory(request, wg=wg, user=user)
|
|
if form.is_valid():
|
|
form.save()
|
|
elif isinstance(form, TransitionFormSet):
|
|
formset = form
|
|
tags = workflow.selected_tags.all()
|
|
default_tags = default_workflow.annotation_tags.all()
|
|
states = workflow.selected_states.all().order_by('statedescription__order')
|
|
default_states = default_workflow.states.all().order_by('statedescription__order')
|
|
for i in default_states:
|
|
if states.filter(name=i.name).count() == 1:
|
|
i.used = True
|
|
if i.name in REQUIRED_STATES:
|
|
i.freeze = True
|
|
for i in default_tags:
|
|
if tags.filter(name=i.name).count() == 1:
|
|
i.used = True
|
|
if not formset:
|
|
formset = TransitionFormSet(queryset=workflow.transitions.all(), user=user, wg=wg)
|
|
|
|
return render_to_response('wgchairs/manage_workflow.html',
|
|
{'wg': wg,
|
|
'workflow': workflow,
|
|
'default_workflow': default_workflow,
|
|
'states': states,
|
|
'tags': tags,
|
|
'default_states': default_states,
|
|
'default_tags': default_tags,
|
|
'formset': formset,
|
|
'selected': 'manage_workflow',
|
|
}, RequestContext(request))
|
|
|
|
def manage_workflowREDESIGN(request, acronym):
|
|
from ietf.doc.models import State
|
|
from ietf.group.models import GroupStateTransitions
|
|
|
|
MANDATORY_STATES = ('c-adopt', 'wg-doc', 'sub-pub')
|
|
|
|
wg = get_object_or_404(IETFWG, group_acronym__acronym=acronym, group_type=1)
|
|
user = request.user
|
|
if not can_manage_workflow_in_group(user, wg):
|
|
return HttpResponseForbidden("You don't have permission to access this view")
|
|
|
|
if request.method == 'POST':
|
|
action = request.POST.get("action")
|
|
if action == "setstateactive":
|
|
active = request.POST.get("active") == "1"
|
|
try:
|
|
state = State.objects.exclude(slug__in=MANDATORY_STATES).get(pk=request.POST.get("state"))
|
|
except State.DoesNotExist:
|
|
return HttpResponse("Invalid state %s" % request.POST.get("state"))
|
|
|
|
if active:
|
|
wg.unused_states.remove(state)
|
|
else:
|
|
wg.unused_states.add(state)
|
|
|
|
if action == "setnextstates":
|
|
try:
|
|
state = State.objects.get(pk=request.POST.get("state"))
|
|
except State.DoesNotExist:
|
|
return HttpResponse("Invalid state %s" % request.POST.get("state"))
|
|
|
|
next_states = State.objects.filter(used=True, type='draft-stream-ietf', pk__in=request.POST.getlist("next_states"))
|
|
unused = wg.unused_states.all()
|
|
if set(next_states.exclude(pk__in=unused)) == set(state.next_states.exclude(pk__in=unused)):
|
|
# just use the default
|
|
wg.groupstatetransitions_set.filter(state=state).delete()
|
|
else:
|
|
transitions, _ = GroupStateTransitions.objects.get_or_create(group=wg, state=state)
|
|
transitions.next_states = next_states
|
|
|
|
if action == "settagactive":
|
|
active = request.POST.get("active") == "1"
|
|
try:
|
|
tag = DocTagName.objects.get(pk=request.POST.get("tag"))
|
|
except DocTagName.DoesNotExist:
|
|
return HttpResponse("Invalid tag %s" % request.POST.get("tag"))
|
|
|
|
if active:
|
|
wg.unused_tags.remove(tag)
|
|
else:
|
|
wg.unused_tags.add(tag)
|
|
|
|
|
|
# put some info for the template on tags and states
|
|
unused_tags = wg.unused_tags.all().values_list('slug', flat=True)
|
|
tags = DocTagName.objects.filter(slug__in=get_tags_for_stream_id("ietf"))
|
|
for t in tags:
|
|
t.used = t.slug not in unused_tags
|
|
|
|
unused_states = wg.unused_states.all().values_list('slug', flat=True)
|
|
states = State.objects.filter(used=True, type="draft-stream-ietf")
|
|
transitions = dict((o.state, o) for o in wg.groupstatetransitions_set.all())
|
|
for s in states:
|
|
s.used = s.slug not in unused_states
|
|
s.mandatory = s.slug in MANDATORY_STATES
|
|
|
|
default_n = s.next_states.all()
|
|
if s in transitions:
|
|
n = transitions[s].next_states.all()
|
|
else:
|
|
n = default_n
|
|
|
|
s.next_states_checkboxes = [(x in n, x in default_n, x) for x in states]
|
|
s.used_next_states = [x for x in n if x.slug not in unused_states]
|
|
|
|
return render_to_response('wgchairs/manage_workflowREDESIGN.html',
|
|
{'wg': wg,
|
|
'states': states,
|
|
'tags': tags,
|
|
'selected': 'manage_workflow',
|
|
}, RequestContext(request))
|
|
|
|
|
|
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
|
manage_workflow = manage_workflowREDESIGN
|
|
|
|
def wg_shepherd_documents(request, acronym):
|
|
wg = get_object_or_404(IETFWG, group_acronym__acronym=acronym, group_type=1)
|
|
user = request.user
|
|
if not can_manage_shepherds_in_group(user, wg):
|
|
return HttpResponseForbidden('You have no permission to access this view')
|
|
current_person = get_person_for_user(user)
|
|
|
|
base_qs = InternetDraft.objects.filter(group=wg, states__type="draft", states__slug="active").select_related("status").order_by('title')
|
|
documents_no_shepherd = base_qs.filter(shepherd=None)
|
|
documents_my = base_qs.filter(shepherd=current_person)
|
|
documents_other = base_qs.exclude(shepherd=None).exclude(shepherd__pk__in=[current_person.pk, 0])
|
|
context = {
|
|
'no_shepherd': documents_no_shepherd,
|
|
'my_documents': documents_my,
|
|
'other_shepherds': documents_other,
|
|
'selected': 'manage_shepherds',
|
|
'wg': wg,
|
|
}
|
|
return render_to_response('wgchairs/wg_shepherd_documents.html', context, RequestContext(request))
|
|
|