Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/gh-999-editable-header-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Plan for [#999 Let CMS Admin Edit Header](https://github.com/TACC/Core-CMS/issue
- **Render:** Standard Picture template at `{% static_placeholder "header-content" %}`.
- **Empty placeholder:** `or` fallback [`header_logo_via_settings.html`](taccsite_cms/templates/header_logo_via_settings.html) (`LOGO` / `PORTAL_LOGO`).
- **Branding images (PR 3):** nested Pictures under TACC Header Branding — not top-level.
- **Follow-up:** Match `PORTAL_LOGO` / `header_logo_via_settings.html` defaults to Header logo form defaults (margin, height, link) and Core-Styles — deferred until willing to test Core-Styles.

## PR stack

Expand Down
3 changes: 3 additions & 0 deletions taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from djangocms_picture.cms_plugins import PicturePlugin
from djangocms_picture.models import Picture

from .forms import HeaderLogoForm

HEADER_LOGO_ELEMENT_ID = 'header-logo'


Expand All @@ -15,6 +17,7 @@ class HeaderLogoPlugin(PicturePlugin):
Full Picture plugin; default id="header-logo" when not set in Attributes.
"""
model = Picture
form = HeaderLogoForm
module = _('TACC Header')
name = _('Header logo')

Expand Down
34 changes: 34 additions & 0 deletions taccsite_cms/contrib/taccsite_header_logo/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from cms.models import Page
from django.contrib.sites.models import Site
from djangocms_picture.forms import PictureForm


def default_home_page():
site = Site.objects.get_current()
return Page.objects.filter(is_home=True, node__site=site).first()


class HeaderLogoForm(PictureForm):
"""
Defaults for new Header logo plugins only (admin add form).

With a link, TACC default picture.html puts Attributes (e.g. class mr-5) on
the <a>, not the <img>.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance.pk:
return

home = default_home_page()
if home is not None:
self.initial.setdefault('link_page', home.pk)

self.initial.setdefault('height', 50)
self.initial.setdefault('use_no_cropping', True)
self.initial.setdefault('use_automatic_scaling', False)

attributes = dict(self.initial.get('attributes') or {})
attributes.setdefault('class', 'mr-5')
self.initial['attributes'] = attributes