Merged in [15111] from rjsparks@nostrum.com:
Removed the \'replaces\' functionality from /secr/drafts. Addresses part of #2513.
- Legacy-Id: 15117
Note: SVN reference [15111] has been migrated to Git commit c3241bddac
This commit is contained in:
parent
362a03ff11
commit
9fd5d104c7
|
@ -4,7 +4,7 @@ import os
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from ietf.doc.models import Document, DocAlias, State
|
from ietf.doc.models import Document, State
|
||||||
from ietf.name.models import IntendedStdLevelName
|
from ietf.name.models import IntendedStdLevelName
|
||||||
from ietf.group.models import Group
|
from ietf.group.models import Group
|
||||||
from ietf.person.models import Person, Email
|
from ietf.person.models import Person, Email
|
||||||
|
@ -239,26 +239,6 @@ class ExtendForm(forms.Form):
|
||||||
action = forms.CharField(max_length=255, widget=forms.HiddenInput(),initial='extend')
|
action = forms.CharField(max_length=255, widget=forms.HiddenInput(),initial='extend')
|
||||||
expiration_date = forms.DateField()
|
expiration_date = forms.DateField()
|
||||||
|
|
||||||
class ReplaceForm(forms.Form):
|
|
||||||
replaced = AliasModelChoiceField(DocAlias.objects.none(),empty_label=None,help_text='This document may have more than one alias. Be sure to select the correct alias to replace.')
|
|
||||||
replaced_by = forms.CharField(max_length=100,help_text='Enter the filename of the Draft which replaces this one.')
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.draft = kwargs.pop('draft')
|
|
||||||
super(ReplaceForm, self).__init__(*args, **kwargs)
|
|
||||||
self.fields['replaced'].queryset = DocAlias.objects.filter(document=self.draft)
|
|
||||||
|
|
||||||
# field must contain filename of existing draft
|
|
||||||
def clean_replaced_by(self):
|
|
||||||
name = self.cleaned_data.get('replaced_by', '')
|
|
||||||
try:
|
|
||||||
doc = Document.objects.get(name=name)
|
|
||||||
except Document.DoesNotExist:
|
|
||||||
raise forms.ValidationError("ERROR: Draft does not exist: %s" % name)
|
|
||||||
if name == self.draft.name:
|
|
||||||
raise forms.ValidationError("ERROR: A draft can't replace itself")
|
|
||||||
return doc
|
|
||||||
|
|
||||||
class BaseRevisionModelForm(forms.ModelForm):
|
class BaseRevisionModelForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Document
|
model = Document
|
||||||
|
|
|
@ -331,40 +331,6 @@ class SecrDraftsTestCase(TestCase):
|
||||||
draft = Document.objects.get(name=draft.name)
|
draft = Document.objects.get(name=draft.name)
|
||||||
self.assertTrue(draft.get_state_slug('draft') == 'ietf-rm')
|
self.assertTrue(draft.get_state_slug('draft') == 'ietf-rm')
|
||||||
|
|
||||||
def test_replace(self):
|
|
||||||
draft = make_test_data()
|
|
||||||
other_draft = Document.objects.filter(type='draft').exclude(name=draft.name).first()
|
|
||||||
url = urlreverse('ietf.secr.drafts.views.replace', kwargs={'id':draft.name})
|
|
||||||
email_url = urlreverse('ietf.secr.drafts.views.email', kwargs={'id':draft.name})
|
|
||||||
confirm_url = urlreverse('ietf.secr.drafts.views.confirm', kwargs={'id':draft.name})
|
|
||||||
do_action_url = urlreverse('ietf.secr.drafts.views.do_action', kwargs={'id':draft.name})
|
|
||||||
view_url = urlreverse('ietf.secr.drafts.views.view', kwargs={'id':draft.name})
|
|
||||||
self.client.login(username="secretary", password="secretary+password")
|
|
||||||
response = self.client.get(url)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
get_data = {
|
|
||||||
'action': 'replace',
|
|
||||||
'replaced': draft.name,
|
|
||||||
'replaced_by': other_draft.name,
|
|
||||||
}
|
|
||||||
post_data = {
|
|
||||||
'action': 'replace',
|
|
||||||
'replaced': draft.name,
|
|
||||||
'replaced_by': other_draft.name,
|
|
||||||
'to': 'john@example.com',
|
|
||||||
'cc': 'joe@example.com',
|
|
||||||
'subject': 'test',
|
|
||||||
'body': 'draft resurrected',
|
|
||||||
'submit': 'Save'
|
|
||||||
}
|
|
||||||
response = self.client.get(email_url + '?' + urlencode(get_data))
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
response = self.client.post(confirm_url, post_data)
|
|
||||||
response = self.client.post(do_action_url, post_data)
|
|
||||||
self.assertRedirects(response, view_url)
|
|
||||||
draft = Document.objects.get(name=draft.name)
|
|
||||||
self.assertTrue(draft.get_state_slug('draft') == 'repl')
|
|
||||||
|
|
||||||
def test_authors(self):
|
def test_authors(self):
|
||||||
draft = DocumentFactory()
|
draft = DocumentFactory()
|
||||||
person = PersonFactory()
|
person = PersonFactory()
|
||||||
|
|
|
@ -19,7 +19,6 @@ urlpatterns = [
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/extend/$', views.extend),
|
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/extend/$', views.extend),
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/email/$', views.email),
|
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/email/$', views.email),
|
||||||
# url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/makerfc/$', views.makerfc), # Not used any more
|
# url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/makerfc/$', views.makerfc), # Not used any more
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/replace/$', views.replace),
|
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/revision/$', views.revision),
|
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/revision/$', views.revision),
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/update/$', views.update),
|
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/update/$', views.update),
|
||||||
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/withdraw/$', views.withdraw),
|
url(r'^(?P<id>[A-Za-z0-9._\-\+]+)/withdraw/$', views.withdraw),
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.shortcuts import render, get_object_or_404, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
|
|
||||||
from ietf.doc.models import Document, DocumentAuthor, DocAlias, DocRelationshipName, RelatedDocument, State
|
from ietf.doc.models import Document, DocumentAuthor, DocAlias, State
|
||||||
from ietf.doc.models import DocEvent, NewRevisionDocEvent
|
from ietf.doc.models import DocEvent, NewRevisionDocEvent
|
||||||
from ietf.doc.utils import add_state_change_event
|
from ietf.doc.utils import add_state_change_event
|
||||||
from ietf.ietfauth.utils import role_required
|
from ietf.ietfauth.utils import role_required
|
||||||
|
@ -20,7 +20,7 @@ from ietf.name.models import StreamName
|
||||||
from ietf.person.models import Person
|
from ietf.person.models import Person
|
||||||
from ietf.secr.drafts.email import announcement_from_form, get_email_initial
|
from ietf.secr.drafts.email import announcement_from_form, get_email_initial
|
||||||
from ietf.secr.drafts.forms import ( AddModelForm, AuthorForm, BaseRevisionModelForm, EditModelForm,
|
from ietf.secr.drafts.forms import ( AddModelForm, AuthorForm, BaseRevisionModelForm, EditModelForm,
|
||||||
EmailForm, ExtendForm, ReplaceForm, RevisionModelForm,
|
EmailForm, ExtendForm, RevisionModelForm,
|
||||||
SearchForm, UploadForm, WithdrawForm )
|
SearchForm, UploadForm, WithdrawForm )
|
||||||
from ietf.secr.utils.ams_utils import get_base
|
from ietf.secr.utils.ams_utils import get_base
|
||||||
from ietf.secr.utils.document import get_rfc_num, get_start_date
|
from ietf.secr.utils.document import get_rfc_num, get_start_date
|
||||||
|
@ -193,41 +193,6 @@ def do_extend(draft, request):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def do_replace(draft, request):
|
|
||||||
'Perform document replace'
|
|
||||||
|
|
||||||
replaced = DocAlias.objects.get(name=request.POST.get('replaced')) # a DocAlias
|
|
||||||
replaced_by = Document.objects.get(name=request.POST.get('replaced_by')) # a Document
|
|
||||||
|
|
||||||
# create relationship
|
|
||||||
RelatedDocument.objects.create(source=replaced_by,
|
|
||||||
target=replaced,
|
|
||||||
relationship=DocRelationshipName.objects.get(slug='replaces'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
draft.set_state(State.objects.get(type="draft", slug="repl"))
|
|
||||||
|
|
||||||
e = DocEvent.objects.create(
|
|
||||||
type='changed_document',
|
|
||||||
by=request.user.person,
|
|
||||||
doc=replaced_by,
|
|
||||||
rev=replaced_by.rev,
|
|
||||||
time=draft.time,
|
|
||||||
desc='This document now replaces <b>%s</b>' % replaced,
|
|
||||||
)
|
|
||||||
|
|
||||||
draft.save_with_history([e])
|
|
||||||
|
|
||||||
# move replaced document to archive
|
|
||||||
archive_draft_files(replaced.document.name + '-' + replaced.document.rev)
|
|
||||||
|
|
||||||
# send announcement
|
|
||||||
form = EmailForm(request.POST)
|
|
||||||
announcement_from_form(form.data,by=request.user.person)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def do_resurrect(draft, request):
|
def do_resurrect(draft, request):
|
||||||
'''
|
'''
|
||||||
Actions
|
Actions
|
||||||
|
@ -667,8 +632,6 @@ def do_action(request, id):
|
||||||
func = do_revision
|
func = do_revision
|
||||||
elif action == 'resurrect':
|
elif action == 'resurrect':
|
||||||
func = do_resurrect
|
func = do_resurrect
|
||||||
elif action == 'replace':
|
|
||||||
func = do_replace
|
|
||||||
elif action == 'update':
|
elif action == 'update':
|
||||||
func = do_update_announce
|
func = do_update_announce
|
||||||
elif action == 'extend':
|
elif action == 'extend':
|
||||||
|
@ -900,42 +863,6 @@ def nudge_report(request):
|
||||||
'docs': docs},
|
'docs': docs},
|
||||||
)
|
)
|
||||||
|
|
||||||
@role_required('Secretariat')
|
|
||||||
def replace(request, id):
|
|
||||||
'''
|
|
||||||
This view handles replacing one Internet-Draft with another
|
|
||||||
Prerequisites: draft must be active
|
|
||||||
Input: replacement draft filename
|
|
||||||
|
|
||||||
# TODO: support two different replaced messages in email
|
|
||||||
'''
|
|
||||||
|
|
||||||
draft = get_object_or_404(Document, name=id)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
button_text = request.POST.get('submit', '')
|
|
||||||
if button_text == 'Cancel':
|
|
||||||
return redirect('ietf.secr.drafts.views.view', id=id)
|
|
||||||
|
|
||||||
form = ReplaceForm(request.POST, draft=draft)
|
|
||||||
if form.is_valid():
|
|
||||||
#params = form.cleaned_data
|
|
||||||
params = {}
|
|
||||||
params['replaced'] = form.data['replaced']
|
|
||||||
params['replaced_by'] = form.data['replaced_by']
|
|
||||||
params['action'] = 'replace'
|
|
||||||
url = reverse('ietf.secr.drafts.views.email', kwargs={'id':id})
|
|
||||||
url = url + '?' + urlencode(params)
|
|
||||||
return redirect(url)
|
|
||||||
|
|
||||||
else:
|
|
||||||
form = ReplaceForm(draft=draft)
|
|
||||||
|
|
||||||
return render(request, 'drafts/replace.html', {
|
|
||||||
'form': form,
|
|
||||||
'draft': draft},
|
|
||||||
)
|
|
||||||
|
|
||||||
@role_required('Secretariat')
|
@role_required('Secretariat')
|
||||||
def revision(request, id):
|
def revision(request, id):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
{% extends "base_site.html" %}
|
|
||||||
{% load staticfiles %}
|
|
||||||
|
|
||||||
{% block title %}Drafts - Replace{% endblock %}
|
|
||||||
|
|
||||||
{% block extrahead %}{{ block.super }}
|
|
||||||
<script type="text/javascript" src="{% static 'secr/js/utils.js' %}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block breadcrumbs %}{{ block.super }}
|
|
||||||
» <a href="../../">Drafts</a>
|
|
||||||
» <a href="../">{{ draft.name }}</a>
|
|
||||||
» Replace
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div class="module draft-container">
|
|
||||||
<h2>Draft - Replace</h2>
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">{% csrf_token %}
|
|
||||||
<table class="full-width">
|
|
||||||
{{ form.as_table }}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% include "includes/buttons_save_cancel.html" %}
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div> <!-- module -->
|
|
||||||
|
|
||||||
{% endblock %}
|
|
|
@ -83,7 +83,6 @@
|
||||||
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='revision/'">New Revision</button></li>
|
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='revision/'">New Revision</button></li>
|
||||||
<li><button {% if is_expired %}{% else %}disabled="disabled"{% endif %}onclick="window.location='update/'">Update Expired</button></li>
|
<li><button {% if is_expired %}{% else %}disabled="disabled"{% endif %}onclick="window.location='update/'">Update Expired</button></li>
|
||||||
<li><button {% if is_expired or is_withdrawn %}{% else %}disabled="disabled"{% endif %}onclick="window.location='{% url "ietf.secr.drafts.views.email" id=draft.name %}?action=resurrect'">Resurrect</button></li>
|
<li><button {% if is_expired or is_withdrawn %}{% else %}disabled="disabled"{% endif %}onclick="window.location='{% url "ietf.secr.drafts.views.email" id=draft.name %}?action=resurrect'">Resurrect</button></li>
|
||||||
<li><button {% if is_active or is_expired %}{% else %}disabled="disabled"{% endif %}onclick="window.location='replace/'">Replace</button></li>
|
|
||||||
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='extend/'">Extend Expiry</button></li>
|
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='extend/'">Extend Expiry</button></li>
|
||||||
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='withdraw/'">Withdraw</button></li>
|
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='withdraw/'">Withdraw</button></li>
|
||||||
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='announce/'">Announcement</button></li>
|
<li><button {% if is_active %}{% else %}disabled="disabled"{% endif %}onclick="window.location='announce/'">Announcement</button></li>
|
||||||
|
|
Loading…
Reference in a new issue