Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP make content models swappable, closes #1160 #1935

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bors-ltd
Copy link
Contributor

(It's marked as WIP because one test fails, but it fails on the vanilla 4.3.1 too, and we can
always discuss the coding style and naming. Github is warning about a merge conflict only because I don't have a proper 4.3.1 branc to base upon.)

Any of the following models can now be swapped by your own version:

  • Page
  • RichTextPage
  • Link
  • BlogPost
  • BlogCategory
  • Form
  • FormEntry
  • Field
  • FieldEntry
  • Gallery
  • GalleryImage

So you can keep the same features and API but add fields, methods, inherit from
other classes (geo models for geo fields, third-party models...), etc.
without having to resort to model inheritance.

Just make sure you inherit from each respective abstract base class.

Contrary to my first submission, I kept the BaseXXX classes for a
smoother transition path.

I didn't change imports or references in the admin modules, I followed
UserAdmin conventions here. You'll have to explicitly register, e.g. PageAdmin
to your swapped Page model.

No docs update yet, let's first agree on code and naming conventions, what will
become the public API for users. This includes whether we provide
default values in the template project settings or in the code.

I also guess this deprecates the field injection feature, before removing it in
a future major version.

Now I wonder if I went too far. Initially I just wanted to swap the BlogPost model to inherit from GeoModel too, but this became useless with Django 2.0 (when Mezzanine will be compatible), and getting rid of the table inheritance of RichTextPage and Link may require a long deprecation path.

Besides that, it must be 100% compatible, no test changes apart from imports.

(It's marked as WIP because tests are far from passing, and we can
always discuss the coding style and naming.)

Any of the following models can now be swapped by your own version:

* Page
* RichTextPage
* Link
* BlogPost
* BlogCategory
* Form
* FormEntry
* Field
* FieldEntry
* Gallery
* GalleryImage

So you can keep the same features and API but add fields, methods, inherit from
other classes (geo models for geo fields, third-party models...), etc.
without having to resort to model inheritance.

Just make sure you inherit from each respective abstract base class.

Contrary to my first submission, I kept the BaseXXX classes for a
smoother transition path.

I didn't change imports or references in the admin modules, I followed
UserAdmin conventions here. You'll have to explicitly register, e.g.  PageAdmin
to your swapped Page model.

No docs update yet, let's first agree on code and naming conventions, what will
become the public API for users. This includes whether we provide
default values in the template project settings or in the code.

I also guess this deprecates the field injection feature, before removing it in
a future major version.

Besides that, it must be 100% compatible, no test changes apart from imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant