|
16 | 16 | import debug # pyflakes:ignore |
17 | 17 |
|
18 | 18 | from ietf.doc.models import ( Document, State, DocEvent, BallotDocEvent, BallotPositionDocEvent, |
19 | | - LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS ) |
| 19 | + LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS, RelatedDocument ) |
20 | 20 | from ietf.doc.utils import ( add_state_change_event, close_ballot, close_open_ballots, |
21 | 21 | create_ballot_if_not_open, update_telechat ) |
22 | 22 | from ietf.doc.mails import ( email_ballot_deferred, email_ballot_undeferred, |
@@ -768,6 +768,7 @@ def ballot_approvaltext(request, name): |
768 | 768 | need_intended_status=need_intended_status, |
769 | 769 | )) |
770 | 770 |
|
| 771 | + |
771 | 772 | @role_required('Secretariat') |
772 | 773 | def approve_ballot(request, name): |
773 | 774 | """Approve ballot, sending out announcement, changing state.""" |
@@ -871,14 +872,76 @@ def approve_ballot(request, name): |
871 | 872 | msg.save() |
872 | 873 | msg.related_docs.add(doc) |
873 | 874 |
|
874 | | - return HttpResponseRedirect(doc.get_absolute_url()) |
| 875 | + downrefs = [rel for rel in doc.relateddocument_set.all() if rel.is_downref() and not rel.is_approved_downref()] |
| 876 | + if not downrefs: |
| 877 | + return HttpResponseRedirect(doc.get_absolute_url()) |
| 878 | + else: |
| 879 | + return HttpResponseRedirect(doc.get_absolute_url()+'edit/approvedownrefs/') |
875 | 880 |
|
876 | 881 | return render(request, 'doc/ballot/approve_ballot.html', |
877 | 882 | dict(doc=doc, |
878 | 883 | action=action, |
879 | 884 | announcement=announcement)) |
880 | 885 |
|
881 | 886 |
|
| 887 | +class ApproveDownrefsForm(forms.Form): |
| 888 | + checkboxes = forms.ModelMultipleChoiceField( |
| 889 | + widget = forms.CheckboxSelectMultiple, |
| 890 | + queryset = RelatedDocument.objects.none(), ) |
| 891 | + |
| 892 | + |
| 893 | + def __init__(self, queryset, *args, **kwargs): |
| 894 | + super(ApproveDownrefsForm, self).__init__(*args, **kwargs) |
| 895 | + self.fields['checkboxes'].queryset = queryset |
| 896 | + |
| 897 | + def clean(self): |
| 898 | + if 'checkboxes' not in self.cleaned_data: |
| 899 | + raise forms.ValidationError("No RFCs were selected") |
| 900 | + |
| 901 | +@role_required('Secretariat') |
| 902 | +def approve_downrefs(request, name): |
| 903 | + """Document ballot was just approved; add the checked downwared references to the downref registry.""" |
| 904 | + doc = get_object_or_404(Document, docalias__name=name) |
| 905 | + if not doc.get_state("draft-iesg"): |
| 906 | + raise Http404 |
| 907 | + |
| 908 | + login = request.user.person |
| 909 | + |
| 910 | + downrefs_to_rfc = [rel for rel in doc.relateddocument_set.all() if rel.is_downref() and not rel.is_approved_downref() and rel.target.document.is_rfc()] |
| 911 | + |
| 912 | + downrefs_to_rfc_qs = RelatedDocument.objects.filter(pk__in=[r.pk for r in downrefs_to_rfc]) |
| 913 | + |
| 914 | + last_call_text = doc.latest_event(WriteupDocEvent, type="changed_last_call_text").text.strip() |
| 915 | + |
| 916 | + if request.method == 'POST': |
| 917 | + form = ApproveDownrefsForm(downrefs_to_rfc_qs, request.POST) |
| 918 | + if form.is_valid(): |
| 919 | + for rel in form.cleaned_data['checkboxes']: |
| 920 | + RelatedDocument.objects.create(source=rel.source, |
| 921 | + target=rel.target, relationship_id='downref-approval') |
| 922 | + c = DocEvent(type="downref_approved", doc=rel.source, |
| 923 | + rev=rel.source.rev, by=login) |
| 924 | + c.desc = "Downref to RFC %s approved by Last Call for %s-%s" % ( |
| 925 | + rel.target.document.rfc_number(), rel.source, rel.source.rev) |
| 926 | + c.save() |
| 927 | + c = DocEvent(type="downref_approved", doc=rel.target.document, |
| 928 | + rev=rel.target.document.rev, by=login) |
| 929 | + c.desc = "Downref to RFC %s approved by Last Call for %s-%s" % ( |
| 930 | + rel.target.document.rfc_number(), rel.source, rel.source.rev) |
| 931 | + c.save() |
| 932 | + |
| 933 | + return HttpResponseRedirect(doc.get_absolute_url()) |
| 934 | + |
| 935 | + else: |
| 936 | + form = ApproveDownrefsForm(downrefs_to_rfc_qs) |
| 937 | + |
| 938 | + return render(request, 'doc/ballot/approve_downrefs.html', |
| 939 | + dict(doc=doc, |
| 940 | + approve_downrefs_form=form, |
| 941 | + last_call_text=last_call_text, |
| 942 | + downrefs_to_rfc=downrefs_to_rfc)) |
| 943 | + |
| 944 | + |
882 | 945 | class MakeLastCallForm(forms.Form): |
883 | 946 | last_call_sent_date = forms.DateField(required=True) |
884 | 947 | last_call_expiration_date = forms.DateField(required=True) |
|
0 commit comments