Update the diffviewer.admin module for better performance and compatibility.
Review Request #10842 — Created Jan. 21, 2020 and submitted — Latest diff uploaded
When DVCS was implemented, the
diffviewermodel gained a lot of new
models, and with those cameModelAdminandInlineModelAdmin
definitions. Many of these were making use of the default dropdown
fields for relations, which wouldn't scale in production. To solve that,
we needed to add more fields toraw_id_fields. On top of that, we
never actually had this set for the inlines, meaning we needed to do
that there as well.This change takes the approach of defining all the attributes common to
both theModelAdminandInlineModelAdminfor each model type into
private_*Commonclasses, and then mixing them in to both classes for
the model. This ensures we don't regress in the inlines, and speeds up
loading all around.It also implements some future-proofing for the
diffandparent_diff
fields for display of aFileDiff, removingallow_tagsand replacing
with a return ofSafeTextfor each. This will be needed eventually for
Django 2.0+.I also found that we were setting the
labelattribute on both of
these, which doesn't exist.short_descriptionwas the correct
attribute to set, which we're now setting.
Tested on Django 1.6 and 1.11 with viewing a
FileDiff,DiffSet,
andDiffCommit.