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
diffviewer
model gained a lot of new
models, and with those cameModelAdmin
andInlineModelAdmin
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 theModelAdmin
andInlineModelAdmin
for each model type into
private_*Common
classes, 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
diff
andparent_diff
fields for display of aFileDiff
, removingallow_tags
and replacing
with a return ofSafeText
for each. This will be needed eventually for
Django 2.0+.I also found that we were setting the
label
attribute on both of
these, which doesn't exist.short_description
was the correct
attribute to set, which we're now setting.
Tested on Django 1.6 and 1.11 with viewing a
FileDiff
,DiffSet
,
andDiffCommit
.