Skip to content

Commit ce081cb

Browse files
committed
Fix 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 - Legacy-Id: 5289
1 parent 188c619 commit ce081cb

9 files changed

Lines changed: 28 additions & 23 deletions

File tree

ietf/doc/migrations/0010_cleanup_rfc_number_notes.py renamed to ietf/doc/migrations/0010_cleanup_doc_notes.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
class Migration(DataMigration):
88

99
def forwards(self, orm):
10-
# whack obsolete RFC 1234 notes (obsolete now that we got RFC alias links set up properly)
1110
for d in orm.Document.objects.filter(type="draft").exclude(note="").iterator():
12-
if re.match("^RFC\s*\d+$", d.note):
13-
# there are a couple that match without a
14-
# corresponding RFC DocAlias, but upon manual
15-
# inspection these all turn out to be mistakes in the
16-
# note (most are off-by-one in the RFC number)
17-
note = re.sub("^RFC\s*\d+$", "", d.note).strip()
11+
note = d.note
12+
13+
# get rid of HTML garbage
14+
note = note.replace("\r", "")
15+
note = note.replace("<br>", "\n")
16+
note = note.replace("&nbsp;", " ")
17+
note = note.strip()
18+
19+
# whack obsolete RFC/BCP/STD 1234 notes (obsolete now that
20+
# we got RFC alias links set up properly),
21+
# there are a couple that match without a
22+
# corresponding RFC DocAlias, but upon manual
23+
# inspection these all turn out to be mistakes in the
24+
# note (most are off-by-one in the RFC number)
25+
note = re.sub("^((STD|BCP|RFC)\s*#?\d+[\s,;]*)+", "", note).strip()
26+
27+
if note != d.note:
1828
orm.Document.objects.filter(name=d.name).update(note=note)
1929

2030
def backwards(self, orm):

ietf/idrfc/views_edit.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ def __init__(self, *args, **kwargs):
380380
self.standard_fields = [x for x in self.visible_fields() if x.name not in ('returning_item',)]
381381

382382
def clean_note(self):
383-
# note is stored munged in the database
384-
return self.cleaned_data['note'].replace('\n', '<br>').replace('\r', '').replace(' ', '&nbsp; ')
383+
return self.cleaned_data['note'].replace('\r', '').strip()
385384

386385

387386
def get_initial_notify(doc):
@@ -516,7 +515,7 @@ def diff(attr, name):
516515
area=doc.group_id,
517516
ad=doc.ad_id,
518517
notify=doc.notify,
519-
note=dehtmlify_textarea_text(doc.note),
518+
note=doc.note,
520519
telechat_date=initial_telechat_date,
521520
returning_item=initial_returning_item,
522521
)
@@ -811,15 +810,14 @@ class IESGNoteForm(forms.Form):
811810
note = forms.CharField(widget=forms.Textarea, label="IESG note", required=False)
812811

813812
def clean_note(self):
814-
# note is stored munged in the database
815-
return self.cleaned_data['note'].replace('\n', '<br>').replace('\r', '').replace(' ', '&nbsp; ')
813+
return self.cleaned_data['note'].replace('\r', '').strip()
816814

817815
@group_required("Area Director", "Secretariat")
818816
def edit_iesg_note(request, name):
819817
doc = get_object_or_404(Document, type="draft", name=name)
820818
login = request.user.get_profile()
821819

822-
initial = dict(note=dehtmlify_textarea_text(doc.note))
820+
initial = dict(note=doc.note)
823821

824822
if request.method == "POST":
825823
form = IESGNoteForm(request.POST, initial=initial)

ietf/iesg/views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ def agenda_docs(date, next_agenda):
229229
section_key = "s"+get_doc_section(id)
230230
if section_key not in res:
231231
res[section_key] = []
232-
if id.note:
233-
# TODO: Find out why this is _here_
234-
id.note = id.note.replace(u"\240",u"&nbsp;")
235232
res[section_key].append({'obj':id})
236233
return res
237234

ietf/templates/idrfc/document_draft.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
<td>IESG Note:</td>
204204
<td>
205205
<a {% if can_edit %}class="editlink" href="{% url doc_change_iesg_note name=doc.name %}"{% endif %}>
206-
{{ doc.note|default:"(None)"|format_textarea|safe }}
206+
{{ doc.note|default:"(None)"|linebreaksbr }}
207207
</a>
208208
</td>
209209
</tr>

ietf/templates/idtracker/document_entry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
{% if doc.primary_flag %}
2121
<tr><td></td><td>Token:</td><td><a href="mailto:{{ doc.token_email|urlencode }}">{{ doc.token_name }}</a></td></tr>
2222
{% if doc.note %}
23-
<tr><td></td><td>Note:</td><td>{{ doc.note|safe|urlize }}</td></tr>
23+
<tr><td></td><td>Note:</td><td>{{ doc.note|linebreaksbr|urlize }}</td></tr>
2424
{% endif %}
2525
{% endif %}

ietf/templates/iesg/agenda_conflict_doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ <h3>{{ title2 }}</h3>
8383
<a href="http://www.ietf.org/id/{{doc.obj.conflictdoc.name}}-{{doc.obj.conflictdoc.rev}}.txt">[txt]</a>
8484
<br/>{{ doc.obj.conflictdoc.title|escape }} ({{doc.obj.conflictdoc.stream}}: {{ doc.obj.conflictdoc.intended_std_level }})
8585
{% if doc.obj.conflictdoc.note %}
86-
<br/>Note: {{ doc.obj.conflictdoc.note|unescape }}
86+
<br/>Note: {{ doc.obj.conflictdoc.note|linebreaksbr }}
8787
{% endif %}
8888

8989
{% if doc.obj.conflictdoc.ipr %}

ietf/templates/iesg/agenda_doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h3>{{ title2 }}</h3>
7777

7878

7979
{% if doc.obj.note %}
80-
<br/>Note: {{ doc.obj.note|unescape }}
80+
<br/>Note: {{ doc.obj.note|linebreaksbr }}
8181
{% endif %}
8282

8383
{% if doc.obj.ipr %}

ietf/templates/iesg/scribe_conflict_doc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
{{ doc.obj.conflictdoc.title|escape }} ({{doc.obj.conflictdoc.stream}}: {{ doc.obj.conflictdoc.intended_std_level }})
5252
<br><a href="{% url doc_view name=doc.obj.conflictdoc.canonical_name %}">{{doc.obj.conflictdoc.canonical_name}}</a>
5353
<a href="http://www.ietf.org/id/{{doc.obj.conflictdoc.canonical_name}}-{{doc.obj.conflictdoc.rev}}.txt">[txt]</a>
54-
{% if doc.obj.conflictdoc.note %}{# note: note is not escaped #}
55-
<br>Note: {{ doc.obj.conflictdoc.note|safe }}
54+
{% if doc.obj.conflictdoc.note %}
55+
<br>Note: {{ doc.obj.conflictdoc.note|linebreaksbr }}
5656
{% endif %}
5757
{% for ipr in doc.obj.conflictdoc.ipr %}
5858
{% ifequal ipr.ipr.status 1 %}

ietf/templates/iesg/scribe_doc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
{% endwith %}
5656
<br>Token: {{ doc.obj.ad.plain_name|escape }} ({{doc.obj.area_acronym}} area)
5757
{% if doc.obj.note %}
58-
<br>Note: {{ doc.obj.note }}
58+
<br>Note: {{ doc.obj.note|linebreaksbr }}
5959
{% endif %}
6060
{% for ipr in doc.obj.ipr %}
6161
{% ifequal ipr.ipr.status 1 %}

0 commit comments

Comments
 (0)