django-cms / djangocms-text-ckeditor

Text Plugin for django CMS using CKEditor 4
https://www.django-cms.org/en/repositories-plugins/
BSD 3-Clause "New" or "Revised" License
164 stars 186 forks source link

fix: Delay importing models.CMSPlugin in utils. #637

Closed mbi closed 1 year ago

mbi commented 1 year ago

Continuation of PR #636

As mentioned in #468, Importing html.clean_html too early prevents registering custom user models containing an HTMLField.

This solves the issue by decoupling the import of models.CMSPlugin into the relevant function calls, to allow registering the models properly.

NOTE: This lacks a proper test, as I couldn't manage to register a custom user model and define it in settings.AUTH_USER_MODEL using django-cms's app_helper mechanism. If you absolutely need a test, can you please provide guidance on how to define a custom user model, that would trigger the error (when 172e1f0348415fa80ce4b622c34587460e162afd is not present)?

codecov[bot] commented 1 year ago

Codecov Report

Merging #637 (4a86f6a) into master (9ac4c15) will increase coverage by 0.06%. The diff coverage is 72.22%.

:exclamation: Current head 4a86f6a differs from pull request most recent head 21459f6. Consider uploading reports for the commit 21459f6 to get more accurate results

@@            Coverage Diff             @@
##           master     #637      +/-   ##
==========================================
+ Coverage   69.86%   69.93%   +0.06%     
==========================================
  Files          16       16              
  Lines         448      449       +1     
  Branches       49       49              
==========================================
+ Hits          313      314       +1     
  Misses        118      118              
  Partials       17       17              
Impacted Files Coverage Δ
djangocms_text_ckeditor/utils.py 89.24% <72.22%> (+0.11%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

fsbraun commented 1 year ago

Some of the test fail due to migrations of other packages. This is fixed in #631. So do not worry about that.

Can you fix the isort issue (see linting results)? I'll merge then.

Thanks very much!!