Skip to content

Commit

Permalink
Merge branch 'main' into task/GH-101-header-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Nov 4, 2021
2 parents 73e6190 + b9d08f8 commit 9d5c68a
Show file tree
Hide file tree
Showing 67 changed files with 1,892 additions and 86 deletions.
86 changes: 85 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,88 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Bugfix/FP-1277: Extra Margin from Container by User on Standard Template (#370)

## [3.0.7] - 2021-10-26: Hotfixes (mostly for Frontera); Rename Unused Component

### Changed

- task/FP-1260 Rename Component ReadMore to ShowMore (#376)

### Fixed

- FP-1270: Provide Header CSS that Only Docs Needs (#381)
- (UTRC) FP-1234: Add Missing Top Margin for Headings (#359)
- Quick: Complete Core fix for section header colors (#385)
- Hotfix: Local Images for Getting Started Guide (#369)
- `taccsite_custom`
- Hotfix: Frontera: White Text for Home Banner H3's (#100)
- Hotfix: Frontera: (UTRC-356) Homepage Banner Bkgd (x-overlay Mixin Syntax) (#386)

## [3.0.0] - 2021-10-18: Refactor Settings; New Sites & Plugins; v1 CSS; Themes

### Added

- Quick: A2CPS [Site] (#271, #272, #380)
- GH-245/FP-1097: v1–v2 Migration Stylesheet (#274)
- GH-73: Blockquote, Offset [...] Plugins (#275)
- Quick: Support Non-Bootstrap Link & Picture Plugins (#278)
- FP-1097: A2CPS: Add Snippets (#288)
- GH-89: (Minimal) System Monitor Plugin (a.k.a. SysMon) (#297)
- GH-298: Add "See All" Link Component (#300)
- Quick: Support Snippets & Add 1 Useful Snippet (#301)
- GH-75: Data List - Styles / Component / Plugin (#305, #308, #326, #336)
- GH-310: Breadcrumbs [...] (#311)
- GH-310: [...] Standard Template (#311)
- GH-98: Typography (#312, #314, #316, #318)
- GH-83: Callout Plugin (#324)
- GH-88: System Specs Plugin (#323, #330)
- UTRC-356: New UTRC [...] (#367, #368, TACC/Core-CMS-Resources#80)
- Quick: (UTRC-356) Add CSS Mixins for "Overlay" (#362, #368)
- GH-191: Theme (for ProTX Light Header & TACC Blue Header) (#192)
- `taccsite_custom`
- FP-1238/TACC/Core-CMS-Resources#68: Frontera: [...] Add Standard Template (TACC/Core-CMS-Resources#69)
- Quick: Frontera: Save Newsletter Snippets (TACC/Core-CMS-Resources#63)
- TACC/Core-CMS-Resources#70: ProTX & A2CPS: [...] Add Standard Template (TACC/Core-CMS-Resources#73)
- FP-1217: New UTRC Logo (TACC/Core-CMS-Resources#83)
- TACC/Core-CMS-Resources#191: ProTX: Support 'has-dark-logo' theme (TACC/Core-CMS-Resources#87)
- [Texascale: Load Blog a.k.a.] Hotfix: Texascale: Post-FP-1194 Fix (Restore Blog) (#95)

### Changed

- GH-73: [Update Sample Plugin to be Consistent with other Plugins] (#275)
- Quick: Support Variable in x-truncate CSS (#304)
- Quick: GH-253: Tweak Style Guide CSS (#325, #326)
- GH-331: Cleanup Fullwidth Template (#332)
- [Major: Split Settings and Secrets] (#341, #345, #347, #348, TACC/Core-CMS-Resources#77)
- [Quick: Add UTRC Site] (#345, #357)
- [FP-1194: Synchronize User Login between Core Portal and CMS] (#341, #346, #356)
- Quick: (UTRC-356) Migrate Banner Overlay Styles from Core (to Frontera) (#361, #368)
- `taccsite_custom`
- FP-1238/TACC/Core-CMS-Resources#68: Frontera: Cleanup Templates [...] (TACC/Core-CMS-Resources#69)
- Quick: Support & Move Snippets (TACC/Core-CMS-Resources#66)
- TACC/Core-CMS-Resources#70: ProTX & A2CPS: Cleanup Templates [...] (TACC/Core-CMS-Resources#73)

### Fixed

- GH-283/GH-284: Fix Facebook Share Bug (Smaller TACC Logo) (#283)
- Hotfix/FP-1194: Use gettext_lazy Not gettext (fixed tup-cms deploy) (#344)
- FP-1234: Add Missing Top Margin for Headings (#359)
- Hotfix: (UTRC-356) Let Banner Section Padding Match Other Sections (#363, #368)
- Hotfix: (UTRC-356) Avoid Grid Blowout (#365, #368)
- Hotfix: (UTRC-356) Darker Core Body Text (#366, #368)
- Hotfix: Static Images for Getting Started Guide (#369)
- FP-1232: Fix Inconsistent Search Bar Icon Size (#371)
- `taccsite_custom`
- TACC/Core-CMS-Resources#81: Fix Favicons Not Loading (TACC/Core-CMS-Resources#82)

### Removed

- `taccsite_custom`
- GH-89: Remove SysMon Snippet (TACC/Core-CMS-Resources#67)

## [2.5.2] - 2021-07-16: Fix Publish Bug; Texascale 2020; Polish

### Added
Expand Down Expand Up @@ -80,7 +162,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.0.0] - 2021-03-31
v2.0.0 Production release as of Mar 31, 2021.

[unreleased]: https://github.com/TACC/Core-CMS/compare/v2.5.2...HEAD
[unreleased]: https://github.com/TACC/Core-CMS/compare/v3.0.7...HEAD
[3.0.7]: https://github.com/TACC/Core-CMS/releases/tag/v3.0.7
[3.0.0]: https://github.com/TACC/Core-CMS/releases/tag/v3.0.0
[2.5.2]: https://github.com/TACC/Core-CMS/releases/tag/v2.5.2
[2.1.1]: https://github.com/TACC/Core-CMS/releases/tag/v2.1.1
[2.1.0]: https://github.com/TACC/Core-CMS/releases/tag/v2.1.0
Expand Down
Empty file.
78 changes: 78 additions & 0 deletions taccsite_cms/contrib/_docs/how-to-extend-django-cms-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# How To Extend a `djangocms-___` Plugin

These example codes extend the [`djangocms-link` plugin](https://github.com/django-cms/djangocms-link/tree/3.0.0/djangocms_link).

`.../models.py`:

```python
from djangocms_link.models import AbstractLink

from taccsite_cms.contrib.helpers import clean_for_abstract_link

class Taccsite______(AbstractLink):
"""
Components > "Article List" Model
https://confluence.tacc.utexas.edu/x/OIAjCQ
"""
# ...



# Parent

link_is_optional = True # or False

class Meta:
abstract = False

# Validate
def clean(self):
clean_for_abstract_link(__class__, self)
```

`.../cms_plugins.py`:

```python
from djangocms_link.cms_plugins import LinkPlugin

from .models import ______Preview

class ______Plugin(LinkPlugin):
# ...
render_template = 'static_article_preview.html'
def get_render_template(self, context, instance, placeholder):
return self.render_template

fieldsets = [
# ...
(_('Link'), {
'fields': (
# 'name', # to use LinkPlugin "Display name"
('external_link', 'internal_link'),
('anchor', 'target'),
)
}),
]

# Render
def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
request = context['request']

context.update({
'link_url': instance.get_link(),
'link_target': instance.target
# 'link_text': instance.name, # to use LinkPlugin "Display name"
})
return context
```

`.../templates/______.py`:

```handlebars
<a class="______" href="{{ link_url }}"
{% if link_target %}target="{{ link_target }}"{% endif %}>
<span>{{ link_text }}
</a>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# How To Override `ValidationError()` from Parent Model

Intercept Error(s):

```python
from django.core.exceptions import ValidationError

from djangocms_Xxx.models import AbstractXxx

from taccsite_cms.contrib.helpers import (
get_indices_that_start_with
)

class OurModelThatUsesXxx(AbstractXxx):
# Validate
def clean(self):
# Bypass irrelevant parent validation
try:
super().clean()
except ValidationError as err:
# Intercept single-field errors
if hasattr(err, 'error_list'):
for i in range(len(err.error_list)):
# SEE: "Find Error(s)"
# ...
# Skip error
del err.error_list[i]
# Replace error
# SEE: https://docs.djangoproject.com/en/2.2/ref/forms/validation/#raising-validationerror

# Intercept multi-field errors
if hasattr(err, 'error_dict'):
for field, errors in err.message_dict.items():
# SEE: "Find Error(s)"
# ...
# Skip error
del err.error_dict[field]
# Replace error
# SEE: https://docs.djangoproject.com/en/2.2/ref/forms/validation/#raising-validationerror

if err.messages:
raise err
```

Handle Error(s):

```python
# SEE: "Find Error(s)"
# ...

# Catch known static error
if 'Known static error string' in error:
# ...

# Catch known dynamic error
indices_to_catch = get_indices_that_start_with(
'Known dynamic error string that starts with same text',
errors
)
for i in indices_to_catch:
# ...
```
10 changes: 10 additions & 0 deletions taccsite_cms/contrib/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
TEXT_FOR_NESTED_PLUGIN_CONTENT_ADD = '\
<dl>\
<dt>To add {element},</dt>\
<dd>nest "{plugin_name}" plugin inside this plugin.</dd>\
<dt>To edit {element},</dt>\
<dd>edit existing nested "{plugin_name}" plugin.*</dd>\
</dl>\
<br />\
* If the existing content is from a plugin not nested within this one, then you should nest it inside this one instead.'

TEXT_FOR_NESTED_PLUGIN_CONTENT_SWAP = '\
<dl>\
<dt>To add {element},</dt>\
Expand Down
60 changes: 60 additions & 0 deletions taccsite_cms/contrib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,63 @@ def concat_classnames(classes):


# GH-93, GH-142, GH-133: Upcoming functions here (ease merge conflict, maybe)
# Get list of indicies of items that start with text
# SEE: https://stackoverflow.com/a/67393343/11817077
def get_indices_that_start_with(text, list):
"""
Get a list of indices of list elements that starts with given text
:rtype: list
"""
return [i for i in range(len(list)) if list[i].startswith(text)]


# Tweak validation on Django CMS `AbstractLink` for TACC

from cms.models.pluginmodel import CMSPlugin

from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _



# SEE: https://github.com/django-cms/djangocms-link/blob/3.0.0/djangocms_link/models.py#L48
def clean_for_abstract_link(model, self):
"""
Intercept and manipulate validation on `AbstractLink` so that it suits TACC's minimal subclassing of it. (To catch only parent validation errors, not custom ones, run this before any custom validation.)
Usage:
```
from taccsite_cms.contrib.helpers import clean_for_abstract_link
# Validate
def clean(self):
clean_for_abstract_link(__class__, self)
...
```
"""

# Bypass irrelevant parent validation
# SEE: ./_docs/how-to-override-validation-error-from-parent-model.md
try:
super(model, self).clean()
except ValidationError as err:
# Intercept multi-field errors
if hasattr(err, 'error_dict'):
for field, errors in err.message_dict.items():
# Reduce verbosity of original error message
# FAQ: Original error message assumes more fields exist
indices = get_indices_that_start_with(
'Only one of ', errors
)
for i in indices:
err.error_dict[field] = ValidationError(
_('Only one of External link or Internal link may be given.'), code='invalid')

if len(err.messages):
raise err

# Get name of field from a given model

# SEE: https://stackoverflow.com/a/14498938/11817077
def get_model_field_name(model, field_name):
model_field_name = model._meta.get_field(field_name).verbose_name.title()

return model_field_name
Empty file.
66 changes: 66 additions & 0 deletions taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _

from taccsite_cms.contrib.helpers import concat_classnames
from taccsite_cms.contrib.taccsite_offset.cms_plugins import get_direction_classname

from .models import TaccsiteBlockquote

@plugin_pool.register_plugin
class TaccsiteBlockquotePlugin(CMSPluginBase):
"""
Components > "Blockquote" Plugin
https://confluence.tacc.utexas.edu/x/FIEjCQ
"""
module = 'TACC Site'
model = TaccsiteBlockquote
name = _('Blockquote')
render_template = 'blockquote.html'

cache = True
text_enabled = True
allow_children = False

fieldsets = [
(None, {
'fields': (
'text',
'origin',
'use_cite',
)
}),
(_('Citation'), {
'classes': ('collapse',),
'fields': (
'cite_person',
('cite_text', 'cite_url'),
)
}),
(_('Layout'), {
'fields': (
'offset',
)
}),
(_('Advanced settings'), {
'classes': ('collapse',),
'fields': (
'attributes',
)
}),
]

# Render

def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
request = context['request']

classes = concat_classnames([
's-blockquote',
get_direction_classname(instance.offset),
instance.attributes.get('class'),
])
instance.attributes['class'] = classes

return context
Loading

0 comments on commit 9d5c68a

Please sign in to comment.