django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
33 stars 29 forks source link

feat: Modified ExtendedVersionAdminMixin to allow for the alteration of a field from cms_config #275

Closed adam-murray closed 2 years ago

adam-murray commented 2 years ago

Description

By adding extended_admin_field_modifiers to an apps cms_config, it is possible to provide a method, which can alter a field in the admin. The rationale for this is that injecting things like icons, or further information from other apps which use Versioning, can be done without monkeypatching, or forking versioning for oneself.

To alter a field, add: extended_admin_field_modifiers = {model: {field_name: method}} With model being a model which is registered with an admin class that inherits ExtendedVersionAdminMixin field_name being the name of the target field method is a method which takes (obj, field) and returns the value to be displayed

Checklist

codecov[bot] commented 2 years ago

Codecov Report

Merging #275 (24446e6) into master (0ba20b4) will increase coverage by 0.13%. The diff coverage is 93.93%.

@@            Coverage Diff             @@
##           master     #275      +/-   ##
==========================================
+ Coverage   87.30%   87.43%   +0.13%     
==========================================
  Files          29       29              
  Lines        1536     1568      +32     
  Branches      249      256       +7     
==========================================
+ Hits         1341     1371      +30     
- Misses        140      141       +1     
- Partials       55       56       +1     
Impacted Files Coverage Δ
djangocms_versioning/admin.py 86.84% <91.30%> (+0.21%) :arrow_up:
djangocms_versioning/cms_config.py 84.45% <100.00%> (+1.12%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0ba20b4...24446e6. Read the comment docs.