Consolidate and fix building of RB.FileAttachment model attributes.

Review Request #10914 — Created Feb. 24, 2020 and submitted

Information

Review Board
release-4.0.x

Reviewers

We build attributes to pass to RB.FileAttachment when building the
page model data (in {% reviewable_page_model_data %}) and when
rendering the change description for any changed file attachments.
This code was duplicated. The former used Python to generate the data.
The latter used a template (and had a typo, resulting in a bad
filename).

This change consolidates this by adding a method to
FileAttachmentsField that returns a dictionary of attribute data. Both
the page model data and the change description rendering make use of
this, ensuring we have a single place to make changes.

This also speeds up rendering of change descriptions by simplifying that
template and avoiding all the extra jsescape calls.

Unit tests passed.

Manually tested pages with file attachments and change descriptions.

Summary ID
Consolidate and fix building of RB.FileAttachment model attributes.
We build attributes to pass to `RB.FileAttachment` when building the page model data (in `{% reviewable_page_model_data %}`) and when rendering the change description for any changed file attachments. This code was duplicated. The former used Python to generate the data. The latter used a template (and had a typo, resulting in a bad filename). This change consolidates this by adding a method to `FileAttachmentsField` that returns a dictionary of attribute data. Both the page model data and the change description rendering make use of this, ensuring we have a single place to make changes. This speeds up rendering of change descriptions by simplifying that template and avoiding all the extra `jsescape` calls.
6b8a3bdae97745edf2e44c256d82d097c9c03fa7
Description From Last Updated

F821 undefined name 'review_request'

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (40febf7)
Loading...