|
28 | 28 | from ietf.doc.models import Document |
29 | 29 | from ietf.group.models import Group |
30 | 30 | from ietf.ietfauth.utils import has_role |
31 | | -from ietf.doc.fields import SearchableDocAliasesField |
| 31 | +from ietf.doc.fields import SearchableDocumentsField |
32 | 32 | from ietf.doc.models import DocAlias |
33 | 33 | from ietf.ipr.mail import utc_from_string |
34 | 34 | from ietf.meeting.models import Meeting |
@@ -683,37 +683,32 @@ def clean(self): |
683 | 683 | if self.cleaned_data['replaces']: |
684 | 684 | names_replaced = [s.strip() for s in self.cleaned_data['replaces'].split(',')] |
685 | 685 | self.cleaned_data['replaces'] = ','.join(names_replaced) |
686 | | - aliases_replaced = DocAlias.objects.filter(name__in=names_replaced) |
687 | | - if len(names_replaced) != len(aliases_replaced): |
688 | | - known_names = aliases_replaced.values_list('name', flat=True) |
| 686 | + documents_replaced = Document.objects.filter(name__in=names_replaced) |
| 687 | + if len(names_replaced) != len(documents_replaced): |
| 688 | + known_names = documents_replaced.values_list('name', flat=True) |
689 | 689 | unknown_names = [n for n in names_replaced if n not in known_names] |
690 | 690 | self.add_error( |
691 | 691 | 'replaces', |
692 | 692 | forms.ValidationError( |
693 | 693 | 'Unknown Internet-Draft name(s): ' + ', '.join(unknown_names) |
694 | 694 | ), |
695 | 695 | ) |
696 | | - for alias in aliases_replaced: |
697 | | - if alias.document.name == self.filename: |
| 696 | + for doc in documents_replaced: |
| 697 | + if doc.name == self.filename: |
698 | 698 | self.add_error( |
699 | 699 | 'replaces', |
700 | 700 | forms.ValidationError("An Internet-Draft cannot replace itself"), |
701 | 701 | ) |
702 | | - elif alias.document.type_id != "draft": |
| 702 | + elif doc.type_id != "draft": |
703 | 703 | self.add_error( |
704 | 704 | 'replaces', |
705 | 705 | forms.ValidationError("An Internet-Draft can only replace another Internet-Draft"), |
706 | 706 | ) |
707 | | - elif alias.document.get_state_slug() == "rfc": |
708 | | - self.add_error( |
709 | | - 'replaces', |
710 | | - forms.ValidationError("An Internet-Draft cannot replace an RFC"), |
711 | | - ) |
712 | | - elif alias.document.get_state_slug('draft-iesg') in ('approved', 'ann', 'rfcqueue'): |
| 707 | + elif doc.get_state_slug('draft-iesg') in ('approved', 'ann', 'rfcqueue'): |
713 | 708 | self.add_error( |
714 | 709 | 'replaces', |
715 | 710 | forms.ValidationError( |
716 | | - alias.name + " is approved by the IESG and cannot be replaced" |
| 711 | + doc.name + " is approved by the IESG and cannot be replaced" |
717 | 712 | ), |
718 | 713 | ) |
719 | 714 | return cleaned_data |
@@ -754,22 +749,20 @@ def cleaned_line(self): |
754 | 749 | return line |
755 | 750 |
|
756 | 751 | class ReplacesForm(forms.Form): |
757 | | - replaces = SearchableDocAliasesField(required=False, help_text="Any Internet-Drafts that this document replaces (approval required for replacing an Internet-Draft you are not the author of)") |
| 752 | + replaces = SearchableDocumentsField(required=False, help_text="Any Internet-Drafts that this document replaces (approval required for replacing an Internet-Draft you are not the author of)") |
758 | 753 |
|
759 | 754 | def __init__(self, *args, **kwargs): |
760 | 755 | self.name = kwargs.pop("name") |
761 | 756 | super(ReplacesForm, self).__init__(*args, **kwargs) |
762 | 757 |
|
763 | 758 | def clean_replaces(self): |
764 | | - for alias in self.cleaned_data['replaces']: |
765 | | - if alias.document.name == self.name: |
| 759 | + for doc in self.cleaned_data['replaces']: |
| 760 | + if doc.name == self.name: |
766 | 761 | raise forms.ValidationError("An Internet-Draft cannot replace itself.") |
767 | | - if alias.document.type_id != "draft": |
| 762 | + if doc.type_id != "draft": |
768 | 763 | raise forms.ValidationError("An Internet-Draft can only replace another Internet-Draft") |
769 | | - if alias.document.get_state_slug() == "rfc": |
770 | | - raise forms.ValidationError("An Internet-Draft cannot replace an RFC") |
771 | | - if alias.document.get_state_slug('draft-iesg') in ('approved','ann','rfcqueue'): |
772 | | - raise forms.ValidationError(alias.name+" is approved by the IESG and cannot be replaced") |
| 764 | + if doc.get_state_slug('draft-iesg') in ('approved','ann','rfcqueue'): |
| 765 | + raise forms.ValidationError(doc.name+" is approved by the IESG and cannot be replaced") |
773 | 766 | return self.cleaned_data['replaces'] |
774 | 767 |
|
775 | 768 | class EditSubmissionForm(forms.ModelForm): |
|
0 commit comments