Fix issues related to text type metadata for custom fields.
Review Request #8263 — Created June 30, 2016 and submitted — Latest diff uploaded
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 theextra_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 inReviewRequestDraft.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 fromBaseTextAreaField
have both a value and an associated text type metadata element. This
issue is resolved by adding a newpropagate_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. InBaseTextAreaField
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. ThegetDraftField
method inReviewRequestEditor
has logic for handing theuseExtraData
case and was always getting
options.fieldID
fromextraData
, while ignoring thefieldName
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 inReviewRequestEditorView.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 usingtext_text_type
rather thantext_type
. All of these
problems have been resolved.
- Added Python unit tests which failed before the back end fixes.
Successfully executed all unit tests.- Added Javascript unit tests which failed before the front end fixes.
Successfully executed all unit tests.- Lots of manual testing with Note to Reviewers extension. Observed
thatbeanbag_notefield_notes_text_type
key-value pair is now correctly
serialized to the database inextra_data
, markdown text is now
correctly rendered, and markdown checkbox state is sensible.