Fix issues related to text type metadata for custom fields.

Review Request #8263 — Created June 30, 2016 and submitted — Latest diff uploaded

Information

Review Board
release-2.5.x
f4273b9...

Reviewers

There were a couple of problems, on both the front and back ends, that
prevented text types from being set and handled correctly for custom
fields.

The primary issue was that the <filename>_text_type metadata was not
being stored into the extra_data dictionary on the review request.
Investigation revealed that this item was being set correctly on the
review request draft, but was not being propagated upon publishing. The
root cause of this lies in ReviewRequestDraft.copy_fields_to_request
where changed fields are identified and their value's are copied
from draft to request. Nominally, fields only contain values and this
copying process is fine, but fields derived from BaseTextAreaField
have both a value and an associated text type metadata element. This
issue is resolved by adding a new propagate_data method to the
BaseReviewRequestField base class, which is now called in
copy_fields_to_request. This method assumes the responsibility for
copying value's from draft to review request. In BaseTextAreaField the
method is extended to also copy text type metadata.

Additionally there were a couple of problems on the front end which
prevented the Enable Markdown checkbox from always being set correctly
for custom fields. The getDraftField method in ReviewRequestEditor
has logic for handing the useExtraData case and was always getting
options.fieldID from extraData, while ignoring the fieldName
parameter passed into the function. This had the effect of always
returning the value associated with a custom field, regardless of what
data element the caller may have actually been asking for. Specifically,
this prevented the retrieval of the rich text attribute associated with
the field. Additionally in ReviewRequestEditorView.render the name of
the rich text attribute was being incorrectly set to
<fieldname>_rich_text rather than <fieldname>RichText. This was
problematic because the later naming syntax is assumed in other places
for accessing the rich text attribute. Finally, in
ReviewRequestEditorView.registerField the naming convention of the
text type field for the special case field name of 'text' was
incorrectly using text_text_type rather than text_type. All of these
problems have been resolved.

  1. Added Python unit tests which failed before the back end fixes.
    Successfully executed all unit tests.
  2. Added Javascript unit tests which failed before the front end fixes.
    Successfully executed all unit tests.
  3. Lots of manual testing with Note to Reviewers extension. Observed
    that beanbag_notefield_notes_text_type key-value pair is now correctly
    serialized to the database in extra_data, markdown text is now
    correctly rendered, and markdown checkbox state is sensible.
    Loading...