Skip to content

Static Article Plugins

W. Bomar edited this page Dec 9, 2021 · 7 revisions

Status

Archived. We will not have "Static Article Plugins"; they are too high-maintenance compared to much simpler solutions.

Intent

Support addition of news articles that originate from the TACC news site.

Ideally, we have a dynamic solution that pulls from one news site:

But this was not feasible (Summer 2021)* thus:

* Not feasible because of constraints on time, of knowledge, and from incomplete architecture.

To Do

Add Image via Child Plugin Instead of Via Fields

Instead, the image fields should be in the plugin, not via a child plugin, but a solution has not yet been implemented.

Hope for the Future

The AbstractLink model has been successfully extended:

Failed Attempt

  1. Build model so it extends AbstractPicture from djangocms-picture.
  2. Tweak model to sweep bugs under the rug.
  3. Quit when he was unable to resolve the error, TaccsiteStaticNewsArticlePreview has no field named 'cmsplugin_ptr_id' upon saving a plugin instance.
  4. Learn:

Abandoned Code

from djangocms_picture.models import AbstractPicture

# To allow user to not set image
# FAQ: Emptying the clean() method avoids picture validation
# SEE: https://github.com/django-cms/djangocms-picture/blob/3.0.0/djangocms_picture/models.py#L278
def skip_image_validation():
    pass

class TaccsiteStaticNewsArticlePreview(AbstractPicture):
    #
    # …
    #

    # Remove error-prone attribute from parent class
    # FAQ: Avoid error when running `makemigrations`:
    #      "You are trying to add a non-nullable field 'cmsplugin_ptr' […]"
    # SEE: https://github.com/django-cms/djangocms-picture/blob/3.0.0/djangocms_picture/models.py#L212
    # SEE: https://github.com/django-cms/djangocms-picture/blob/3.0.0/djangocms_picture/models.py#L234
    cmsplugin_ptr = None

    class Meta:
        abstract = False

    # Validate
    def clean(self):
        skip_image_validation()