From 6d69a561007512b7397fe78d6f46914b7682cc04 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 12 Apr 2021 18:46:53 -0500 Subject: [PATCH 01/92] GH-73: WIP Blockquote Plugin from Greet Plugin --- .../contrib/taccsite_blockquote/__init__.py | 0 .../taccsite_blockquote/cms_plugins.py | 39 +++++++++++++++++++ .../migrations/0001_initial.py | 27 +++++++++++++ .../migrations/__init__.py | 0 .../contrib/taccsite_blockquote/models.py | 13 +++++++ .../templates/blockquote.html | 8 ++++ 6 files changed, 87 insertions(+) create mode 100644 taccsite_cms/contrib/taccsite_blockquote/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/models.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html diff --git a/taccsite_cms/contrib/taccsite_blockquote/__init__.py b/taccsite_cms/contrib/taccsite_blockquote/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py new file mode 100644 index 000000000..93ff70eb7 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -0,0 +1,39 @@ +from cms.plugin_base import CMSPluginBase +from cms.plugin_pool import plugin_pool +from cms.models.pluginmodel import CMSPlugin +from django.utils.translation import gettext_lazy as _ + +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 = False + + def get_name(self, instance, user): + """Get name of authenticated user or the name for any guest.""" + + if user.is_authenticated: + name = user.first_name + ' ' + user.last_name + if False: + name = 'Jim' + else: + name = instance.guest_name + + return name + + def render(self, context, instance, placeholder): + context = super().render(context, instance, placeholder) + request = context['request'] + + context.update({ + 'user_name': self.get_name(instance, request.user) + }) + return context diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py new file mode 100644 index 000000000..04ff60c6c --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.16 on 2021-04-12 17:18 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ] + + operations = [ + migrations.CreateModel( + name='TaccsiteBlockquote', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_blockquote_taccsiteblockquote', serialize=False, to='cms.CMSPlugin')), + ('guest_name', models.CharField(default='Guest', max_length=50)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/__init__.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py new file mode 100644 index 000000000..d8b8b282c --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -0,0 +1,13 @@ +from cms.models.pluginmodel import CMSPlugin + +from django.db import models + +class TaccsiteBlockquote(CMSPlugin): + """ + Components > "Blockquote" Plugin + https://confluence.tacc.utexas.edu/x/FIEjCQ + """ + guest_name = models.CharField(max_length=50, default='Guest') + + def get_short_description(self): + return 'Hello, […]' diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html new file mode 100644 index 000000000..48a0d12b5 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -0,0 +1,8 @@ +
+ {{ instance.quote_content }} + {% if instance.quote_origin %} +
+ {{ instance.quote_origin }} +
+ {% endif %} +
From 4b5b5c74b5b6e1c0dc4f3f2c1cbfe4d64712cf97 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 12 Apr 2021 19:02:42 -0500 Subject: [PATCH 02/92] GH-73: Fix model desc typo --- taccsite_cms/contrib/taccsite_blockquote/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index d8b8b282c..f47b933cd 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -4,7 +4,7 @@ class TaccsiteBlockquote(CMSPlugin): """ - Components > "Blockquote" Plugin + Components > "Blockquote" Model https://confluence.tacc.utexas.edu/x/FIEjCQ """ guest_name = models.CharField(max_length=50, default='Guest') From 0260226af608deb05adfc54413b5df10a0c01d9f Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 13 Apr 2021 15:16:08 -0500 Subject: [PATCH 03/92] GH-73: Update blockquote based on GH-67 --- .../taccsite_blockquote/cms_plugins.py | 25 +++++-- .../contrib/taccsite_blockquote/defaults.py | 1 + .../migrations/0001_initial.py | 4 +- .../contrib/taccsite_blockquote/models.py | 9 ++- .../contrib/taccsite_blockquote/tests.py | 71 +++++++++++++++++++ taccsite_cms/settings.py | 1 + 6 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 taccsite_cms/contrib/taccsite_blockquote/defaults.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/tests.py diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 93ff70eb7..1b443c943 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -2,9 +2,12 @@ from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import gettext_lazy as _ +from django.utils.encoding import force_text from .models import TaccsiteBlockquote +from .defaults import user_name as default_name + @plugin_pool.register_plugin class TaccsiteBlockquotePlugin(CMSPluginBase): """ @@ -15,20 +18,32 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): model = TaccsiteBlockquote name = _('Blockquote') render_template = 'blockquote.html' + cache = False + text_enabled = False + + # FAQ: Sets tooltip of preview of this plugin within a Text plugin + def icon_alt(self, instance): + super_value = force_text(super().icon_alt(instance)) + name = self.get_name(instance) + return f'Hello, {{{name}}} [{super_value}]' + + # Helpers - def get_name(self, instance, user): + def get_name(self, instance, user=None): """Get name of authenticated user or the name for any guest.""" - if user.is_authenticated: + if user and user.is_authenticated: name = user.first_name + ' ' + user.last_name - if False: - name = 'Jim' - else: + elif bool(instance.guest_name): name = instance.guest_name + else: + name = default_name return name + # Render + def render(self, context, instance, placeholder): context = super().render(context, instance, placeholder) request = context['request'] diff --git a/taccsite_cms/contrib/taccsite_blockquote/defaults.py b/taccsite_cms/contrib/taccsite_blockquote/defaults.py new file mode 100644 index 000000000..8fc1ca55a --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/defaults.py @@ -0,0 +1 @@ +user_name = 'Guest' diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py index 04ff60c6c..7271dc62c 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.16 on 2021-04-12 17:18 +# Generated by Django 2.2.16 on 2021-04-13 20:15 from django.db import migrations, models import django.db.models.deletion @@ -17,7 +17,7 @@ class Migration(migrations.Migration): name='TaccsiteBlockquote', fields=[ ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_blockquote_taccsiteblockquote', serialize=False, to='cms.CMSPlugin')), - ('guest_name', models.CharField(default='Guest', max_length=50)), + ('guest_name', models.CharField(blank=True, default='Guest', help_text='If user is logged in they are greeted by their name. If not logged in, they are greeted as this value. If this value is blank, they are greeted as "Guest".', max_length=50)), ], options={ 'abstract': False, diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index f47b933cd..38f406b17 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -2,12 +2,19 @@ from django.db import models +from .defaults import user_name as default_name + class TaccsiteBlockquote(CMSPlugin): """ Components > "Blockquote" Model https://confluence.tacc.utexas.edu/x/FIEjCQ """ - guest_name = models.CharField(max_length=50, default='Guest') + guest_name = models.CharField( + max_length=50, + default=default_name, + help_text=f'If user is logged in they are greeted by their name. If not logged in, they are greeted as this value. If this value is blank, they are greeted as "{default_name}".', + blank=True + ) def get_short_description(self): return 'Hello, […]' diff --git a/taccsite_cms/contrib/taccsite_blockquote/tests.py b/taccsite_cms/contrib/taccsite_blockquote/tests.py new file mode 100644 index 000000000..e78ffac38 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/tests.py @@ -0,0 +1,71 @@ +from django.test import TestCase +from django.test.client import RequestFactory + +from django.contrib.auth.models import AnonymousUser, User + +from cms.api import add_plugin +from cms.models import Placeholder +from cms.plugin_rendering import ContentRenderer + +from taccsite_cms.contrib.taccsite_blockquote.cms_plugins import TaccsiteBlockquotePlugin +from taccsite_cms.contrib.taccsite_blockquote.models import TaccsiteBlockquote + +class TaccsiteBlockquoteTests(TestCase): + def setUp(self): + self.factory = RequestFactory() + self.auth_user = User() + self.anon_user = AnonymousUser() + self.context = { 'request': self.factory.get('/test/user') } + self.placeholder = Placeholder.objects.create(slot='test') + self.plugin = add_plugin( + self.placeholder, + TaccsiteBlockquotePlugin, + 'en', + ) + + # Helpers + + def _get_context(self): + """Return context necessary for testing plugin logic""" + plugin_instance = self.plugin.get_plugin_class_instance() + context = plugin_instance.render(self.context, self.plugin, None) + return context + + def _get_html(self): + """Return markup necessary for testing plugin template""" + renderer = ContentRenderer(request=self.factory) + html = renderer.render_plugin(self.plugin, self.context) + return html + + def _test_context(self, assertVals): + """Reusable plugin logic test""" + context = self._get_context() + self.assertIn('user_name', context) + self.assertEqual(context['user_name'], assertVals['name']) + + def _test_html(self, assertVals): + """Reusable plugin markup test""" + html = self._get_html() + self.assertEqual(html, '

Hello, ' + assertVals['name'] + '.

\n') + + # Tests + + def test_anon_user(self): + """Test name of unauthenticated user""" + self.context['request'].user = self.anon_user + + assertVals = { 'name': 'Guest' } + + self._test_context(assertVals) + self._test_html(assertVals) + + def test_auth_user(self): + """Test name of authenticated user""" + self.context['request'].user = self.auth_user + + assertVals = { + 'name': self.auth_user.first_name + ' ' + self.auth_user.last_name + } + + self._test_context(assertVals) + self._test_html(assertVals) diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 2d7c58175..0025d4ab1 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -243,6 +243,7 @@ def getsecrets(): # TODO: Extract TACC CMS UI components into pip-installable plugins # FAQ: The djangocms_bootstrap4 library can serve as an example 'taccsite_cms.contrib.taccsite_sample', + 'taccsite_cms.contrib.taccsite_blockquote', ] # Convert list of paths to list of dotted module names From 6028f4aff5270cc47885bb615eb432f2e0c12cad Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 16 Jun 2021 15:45:24 -0500 Subject: [PATCH 04/92] GH-73: Finish first version of blockquote plugin --- taccsite_cms/contrib/__init__.py | 0 taccsite_cms/contrib/constants.py | 7 +++ taccsite_cms/contrib/helpers.py | 6 +++ .../taccsite_blockquote/cms_plugins.py | 49 ++++++++++++------- .../migrations/0002_auto_20210616_1214.py | 38 ++++++++++++++ .../migrations/0003_auto_20210616_1544.py | 18 +++++++ .../contrib/taccsite_blockquote/models.py | 25 ++++++++-- .../templates/blockquote.html | 2 +- .../_imports/components/c-offset-content.css | 36 ++++++++++++++ .../css/src/_imports/trumps/s-blockquote.css | 28 +++++++++++ .../_imports/trumps/s-blockquote.twig.html | 8 +++ taccsite_cms/static/site_cms/css/src/site.css | 1 + taccsite_custom | 2 +- 13 files changed, 196 insertions(+), 24 deletions(-) create mode 100644 taccsite_cms/contrib/__init__.py create mode 100644 taccsite_cms/contrib/constants.py create mode 100644 taccsite_cms/contrib/helpers.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py create mode 100644 taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css create mode 100644 taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css create mode 100644 taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html diff --git a/taccsite_cms/contrib/__init__.py b/taccsite_cms/contrib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/constants.py b/taccsite_cms/contrib/constants.py new file mode 100644 index 000000000..f59838686 --- /dev/null +++ b/taccsite_cms/contrib/constants.py @@ -0,0 +1,7 @@ +from django.utils.translation import gettext_lazy as _ + +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/constants.py +ALIGN_CHOICES = ( + ('left', _('Left')), + ('right', _('Right')), +) diff --git a/taccsite_cms/contrib/helpers.py b/taccsite_cms/contrib/helpers.py new file mode 100644 index 000000000..e591fda8d --- /dev/null +++ b/taccsite_cms/contrib/helpers.py @@ -0,0 +1,6 @@ +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py +def concat_classes(classes): + """ + Merge a list of classes and return concatinated string + """ + return ' '.join(_class for _class in classes if _class) diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 1b443c943..738d06a1e 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -1,9 +1,13 @@ +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/cms_plugins.py#L41 + from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from cms.models.pluginmodel import CMSPlugin from django.utils.translation import gettext_lazy as _ from django.utils.encoding import force_text +from taccsite_cms.contrib.helpers import concat_classes + from .models import TaccsiteBlockquote from .defaults import user_name as default_name @@ -22,25 +26,32 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): cache = False text_enabled = False - # FAQ: Sets tooltip of preview of this plugin within a Text plugin - def icon_alt(self, instance): - super_value = force_text(super().icon_alt(instance)) - name = self.get_name(instance) - return f'Hello, {{{name}}} [{super_value}]' + fieldsets = [ + (None, { + 'fields': ( + ('quote_text', 'quote_origin'), + 'quote_alignment', + ) + }), + (_('Advanced settings'), { + 'classes': ('collapse'), + 'fields': ( + 'attributes', + ) + }), + ] # Helpers - def get_name(self, instance, user=None): - """Get name of authenticated user or the name for any guest.""" + def get_alignment_class(self, instance, option_value): + """Get alignment class based on alignment option.""" - if user and user.is_authenticated: - name = user.first_name + ' ' + user.last_name - elif bool(instance.guest_name): - name = instance.guest_name - else: - name = default_name + switcher = { + 'right': 'c-offset-content--right', + 'left': 'c-offset-content--left', + } - return name + return switcher.get(option_value, '') # Render @@ -48,7 +59,11 @@ def render(self, context, instance, placeholder): context = super().render(context, instance, placeholder) request = context['request'] - context.update({ - 'user_name': self.get_name(instance, request.user) - }) + classes = ' '.join([ + 's-blockquote', + self.get_alignment_class(instance, instance.quote_alignment), + instance.attributes.get('class'), + ]) + instance.attributes['class'] = classes + return context diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py new file mode 100644 index 000000000..c53e3c74e --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py @@ -0,0 +1,38 @@ +# Generated by Django 2.2.16 on 2021-06-16 17:14 + +from django.db import migrations, models +import djangocms_attributes_field.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('taccsite_blockquote', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='taccsiteblockquote', + name='guest_name', + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='attributes', + field=djangocms_attributes_field.fields.AttributesField(default=dict), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='quote_alignment', + field=models.CharField(blank=True, choices=[('text-left', 'Left'), ('text-center', 'Center'), ('text-right', 'Right')], default='text-left', max_length=255), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='quote_origin', + field=models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source).', max_length=50), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='quote_text', + field=models.TextField(default=None), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py new file mode 100644 index 000000000..667ac50ca --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.16 on 2021-06-16 20:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taccsite_blockquote', '0002_auto_20210616_1214'), + ] + + operations = [ + migrations.AlterField( + model_name='taccsiteblockquote', + name='quote_alignment', + field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], default='left', max_length=255), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index 38f406b17..6823fa775 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -1,7 +1,13 @@ +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/models.py + from cms.models.pluginmodel import CMSPlugin from django.db import models +from djangocms_attributes_field import fields + +from taccsite_cms.contrib.constants import ALIGN_CHOICES + from .defaults import user_name as default_name class TaccsiteBlockquote(CMSPlugin): @@ -9,12 +15,21 @@ class TaccsiteBlockquote(CMSPlugin): Components > "Blockquote" Model https://confluence.tacc.utexas.edu/x/FIEjCQ """ - guest_name = models.CharField( + quote_text = models.TextField( + default=None, + ) + quote_origin = models.CharField( + help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source).', + blank=True, max_length=50, - default=default_name, - help_text=f'If user is logged in they are greeted by their name. If not logged in, they are greeted as this value. If this value is blank, they are greeted as "{default_name}".', - blank=True ) + quote_alignment = models.CharField( + choices=ALIGN_CHOICES, + default=ALIGN_CHOICES[0][0], + blank=True, + max_length=255, + ) + attributes = fields.AttributesField() def get_short_description(self): - return 'Hello, […]' + return self.quote_text diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html index 48a0d12b5..1298b95b5 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -1,5 +1,5 @@
- {{ instance.quote_content }} + {{ instance.quote_text }} {% if instance.quote_origin %}
{{ instance.quote_origin }} diff --git a/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css b/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css new file mode 100644 index 000000000..87769d9cd --- /dev/null +++ b/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css @@ -0,0 +1,36 @@ +/* +Offset Content + +Content that should be offset from the flow of text within which it is placed. + +Styleguide Components.OffsetContent +*/ + +[class*="c-offset-content--"] { + --offset-distance: 8.5vw; /* NOTE: Value is from Texascale.org 2020 */ + --buffer: 30px; /* double Bootstrap `.col` padding */ +} + +@media only screen and (--medium-and-above) { + .c-offset-content--right { + float: right; + margin-left: var(--buffer); + } + .c-offset-content--right + .c-offset-content--right { clear: right; } + + .c-offset-content--left { + float: left; + margin-right: var(--buffer); + } + .c-offset-content--left + .c-offset-content--left { clear: left; } +} +/* WARNING: Value `2400px` is from Texascale.org 2020 */ +@media only screen and (--medium-and-above) and (max-width: 2400px) { + /* Apply negative margin only when using offset value */ + .c-offset-content--right { + margin-right: calc( var(--offset-distance) * -1); + } + .c-offset-content--left { + margin-left: calc( var(--offset-distance) * -1); + } +} diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css new file mode 100644 index 000000000..d69c02325 --- /dev/null +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css @@ -0,0 +1,28 @@ +/* +Blockquote + +A [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote). + +Markup: s-blockquote.twig.html + +Styleguide Trumps.Scopes.Blockquote +*/ + +.s-blockquote { + margin-top: 20px; + margin-bottom: 20px; +} +.s-blockquote blockquote { + color: #b75554; + font-size: 18px; + font-style: italic; +} +.s-blockquote figcaption { + margin-top: 5px; + + color: #636466; + font-size: 16px; +} +.s-blockquote cite { + font-style: normal; /* overwrite browser `cite` */ +} diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html new file mode 100644 index 000000000..0419ecb28 --- /dev/null +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html @@ -0,0 +1,8 @@ +
+
+

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

+
+
—Aldous Huxley, Brave New World
+
diff --git a/taccsite_cms/static/site_cms/css/src/site.css b/taccsite_cms/static/site_cms/css/src/site.css index d63d8c511..96a8149af 100644 --- a/taccsite_cms/static/site_cms/css/src/site.css +++ b/taccsite_cms/static/site_cms/css/src/site.css @@ -26,6 +26,7 @@ /* COMPONENTS */ @import url("_imports/components/c-footer.css"); +@import url("_imports/components/c-offset-content.css"); @import url("_imports/components/django.cms.css"); @import url("_imports/components/django.cms.blog.css"); @import url("_imports/components/django.cms.post.css"); diff --git a/taccsite_custom b/taccsite_custom index e3d043455..702e0a111 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit e3d043455b06070fa4aa5e3955d15f12a9cb585a +Subproject commit 702e0a111fea1299420473eb3b8eae6778e3561b From c73532e452171c48e72e03ca3531f9dbac33ff5b Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 16 Jun 2021 19:24:03 -0500 Subject: [PATCH 05/92] GH-73: Finish blockquote plugin --- taccsite_cms/contrib/helpers.py | 6 +- .../taccsite_blockquote/cms_plugins.py | 35 +++++------- .../contrib/taccsite_blockquote/defaults.py | 1 - ...6_1710_squashed_0012_auto_20210616_1910.py | 57 +++++++++++++++++++ .../contrib/taccsite_blockquote/models.py | 42 ++++++++++---- .../templates/blockquote.html | 35 +++++++++--- taccsite_custom | 2 +- 7 files changed, 133 insertions(+), 45 deletions(-) delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/defaults.py create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py diff --git a/taccsite_cms/contrib/helpers.py b/taccsite_cms/contrib/helpers.py index e591fda8d..2b243229f 100644 --- a/taccsite_cms/contrib/helpers.py +++ b/taccsite_cms/contrib/helpers.py @@ -1,6 +1,8 @@ # SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py -def concat_classes(classes): + +def concat_classnames(classes): """ - Merge a list of classes and return concatinated string + Concatenates a list of classes (without failing on None) """ + # SEE: https://stackoverflow.com/a/20271297/11817077 return ' '.join(_class for _class in classes if _class) diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 738d06a1e..1688388de 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -2,16 +2,12 @@ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool -from cms.models.pluginmodel import CMSPlugin from django.utils.translation import gettext_lazy as _ -from django.utils.encoding import force_text -from taccsite_cms.contrib.helpers import concat_classes +from taccsite_cms.contrib.helpers import concat_classnames from .models import TaccsiteBlockquote -from .defaults import user_name as default_name - @plugin_pool.register_plugin class TaccsiteBlockquotePlugin(CMSPluginBase): """ @@ -29,39 +25,34 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): fieldsets = [ (None, { 'fields': ( - ('quote_text', 'quote_origin'), - 'quote_alignment', + 'text', + 'origin', + 'use_cite', + ) + }), + (_('Citation'), { + 'classes': ('collapse',), + 'fields': ( + 'cite_person', + ('cite_text', 'cite_url'), ) }), (_('Advanced settings'), { - 'classes': ('collapse'), + 'classes': ('collapse',), 'fields': ( 'attributes', ) }), ] - # Helpers - - def get_alignment_class(self, instance, option_value): - """Get alignment class based on alignment option.""" - - switcher = { - 'right': 'c-offset-content--right', - 'left': 'c-offset-content--left', - } - - return switcher.get(option_value, '') - # Render def render(self, context, instance, placeholder): context = super().render(context, instance, placeholder) request = context['request'] - classes = ' '.join([ + classes = concat_classnames([ 's-blockquote', - self.get_alignment_class(instance, instance.quote_alignment), instance.attributes.get('class'), ]) instance.attributes['class'] = classes diff --git a/taccsite_cms/contrib/taccsite_blockquote/defaults.py b/taccsite_cms/contrib/taccsite_blockquote/defaults.py deleted file mode 100644 index 8fc1ca55a..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/defaults.py +++ /dev/null @@ -1 +0,0 @@ -user_name = 'Guest' diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py new file mode 100644 index 000000000..71904e81c --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py @@ -0,0 +1,57 @@ +# Generated by Django 2.2.16 on 2021-06-17 00:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + replaces = [('taccsite_blockquote', '0004_auto_20210616_1710'), ('taccsite_blockquote', '0005_auto_20210616_1717'), ('taccsite_blockquote', '0006_auto_20210616_1752'), ('taccsite_blockquote', '0007_auto_20210616_1758'), ('taccsite_blockquote', '0008_auto_20210616_1802'), ('taccsite_blockquote', '0009_taccsiteblockquote_use_adv_origin'), ('taccsite_blockquote', '0010_auto_20210616_1832'), ('taccsite_blockquote', '0011_auto_20210616_1833'), ('taccsite_blockquote', '0012_auto_20210616_1910')] + + dependencies = [ + ('taccsite_blockquote', '0003_auto_20210616_1544'), + ] + + operations = [ + migrations.RemoveField( + model_name='taccsiteblockquote', + name='quote_alignment', + ), + migrations.RemoveField( + model_name='taccsiteblockquote', + name='quote_origin', + ), + migrations.RemoveField( + model_name='taccsiteblockquote', + name='quote_text', + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='origin', + field=models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.', max_length=100), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='cite_person', + field=models.CharField(blank=True, help_text='The author or speaker of the quote.', max_length=50, verbose_name='Author / Speaker'), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='use_cite', + field=models.BooleanField(default=False, verbose_name='Use the "Citation" fields'), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='cite_url', + field=models.CharField(blank=True, help_text='URL for the source of the quote.', max_length=255, verbose_name='Source URL'), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='cite_text', + field=models.CharField(blank=True, help_text='Text for the source of the quote.', max_length=50, verbose_name='Source Text'), + ), + migrations.AddField( + model_name='taccsiteblockquote', + name='text', + field=models.TextField(default='', null=True, verbose_name='Quote'), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index 6823fa775..80fa0de25 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -1,35 +1,53 @@ # SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/models.py from cms.models.pluginmodel import CMSPlugin +from django.utils.translation import gettext_lazy as _ from django.db import models from djangocms_attributes_field import fields -from taccsite_cms.contrib.constants import ALIGN_CHOICES - -from .defaults import user_name as default_name - class TaccsiteBlockquote(CMSPlugin): """ Components > "Blockquote" Model https://confluence.tacc.utexas.edu/x/FIEjCQ """ - quote_text = models.TextField( - default=None, + text = models.TextField( + verbose_name=_('Quote'), + null=True, + default='', ) - quote_origin = models.CharField( - help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source).', + + origin = models.CharField( + help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.', + blank=True, + max_length=100, + ) + + use_cite = models.BooleanField( + verbose_name=_('Use the "Citation" fields'), + default=False, + ) + cite_person = models.CharField( + verbose_name=_('Author / Speaker'), + help_text='The author or speaker of the quote.', blank=True, max_length=50, ) - quote_alignment = models.CharField( - choices=ALIGN_CHOICES, - default=ALIGN_CHOICES[0][0], + cite_text = models.CharField( + verbose_name=_('Source Text'), + help_text=_('Text for the source of the quote.'), + blank=True, + max_length=50, + ) + cite_url = models.CharField( + verbose_name=_('Source URL'), + help_text=_('URL for the source of the quote.'), blank=True, max_length=255, ) + attributes = fields.AttributesField() def get_short_description(self): - return self.quote_text + return self.text diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html index 1298b95b5..43581f97a 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -1,8 +1,29 @@ -
- {{ instance.quote_text }} - {% if instance.quote_origin %} -
- {{ instance.quote_origin }} -
+
+
+

{{ instance.text }}

+
+
+ {% if instance.use_cite %} + + {% if instance.cite_person %} + {{ instance.cite_person }}{% if instance.cite_text %},{% endif %} + {% endif %} + + {% if instance.cite_text and instance.cite_url %} + + {{ instance.cite_text }} + + {% endif %} + {% if instance.cite_text and not instance.cite_url %} + + {{ instance.cite_text }} + + {% endif %} + + {% else %} + + {{ instance.origin }} + {% endif %} -
+ + diff --git a/taccsite_custom b/taccsite_custom index 702e0a111..39457c8f7 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 702e0a111fea1299420473eb3b8eae6778e3561b +Subproject commit 39457c8f7f4e942fc509b0433469185575ebf627 From 59db29512b8b8a9d0badea0fc6a69eaf876452bf Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Thu, 17 Jun 2021 09:26:34 -0500 Subject: [PATCH 06/92] GH-73: Add offset plugin and offset to blockquote. - Add basic "Offset Content" plugin. - matches existing usage - lacks new feature (center alignment) - Add support for Blockquote plugin inside text. - Add support for offset option in Blockquote plugin. --- taccsite_cms/contrib/constants.py | 1 + taccsite_cms/contrib/helpers.py | 13 +++- .../taccsite_blockquote/cms_plugins.py | 10 ++- ...6_1710_squashed_0012_auto_20210616_1910.py | 2 - ...offset_squashed_0006_auto_20210616_2022.py | 18 +++++ .../contrib/taccsite_blockquote/models.py | 8 +++ .../contrib/taccsite_blockquote/tests.py | 71 ------------------- .../contrib/taccsite_offset/__init__.py | 0 .../contrib/taccsite_offset/cms_plugins.py | 53 ++++++++++++++ .../migrations/0001_initial.py | 27 +++++++ .../taccsite_offset/migrations/__init__.py | 0 .../contrib/taccsite_offset/models.py | 29 ++++++++ .../taccsite_offset/templates/offset.html | 7 ++ .../contrib/taccsite_sample/cms_plugins.py | 1 - taccsite_cms/settings.py | 1 + .../_imports/components/c-offset-content.css | 2 + .../css/src/_imports/trumps/s-blockquote.css | 25 ++++--- .../_imports/trumps/s-blockquote.twig.html | 6 +- taccsite_cms/static/site_cms/css/src/site.css | 1 + 19 files changed, 186 insertions(+), 89 deletions(-) create mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/tests.py create mode 100644 taccsite_cms/contrib/taccsite_offset/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_offset/cms_plugins.py create mode 100644 taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py create mode 100644 taccsite_cms/contrib/taccsite_offset/migrations/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_offset/models.py create mode 100644 taccsite_cms/contrib/taccsite_offset/templates/offset.html diff --git a/taccsite_cms/contrib/constants.py b/taccsite_cms/contrib/constants.py index f59838686..a812b59f6 100644 --- a/taccsite_cms/contrib/constants.py +++ b/taccsite_cms/contrib/constants.py @@ -3,5 +3,6 @@ # SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/constants.py ALIGN_CHOICES = ( ('left', _('Left')), + ('center', _('Center')), ('right', _('Right')), ) diff --git a/taccsite_cms/contrib/helpers.py b/taccsite_cms/contrib/helpers.py index 2b243229f..11879a55b 100644 --- a/taccsite_cms/contrib/helpers.py +++ b/taccsite_cms/contrib/helpers.py @@ -1,5 +1,16 @@ -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py +def get_offset_classname(offset): + """Get offset content class based on standard offset value.""" + + # TODO: Limit input to known offsets + # SEE: taccsite_cms.contrib.constants:OFFSET_CHOICES + switcher = { + 'right': 'c-offset-content--right', + 'left': 'c-offset-content--left' + } + return switcher.get(offset, '') + +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py def concat_classnames(classes): """ Concatenates a list of classes (without failing on None) diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 1688388de..2aab945f9 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -4,7 +4,7 @@ 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.helpers import concat_classnames, get_offset_classname from .models import TaccsiteBlockquote @@ -20,7 +20,7 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): render_template = 'blockquote.html' cache = False - text_enabled = False + text_enabled = True fieldsets = [ (None, { @@ -37,6 +37,11 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): ('cite_text', 'cite_url'), ) }), + (_('Layout'), { + 'fields': ( + 'offset', + ) + }), (_('Advanced settings'), { 'classes': ('collapse',), 'fields': ( @@ -53,6 +58,7 @@ def render(self, context, instance, placeholder): classes = concat_classnames([ 's-blockquote', + get_offset_classname(instance.offset), instance.attributes.get('class'), ]) instance.attributes['class'] = classes diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py index 71904e81c..306bcf806 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py @@ -5,8 +5,6 @@ class Migration(migrations.Migration): - replaces = [('taccsite_blockquote', '0004_auto_20210616_1710'), ('taccsite_blockquote', '0005_auto_20210616_1717'), ('taccsite_blockquote', '0006_auto_20210616_1752'), ('taccsite_blockquote', '0007_auto_20210616_1758'), ('taccsite_blockquote', '0008_auto_20210616_1802'), ('taccsite_blockquote', '0009_taccsiteblockquote_use_adv_origin'), ('taccsite_blockquote', '0010_auto_20210616_1832'), ('taccsite_blockquote', '0011_auto_20210616_1833'), ('taccsite_blockquote', '0012_auto_20210616_1910')] - dependencies = [ ('taccsite_blockquote', '0003_auto_20210616_1544'), ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py new file mode 100644 index 000000000..f5076837a --- /dev/null +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.16 on 2021-06-17 14:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taccsite_blockquote', '0004_auto_20210616_1710_squashed_0012_auto_20210616_1910'), + ] + + operations = [ + migrations.AddField( + model_name='taccsiteblockquote', + name='offset', + field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index 80fa0de25..81a73b898 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -7,6 +7,8 @@ from djangocms_attributes_field import fields +from taccsite_cms.contrib.taccsite_offset.models import TaccsiteOffset + class TaccsiteBlockquote(CMSPlugin): """ Components > "Blockquote" Model @@ -47,6 +49,12 @@ class TaccsiteBlockquote(CMSPlugin): max_length=255, ) + offset = models.CharField( + choices=TaccsiteOffset.DIRECTION_CHOICES, + blank=True, + max_length=255, + ) + attributes = fields.AttributesField() def get_short_description(self): diff --git a/taccsite_cms/contrib/taccsite_blockquote/tests.py b/taccsite_cms/contrib/taccsite_blockquote/tests.py deleted file mode 100644 index e78ffac38..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/tests.py +++ /dev/null @@ -1,71 +0,0 @@ -from django.test import TestCase -from django.test.client import RequestFactory - -from django.contrib.auth.models import AnonymousUser, User - -from cms.api import add_plugin -from cms.models import Placeholder -from cms.plugin_rendering import ContentRenderer - -from taccsite_cms.contrib.taccsite_blockquote.cms_plugins import TaccsiteBlockquotePlugin -from taccsite_cms.contrib.taccsite_blockquote.models import TaccsiteBlockquote - -class TaccsiteBlockquoteTests(TestCase): - def setUp(self): - self.factory = RequestFactory() - self.auth_user = User() - self.anon_user = AnonymousUser() - self.context = { 'request': self.factory.get('/test/user') } - self.placeholder = Placeholder.objects.create(slot='test') - self.plugin = add_plugin( - self.placeholder, - TaccsiteBlockquotePlugin, - 'en', - ) - - # Helpers - - def _get_context(self): - """Return context necessary for testing plugin logic""" - plugin_instance = self.plugin.get_plugin_class_instance() - context = plugin_instance.render(self.context, self.plugin, None) - return context - - def _get_html(self): - """Return markup necessary for testing plugin template""" - renderer = ContentRenderer(request=self.factory) - html = renderer.render_plugin(self.plugin, self.context) - return html - - def _test_context(self, assertVals): - """Reusable plugin logic test""" - context = self._get_context() - self.assertIn('user_name', context) - self.assertEqual(context['user_name'], assertVals['name']) - - def _test_html(self, assertVals): - """Reusable plugin markup test""" - html = self._get_html() - self.assertEqual(html, '

Hello, ' + assertVals['name'] + '.

\n') - - # Tests - - def test_anon_user(self): - """Test name of unauthenticated user""" - self.context['request'].user = self.anon_user - - assertVals = { 'name': 'Guest' } - - self._test_context(assertVals) - self._test_html(assertVals) - - def test_auth_user(self): - """Test name of authenticated user""" - self.context['request'].user = self.auth_user - - assertVals = { - 'name': self.auth_user.first_name + ' ' + self.auth_user.last_name - } - - self._test_context(assertVals) - self._test_html(assertVals) diff --git a/taccsite_cms/contrib/taccsite_offset/__init__.py b/taccsite_cms/contrib/taccsite_offset/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py new file mode 100644 index 000000000..8c796f61f --- /dev/null +++ b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py @@ -0,0 +1,53 @@ +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/cms_plugins.py#L41 + +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, get_offset_classname + +from .models import TaccsiteOffset + +@plugin_pool.register_plugin +class TaccsiteOffsetPlugin(CMSPluginBase): + """ + Components > "Offset Content" Plugin + https://confluence.tacc.utexas.edu/x/FIEjCQ + """ + module = 'TACC Site' + model = TaccsiteOffset + name = _('Offset Content') + render_template = 'offset.html' + + cache = False + text_enabled = False + allow_children = True + + fieldsets = [ + (None, { + 'fields': ( + 'direction', + ) + }), + (_('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([ + get_offset_classname(instance.direction), + instance.attributes.get('class'), + ]) + instance.attributes['class'] = classes + + return context diff --git a/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py new file mode 100644 index 000000000..5542b0410 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.16 on 2021-06-17 00:45 + +from django.db import migrations, models +import django.db.models.deletion +import djangocms_attributes_field.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ] + + operations = [ + migrations.CreateModel( + name='TaccsiteOffset', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_offset_taccsiteoffset', serialize=False, to='cms.CMSPlugin')), + ('alignment', models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], default='left', max_length=255)), + ('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_offset/migrations/__init__.py b/taccsite_cms/contrib/taccsite_offset/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_offset/models.py b/taccsite_cms/contrib/taccsite_offset/models.py new file mode 100644 index 000000000..a8afa1452 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_offset/models.py @@ -0,0 +1,29 @@ +# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/models.py + +from cms.models.pluginmodel import CMSPlugin + +from django.db import models +from django.utils.translation import gettext_lazy as _ + +from djangocms_attributes_field import fields + +class TaccsiteOffset(CMSPlugin): + """ + Components > "Offset Content" Model + https://confluence.tacc.utexas.edu/x/GIEjCQ + """ + DIRECTION_CHOICES = ( + ('left', _('Left')), + ('right', _('Right')), + ) + + direction = models.CharField( + choices=DIRECTION_CHOICES, + blank=True, + max_length=255, + ) + + attributes = fields.AttributesField() + + def get_short_description(self): + return self.direction diff --git a/taccsite_cms/contrib/taccsite_offset/templates/offset.html b/taccsite_cms/contrib/taccsite_offset/templates/offset.html new file mode 100644 index 000000000..98edf0c42 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_offset/templates/offset.html @@ -0,0 +1,7 @@ +{% load cms_tags %} + + diff --git a/taccsite_cms/contrib/taccsite_sample/cms_plugins.py b/taccsite_cms/contrib/taccsite_sample/cms_plugins.py index 1e775d3bb..87bb30636 100644 --- a/taccsite_cms/contrib/taccsite_sample/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_sample/cms_plugins.py @@ -1,6 +1,5 @@ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool -from cms.models.pluginmodel import CMSPlugin from django.utils.translation import gettext_lazy as _ from django.utils.encoding import force_text diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 289fad4b7..4b548fb00 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -242,6 +242,7 @@ def getsecrets(): # FAQ: The djangocms_bootstrap4 library can serve as an example 'taccsite_cms.contrib.taccsite_sample', 'taccsite_cms.contrib.taccsite_blockquote', + 'taccsite_cms.contrib.taccsite_offset', ] # Convert list of paths to list of dotted module names diff --git a/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css b/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css index 87769d9cd..102a6f13b 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css @@ -9,6 +9,8 @@ Styleguide Components.OffsetContent [class*="c-offset-content--"] { --offset-distance: 8.5vw; /* NOTE: Value is from Texascale.org 2020 */ --buffer: 30px; /* double Bootstrap `.col` padding */ + + max-width: 50%; } @media only screen and (--medium-and-above) { diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css index d69c02325..4769ef842 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css @@ -9,20 +9,29 @@ Styleguide Trumps.Scopes.Blockquote */ .s-blockquote { - margin-top: 20px; - margin-bottom: 20px; + margin-top: 1.25em; + margin-bottom: 1.25em; } .s-blockquote blockquote { - color: #b75554; - font-size: 18px; + margin-bottom: 0; /* overwrite Bootstrap */ + + font-size: 1.125em; font-style: italic; } +.s-blockquote blockquote p { + margin: 0; + white-space: pre-wrap; +} + .s-blockquote figcaption { - margin-top: 5px; + margin-top: 0.3em; - color: #636466; - font-size: 16px; + font-size: 1em; } +.s-blockquote figcaption::before { + content: "—"; +} + .s-blockquote cite { - font-style: normal; /* overwrite browser `cite` */ + font-style: normal; /* overwrite browser */ } diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html index 0419ecb28..249d11cff 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html @@ -1,8 +1,6 @@
-
+

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

-
—Aldous Huxley, Brave New World
+
Aldous Huxley, Brave New World
diff --git a/taccsite_cms/static/site_cms/css/src/site.css b/taccsite_cms/static/site_cms/css/src/site.css index 96a8149af..21b257785 100644 --- a/taccsite_cms/static/site_cms/css/src/site.css +++ b/taccsite_cms/static/site_cms/css/src/site.css @@ -34,4 +34,5 @@ /* TRUMPS */ @import url("_imports/trumps/s-footer.css"); +@import url("_imports/trumps/s-blockquote.css"); @import url("_imports/trumps/u-empty.css"); From f3dac48fb0f9d069d42841d986d636c0296e6590 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Thu, 17 Jun 2021 09:58:18 -0500 Subject: [PATCH 07/92] GH-73: Blockquote: fix markup bug, post-dash space --- .../contrib/taccsite_blockquote/templates/blockquote.html | 8 ++++---- .../site_cms/css/src/_imports/trumps/s-blockquote.css | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html index 43581f97a..565da399c 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -2,8 +2,8 @@

{{ instance.text }}

-
{% if instance.use_cite %} +
{% if instance.cite_person %} {{ instance.cite_person }}{% if instance.cite_text %},{% endif %} @@ -20,10 +20,10 @@ {% endif %} - {% else %} +
+ {% elif instance.origin %} - {{ instance.origin }} +
{{ instance.origin }}
{% endif %} -
diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css index 4769ef842..993c2511c 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css @@ -29,7 +29,7 @@ Styleguide Trumps.Scopes.Blockquote font-size: 1em; } .s-blockquote figcaption::before { - content: "—"; + content: "— "; } .s-blockquote cite { From eaa0a01abd472ed131ddee52622fa1db4e511222 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Thu, 17 Jun 2021 16:19:26 -0500 Subject: [PATCH 08/92] GH-73: Update submodule to merge of main --- taccsite_custom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_custom b/taccsite_custom index 39457c8f7..e32c93534 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 39457c8f7f4e942fc509b0433469185575ebf627 +Subproject commit e32c9353453533a4fb3dc8385dd385416e03219a From 580a7a5e306b88ee8cf3c8f368dcd830615fc434 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Fri, 18 Jun 2021 14:19:53 -0500 Subject: [PATCH 09/92] FP-1099: Test: Disable reindex on publish --- taccsite_cms/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 530c2d3fd..7a8505ef4 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -467,7 +467,8 @@ def get_subdirs_as_module_names(path): # Elasticsearch Indexing HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter',] -HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor' +# FP-1099: Wesley is disabling this to prove it is a trigger for a bug +# HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor' ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'en' ALDRYN_SEARCH_REGISTER_APPHOOK = True HAYSTACK_CONNECTIONS = { From 22232f0a10b6dcd51aed684927a6e699357311fa Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Sat, 19 Jun 2021 15:03:43 -0500 Subject: [PATCH 10/92] Quick: Update taccsite_custom to latest --- taccsite_custom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_custom b/taccsite_custom index 66f0bfcbd..3933a9b53 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 66f0bfcbd685cd269f8fdc3fbcbdefcadc559e01 +Subproject commit 3933a9b53faa51a79fdfedf8aaad90b8400ad3eb From 98d419965d35ac45e94b685853e8c00ad64c016e Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 10:59:22 -0500 Subject: [PATCH 11/92] GH-73: Move sample markup for blockquote into css --- .../site_cms/css/src/_imports/trumps/s-blockquote.css | 8 +++++++- .../css/src/_imports/trumps/s-blockquote.twig.html | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css index 993c2511c..d288f5504 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css @@ -3,7 +3,13 @@ Blockquote A [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote). -Markup: s-blockquote.twig.html +Markup: +
+
+

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

+
+
Aldous Huxley, Brave New World
+
Styleguide Trumps.Scopes.Blockquote */ diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html deleted file mode 100644 index 249d11cff..000000000 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.twig.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

-
-
Aldous Huxley, Brave New World
-
From 7ebecb1dc58152c21ed3241c242cc4c6a6dd09be Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 12:44:30 -0500 Subject: [PATCH 12/92] FP-1099: Make Search a feature Allow search to be disabled for Portal. Allow indexing to be disabled for CMS. --- taccsite_cms/default_secrets.py | 7 ++++ taccsite_cms/settings.py | 56 +++++++++++++++++------------- taccsite_cms/templates/header.html | 2 +- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/taccsite_cms/default_secrets.py b/taccsite_cms/default_secrets.py index ef3fd6353..77b6b6826 100644 --- a/taccsite_cms/default_secrets.py +++ b/taccsite_cms/default_secrets.py @@ -157,6 +157,13 @@ # SEE: https://confluence.tacc.utexas.edu/x/EwDeCg # SEE: https://confluence.tacc.utexas.edu/x/FAA9Cw "blog": False, + + # Search + # - `True` (Portal: enable search, CMS: enable indexing) + # - (falsy) (Portal: enable search, CMS: disable indexing) + # - `False` (Portal: disable search, CMS: disable indexing) + # FP-1099: Search can be disabled as a workaround to suspected indexing bug + "search": None, } ######################## diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 7a8505ef4..2f98cf51f 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -232,8 +232,6 @@ def getsecrets(): 'djangocms_bootstrap4.contrib.bootstrap4_picture', 'djangocms_bootstrap4.contrib.bootstrap4_tabs', 'djangocms_bootstrap4.contrib.bootstrap4_utilities', - 'haystack', - 'aldryn_apphooks_config', # For faster testing, disable migrations during database creation # SEE: https://stackoverflow.com/a/37150997 'test_without_migrations', @@ -377,8 +375,8 @@ def get_subdirs_as_module_names(path): for feature in FEATURES: print(feature + ": ", FEATURES[feature]) -if current_secrets._FEATURES['blog']: - # Install required apps +# Support Blog/News & Social Media Metadata +if FEATURES['blog']: INSTALLED_APPS += [ # Blog/News # 'filer', # Already added @@ -394,7 +392,7 @@ def get_subdirs_as_module_names(path): 'djangocms_page_meta', ] - # Metadata: Configure + # Configure metadata META_SITE_PROTOCOL = 'http' META_USE_SITES = True META_USE_OG_PROPERTIES = True @@ -402,19 +400,46 @@ def get_subdirs_as_module_names(path): META_USE_GOOGLEPLUS_PROPERTIES = True # django-meta 1.x+ # META_USE_SCHEMAORG_PROPERTIES=True # django-meta 2.x+ - # Blog/News: Set custom paths for templates + # Set custom paths for templates BLOG_PLUGIN_TEMPLATE_FOLDERS = ( ('plugins/default', 'Default template'), # i.e. `templates/djangocms_blog/plugins/default/` ('plugins/default-clone', 'Clone of default template'), # i.e. `templates/djangocms_blog/plugins/default-clone/` ) - # Blog/News: Change default values for the auto-setup of one `BlogConfig` + # Change default values for the auto-setup of one `BlogConfig` # SEE: https://github.com/nephila/djangocms-blog/issues/629 BLOG_AUTO_SETUP = True BLOG_AUTO_HOME_TITLE ='Home' BLOG_AUTO_BLOG_TITLE = 'News' BLOG_AUTO_APP_TITLE = 'News' +# Support Portal search or CMS indexing +if 'search' in FEATURES and ( + FEATURES['search'] + # FAQ: Portals can search by default, but may not set `FEATURES['search']` + or (PORTAL and FEATURES['search'] != False) +): + INSTALLED_APPS += [ + 'haystack', + 'aldryn_apphooks_config', + ] + + # Elasticsearch Indexing + HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter',] + HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor' + ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'en' + ALDRYN_SEARCH_REGISTER_APPHOOK = True + HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', + 'URL': current_secrets._ES_HOSTS, + 'INDEX_NAME': current_secrets._ES_INDEX_PREFIX.format('cms'), + 'KWARGS': {'http_auth': current_secrets._ES_AUTH } + } + } + + ES_DOMAIN = current_secrets._ES_DOMAIN + DJANGOCMS_PICTURE_NESTING = True DJANGOCMS_PICTURE_RESPONSIVE_IMAGES = True @@ -465,23 +490,6 @@ def get_subdirs_as_module_names(path): # Use a custom namespace (using default settings.VARIABLE configuration) SETTINGS_EXPORT_VARIABLE_NAME = 'settings' -# Elasticsearch Indexing -HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter',] -# FP-1099: Wesley is disabling this to prove it is a trigger for a bug -# HAYSTACK_SIGNAL_PROCESSOR = 'taccsite_cms.signal_processor.RealtimeSignalProcessor' -ALDRYN_SEARCH_DEFAULT_LANGUAGE = 'en' -ALDRYN_SEARCH_REGISTER_APPHOOK = True -HAYSTACK_CONNECTIONS = { - 'default': { - 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', - 'URL': current_secrets._ES_HOSTS, - 'INDEX_NAME': current_secrets._ES_INDEX_PREFIX.format('cms'), - 'KWARGS': {'http_auth': current_secrets._ES_AUTH } - } -} - -ES_DOMAIN = current_secrets._ES_DOMAIN - # Exported settings. SETTINGS_EXPORT = [ 'DEBUG', diff --git a/taccsite_cms/templates/header.html b/taccsite_cms/templates/header.html index d02a41c53..195df8c41 100644 --- a/taccsite_cms/templates/header.html +++ b/taccsite_cms/templates/header.html @@ -23,7 +23,7 @@ {% include "nav_cms.html" with className="navbar-nav" %} {# NOTE: As of 2020-12, search is only available with a Portal #} - {% include "nav_search.html" with className="form-inline ml-auto" only %} + {% if settings.FEATURES.search != False %}{% include "nav_search.html" with className="form-inline ml-auto" only %}{% endif %} {% include "nav_portal.html" with className="navbar-nav" settings=settings only %} {% else %} {# FAQ: If template were included with `only`, then it would NOT render `show_menu` #} From 9ce83d2977c1a253afe4b4cb9e571a79444585e2 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 13:18:44 -0500 Subject: [PATCH 13/92] FP-1099: Clarify Search feature value results Default Value (i.e. falsy): - Allow indexing for Portal CMS. - Disallow indexing for SAD CMS. --- taccsite_cms/default_secrets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taccsite_cms/default_secrets.py b/taccsite_cms/default_secrets.py index 77b6b6826..c3ca92594 100644 --- a/taccsite_cms/default_secrets.py +++ b/taccsite_cms/default_secrets.py @@ -159,10 +159,10 @@ "blog": False, # Search - # - `True` (Portal: enable search, CMS: enable indexing) - # - (falsy) (Portal: enable search, CMS: disable indexing) - # - `False` (Portal: disable search, CMS: disable indexing) - # FP-1099: Search can be disabled as a workaround to suspected indexing bug + # - `True` (Portal: allow search, Any CMS: allow index) + # - (falsy) (Portal & CMS: allow search & index, SAD CMS: never index) + # - `False` (Portal: no search bar, Any CMS: never index) + # FP-1099: Search can be disabled as a workaround to suspected index bug "search": None, } From f972214da05f2d9e081db00e62296eeeaba5d857 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 16:52:28 -0500 Subject: [PATCH 14/92] =?UTF-8?q?GH-73:=20Collapse=20"Adv.=20Settings"=20f?= =?UTF-8?q?or=20Offset=E2=80=A6=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taccsite_cms/contrib/taccsite_offset/cms_plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py index 8c796f61f..973823d34 100644 --- a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py @@ -31,7 +31,7 @@ class TaccsiteOffsetPlugin(CMSPluginBase): ) }), (_('Advanced settings'), { - 'classes': ('collapse'), + 'classes': ('collapse',), 'fields': ( 'attributes', ) From a7517d9c45efa915bc21081d7e87e1ed01f1fc59 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 18:42:05 -0500 Subject: [PATCH 15/92] =?UTF-8?q?GH-73:=20Rename=20c-offset-content=20?= =?UTF-8?q?=E2=86=92=20o-offset-content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Texascale: - Have c-offset-content extend o-offset-content styles - Add comment for legacy support and deprecation of c-offset-content --- taccsite_cms/contrib/helpers.py | 4 ++-- .../o-offset-content.css} | 17 +++++++++-------- taccsite_cms/static/site_cms/css/src/site.css | 4 ++-- taccsite_custom | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) rename taccsite_cms/static/site_cms/css/src/_imports/{components/c-offset-content.css => objects/o-offset-content.css} (66%) diff --git a/taccsite_cms/contrib/helpers.py b/taccsite_cms/contrib/helpers.py index 11879a55b..d63de0720 100644 --- a/taccsite_cms/contrib/helpers.py +++ b/taccsite_cms/contrib/helpers.py @@ -4,8 +4,8 @@ def get_offset_classname(offset): # TODO: Limit input to known offsets # SEE: taccsite_cms.contrib.constants:OFFSET_CHOICES switcher = { - 'right': 'c-offset-content--right', - 'left': 'c-offset-content--left' + 'right': 'o-offset-content--right', + 'left': 'o-offset-content--left' } return switcher.get(offset, '') diff --git a/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css similarity index 66% rename from taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css rename to taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css index 102a6f13b..1376779f2 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/components/c-offset-content.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css @@ -3,10 +3,11 @@ Offset Content Content that should be offset from the flow of text within which it is placed. -Styleguide Components.OffsetContent +Styleguide Objects.OffsetContent */ +@import url("_imports/tools/media-queries.css"); -[class*="c-offset-content--"] { +[class*="o-offset-content--"] { --offset-distance: 8.5vw; /* NOTE: Value is from Texascale.org 2020 */ --buffer: 30px; /* double Bootstrap `.col` padding */ @@ -14,25 +15,25 @@ Styleguide Components.OffsetContent } @media only screen and (--medium-and-above) { - .c-offset-content--right { + .o-offset-content--right { float: right; margin-left: var(--buffer); } - .c-offset-content--right + .c-offset-content--right { clear: right; } + .o-offset-content--right + .o-offset-content--right { clear: right; } - .c-offset-content--left { + .o-offset-content--left { float: left; margin-right: var(--buffer); } - .c-offset-content--left + .c-offset-content--left { clear: left; } + .o-offset-content--left + .o-offset-content--left { clear: left; } } /* WARNING: Value `2400px` is from Texascale.org 2020 */ @media only screen and (--medium-and-above) and (max-width: 2400px) { /* Apply negative margin only when using offset value */ - .c-offset-content--right { + .o-offset-content--right { margin-right: calc( var(--offset-distance) * -1); } - .c-offset-content--left { + .o-offset-content--left { margin-left: calc( var(--offset-distance) * -1); } } diff --git a/taccsite_cms/static/site_cms/css/src/site.css b/taccsite_cms/static/site_cms/css/src/site.css index 21b257785..c8b3acf6a 100644 --- a/taccsite_cms/static/site_cms/css/src/site.css +++ b/taccsite_cms/static/site_cms/css/src/site.css @@ -21,12 +21,12 @@ /* Load custom element styles within custom element, not here */ /* OBJECTS */ -@import url("_imports/objects/o-site.css"); +@import url("_imports/objects/o-offset-content.css"); @import url("_imports/objects/o-section.css"); +@import url("_imports/objects/o-site.css"); /* COMPONENTS */ @import url("_imports/components/c-footer.css"); -@import url("_imports/components/c-offset-content.css"); @import url("_imports/components/django.cms.css"); @import url("_imports/components/django.cms.blog.css"); @import url("_imports/components/django.cms.post.css"); diff --git a/taccsite_custom b/taccsite_custom index 8fa9c27c7..9c2a2f7a4 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 8fa9c27c72feeca46af92bf0331a5380cca3aa49 +Subproject commit 9c2a2f7a46e937fb8d808d71f9600f5edd516d1f From 4a55986178777fe698226aa9e6b752cd35306e3b Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 20:33:01 -0500 Subject: [PATCH 16/92] GH-73: Rename c-offset-content model prop --- .../migrations/0002_auto_20210621_2032.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py diff --git a/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py b/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py new file mode 100644 index 000000000..ff271ed7f --- /dev/null +++ b/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.16 on 2021-06-22 01:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taccsite_offset', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='taccsiteoffset', + name='alignment', + ), + migrations.AddField( + model_name='taccsiteoffset', + name='direction', + field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255), + ), + ] From d63e6ad113b2f5f52cd7fde4e92616931870bdb9 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 20:40:10 -0500 Subject: [PATCH 17/92] GH-73: Texascale: Deprecate Bootstrap blockquote --- taccsite_custom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_custom b/taccsite_custom index 9c2a2f7a4..4fe6ad799 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 9c2a2f7a46e937fb8d808d71f9600f5edd516d1f +Subproject commit 4fe6ad79967662adf3f0cca95e9a06b123866d9a From 10c57480dc100b7199559f295aa2392c79bfd7b3 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 20:51:09 -0500 Subject: [PATCH 18/92] GH-73: Support quotes in blockquote via CSS --- .../contrib/taccsite_blockquote/templates/blockquote.html | 2 +- .../static/site_cms/css/src/_imports/trumps/s-blockquote.css | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html index 565da399c..9e66c7622 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -1,6 +1,6 @@
-

{{ instance.text }}

+

{{ instance.text }}

{% if instance.use_cite %}
diff --git a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css index d288f5504..7c81be140 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/trumps/s-blockquote.css @@ -6,7 +6,7 @@ A [`
`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blo Markup:
-

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

+

Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.

Aldous Huxley, Brave New World
@@ -28,6 +28,8 @@ Styleguide Trumps.Scopes.Blockquote margin: 0; white-space: pre-wrap; } +.s-blockquote blockquote p::before { content: '“'; } +.s-blockquote blockquote p::after { content: '”'; } .s-blockquote figcaption { margin-top: 0.3em; From a047df5e7e360b7f33235933c2bdfab86d90111e Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 21 Jun 2021 21:05:13 -0500 Subject: [PATCH 19/92] =?UTF-8?q?GH-73:=20Move=20`offset-=E2=80=A6`=20max-?= =?UTF-8?q?width=20to=20media=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../css/src/_imports/objects/o-offset-content.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css index 1376779f2..79c59dac1 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css @@ -10,8 +10,7 @@ Styleguide Objects.OffsetContent [class*="o-offset-content--"] { --offset-distance: 8.5vw; /* NOTE: Value is from Texascale.org 2020 */ --buffer: 30px; /* double Bootstrap `.col` padding */ - - max-width: 50%; + --max-width: initial; } @media only screen and (--medium-and-above) { @@ -29,7 +28,10 @@ Styleguide Objects.OffsetContent } /* WARNING: Value `2400px` is from Texascale.org 2020 */ @media only screen and (--medium-and-above) and (max-width: 2400px) { - /* Apply negative margin only when using offset value */ + [class*="c-offset-content--"] { + --max-width: 50%; + } + /* Apply negative margin only when using offset value */ .o-offset-content--right { margin-right: calc( var(--offset-distance) * -1); } From cd45ab75e348cca784a52ded56fcaa1d6f490230 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 08:54:10 -0500 Subject: [PATCH 20/92] =?UTF-8?q?GH-73:=20Texascale:=20Use=202400px=20/=20?= =?UTF-8?q?`--max-wide-=E2=80=A6`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../site_cms/css/src/_imports/objects/o-offset-content.css | 3 +-- .../site_cms/css/src/_imports/tools/media-queries.css | 7 ++++++- taccsite_custom | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css index 79c59dac1..e976559af 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/objects/o-offset-content.css @@ -26,8 +26,7 @@ Styleguide Objects.OffsetContent } .o-offset-content--left + .o-offset-content--left { clear: left; } } -/* WARNING: Value `2400px` is from Texascale.org 2020 */ -@media only screen and (--medium-and-above) and (max-width: 2400px) { +@media only screen and (--medium-and-above) and (--max-wide-and-below) { [class*="c-offset-content--"] { --max-width: 50%; } diff --git a/taccsite_cms/static/site_cms/css/src/_imports/tools/media-queries.css b/taccsite_cms/static/site_cms/css/src/_imports/tools/media-queries.css index 2b2e4df19..1671ae32d 100644 --- a/taccsite_cms/static/site_cms/css/src/_imports/tools/media-queries.css +++ b/taccsite_cms/static/site_cms/css/src/_imports/tools/media-queries.css @@ -11,6 +11,7 @@ Notice: These must be Tools (imported as needed) until native browser support, a Reference: - https://drafts.csswg.org/mediaqueries-5/#at-ruledef-custom-media +- https://confluence.tacc.utexas.edu/x/b4AZCg Styleguide Tools.CustomMediaQueries.Breakpoints */ @@ -40,4 +41,8 @@ Styleguide Tools.CustomMediaQueries.Breakpoints @custom-media --xxx-wide-and-below (width < 1920px); @custom-media --xxx-wide-and-above (width >= 1920px); -/* @custom-media --xxx-wide-to-omg-wide (... <= width < ...); */ +@custom-media --xxx-wide-to-max-wide (1920px <= width < 2400px); + +@custom-media --max-wide-and-below (width < 2400px); +@custom-media --max-wide-and-above (width >= 2400px); +/* @custom-media --max-wide-to-god-wide (... <= width < ...); */ diff --git a/taccsite_custom b/taccsite_custom index 4fe6ad799..25f3575fc 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 4fe6ad79967662adf3f0cca95e9a06b123866d9a +Subproject commit 25f3575fc7b07ff09a83d894c7663815c4770c1c From 2eee71a35ff48ac5e3f51fd3da908c407056bd9b Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 09:09:55 -0500 Subject: [PATCH 21/92] GH-73: Recreate migrations from zero --- .../migrations/0001_initial.py | 12 +++- .../migrations/0002_auto_20210616_1214.py | 38 ------------- .../migrations/0003_auto_20210616_1544.py | 18 ------ ...6_1710_squashed_0012_auto_20210616_1910.py | 55 ------------------- ...offset_squashed_0006_auto_20210616_2022.py | 18 ------ .../migrations/0001_initial.py | 6 +- .../migrations/0002_auto_20210621_2032.py | 22 -------- 7 files changed, 14 insertions(+), 155 deletions(-) delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py delete mode 100644 taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py delete mode 100644 taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py index 7271dc62c..8c1fd019b 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py +++ b/taccsite_cms/contrib/taccsite_blockquote/migrations/0001_initial.py @@ -1,7 +1,8 @@ -# Generated by Django 2.2.16 on 2021-04-13 20:15 +# Generated by Django 2.2.16 on 2021-06-22 14:09 from django.db import migrations, models import django.db.models.deletion +import djangocms_attributes_field.fields class Migration(migrations.Migration): @@ -17,7 +18,14 @@ class Migration(migrations.Migration): name='TaccsiteBlockquote', fields=[ ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_blockquote_taccsiteblockquote', serialize=False, to='cms.CMSPlugin')), - ('guest_name', models.CharField(blank=True, default='Guest', help_text='If user is logged in they are greeted by their name. If not logged in, they are greeted as this value. If this value is blank, they are greeted as "Guest".', max_length=50)), + ('text', models.TextField(default='', null=True, verbose_name='Quote')), + ('origin', models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.', max_length=100)), + ('use_cite', models.BooleanField(default=False, verbose_name='Use the "Citation" fields')), + ('cite_person', models.CharField(blank=True, help_text='The author or speaker of the quote.', max_length=50, verbose_name='Author / Speaker')), + ('cite_text', models.CharField(blank=True, help_text='Text for the source of the quote.', max_length=50, verbose_name='Source Text')), + ('cite_url', models.CharField(blank=True, help_text='URL for the source of the quote.', max_length=255, verbose_name='Source URL')), + ('offset', models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255)), + ('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), ], options={ 'abstract': False, diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py deleted file mode 100644 index c53e3c74e..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0002_auto_20210616_1214.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 2.2.16 on 2021-06-16 17:14 - -from django.db import migrations, models -import djangocms_attributes_field.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ('taccsite_blockquote', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='taccsiteblockquote', - name='guest_name', - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='attributes', - field=djangocms_attributes_field.fields.AttributesField(default=dict), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='quote_alignment', - field=models.CharField(blank=True, choices=[('text-left', 'Left'), ('text-center', 'Center'), ('text-right', 'Right')], default='text-left', max_length=255), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='quote_origin', - field=models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source).', max_length=50), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='quote_text', - field=models.TextField(default=None), - ), - ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py deleted file mode 100644 index 667ac50ca..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0003_auto_20210616_1544.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.16 on 2021-06-16 20:44 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('taccsite_blockquote', '0002_auto_20210616_1214'), - ] - - operations = [ - migrations.AlterField( - model_name='taccsiteblockquote', - name='quote_alignment', - field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], default='left', max_length=255), - ), - ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py deleted file mode 100644 index 306bcf806..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0004_auto_20210616_1710_squashed_0012_auto_20210616_1910.py +++ /dev/null @@ -1,55 +0,0 @@ -# Generated by Django 2.2.16 on 2021-06-17 00:20 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('taccsite_blockquote', '0003_auto_20210616_1544'), - ] - - operations = [ - migrations.RemoveField( - model_name='taccsiteblockquote', - name='quote_alignment', - ), - migrations.RemoveField( - model_name='taccsiteblockquote', - name='quote_origin', - ), - migrations.RemoveField( - model_name='taccsiteblockquote', - name='quote_text', - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='origin', - field=models.CharField(blank=True, help_text='The origin of the quote (i.e. citation, attribution) (e.g. author, source). This value is ignored if "Advanced origin" fields have data.', max_length=100), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='cite_person', - field=models.CharField(blank=True, help_text='The author or speaker of the quote.', max_length=50, verbose_name='Author / Speaker'), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='use_cite', - field=models.BooleanField(default=False, verbose_name='Use the "Citation" fields'), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='cite_url', - field=models.CharField(blank=True, help_text='URL for the source of the quote.', max_length=255, verbose_name='Source URL'), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='cite_text', - field=models.CharField(blank=True, help_text='Text for the source of the quote.', max_length=50, verbose_name='Source Text'), - ), - migrations.AddField( - model_name='taccsiteblockquote', - name='text', - field=models.TextField(default='', null=True, verbose_name='Quote'), - ), - ] diff --git a/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py b/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py deleted file mode 100644 index f5076837a..000000000 --- a/taccsite_cms/contrib/taccsite_blockquote/migrations/0005_taccsiteblockquote_offset_squashed_0006_auto_20210616_2022.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.16 on 2021-06-17 14:18 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('taccsite_blockquote', '0004_auto_20210616_1710_squashed_0012_auto_20210616_1910'), - ] - - operations = [ - migrations.AddField( - model_name='taccsiteblockquote', - name='offset', - field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255), - ), - ] diff --git a/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py index 5542b0410..37d4b021b 100644 --- a/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py +++ b/taccsite_cms/contrib/taccsite_offset/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.16 on 2021-06-17 00:45 +# Generated by Django 2.2.16 on 2021-06-22 14:09 from django.db import migrations, models import django.db.models.deletion @@ -7,6 +7,8 @@ class Migration(migrations.Migration): + initial = True + dependencies = [ ('cms', '0022_auto_20180620_1551'), ] @@ -16,7 +18,7 @@ class Migration(migrations.Migration): name='TaccsiteOffset', fields=[ ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_offset_taccsiteoffset', serialize=False, to='cms.CMSPlugin')), - ('alignment', models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], default='left', max_length=255)), + ('direction', models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255)), ('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), ], options={ diff --git a/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py b/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py deleted file mode 100644 index ff271ed7f..000000000 --- a/taccsite_cms/contrib/taccsite_offset/migrations/0002_auto_20210621_2032.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 2.2.16 on 2021-06-22 01:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('taccsite_offset', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='taccsiteoffset', - name='alignment', - ), - migrations.AddField( - model_name='taccsiteoffset', - name='direction', - field=models.CharField(blank=True, choices=[('left', 'Left'), ('right', 'Right')], max_length=255), - ), - ] From 38317320c1563557e9dc1cf876869425e6ceef22 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 10:00:28 -0500 Subject: [PATCH 22/92] GH-73: Cleanup constants & helpers & offset --- taccsite_cms/contrib/constants.py | 8 ------ taccsite_cms/contrib/helpers.py | 12 -------- .../taccsite_blockquote/cms_plugins.py | 6 ++-- .../contrib/taccsite_blockquote/models.py | 4 +-- .../contrib/taccsite_offset/cms_plugins.py | 6 ++-- .../contrib/taccsite_offset/models.py | 28 +++++++++++++++---- 6 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 taccsite_cms/contrib/constants.py diff --git a/taccsite_cms/contrib/constants.py b/taccsite_cms/contrib/constants.py deleted file mode 100644 index a812b59f6..000000000 --- a/taccsite_cms/contrib/constants.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.utils.translation import gettext_lazy as _ - -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/constants.py -ALIGN_CHOICES = ( - ('left', _('Left')), - ('center', _('Center')), - ('right', _('Right')), -) diff --git a/taccsite_cms/contrib/helpers.py b/taccsite_cms/contrib/helpers.py index d63de0720..25b9cbf03 100644 --- a/taccsite_cms/contrib/helpers.py +++ b/taccsite_cms/contrib/helpers.py @@ -1,15 +1,3 @@ -def get_offset_classname(offset): - """Get offset content class based on standard offset value.""" - - # TODO: Limit input to known offsets - # SEE: taccsite_cms.contrib.constants:OFFSET_CHOICES - switcher = { - 'right': 'o-offset-content--right', - 'left': 'o-offset-content--left' - } - - return switcher.get(offset, '') - # SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py def concat_classnames(classes): """ diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 2aab945f9..9a9aef492 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -4,7 +4,9 @@ from cms.plugin_pool import plugin_pool from django.utils.translation import gettext_lazy as _ -from taccsite_cms.contrib.helpers import concat_classnames, get_offset_classname +from taccsite_cms.contrib.helpers import concat_classnames + +from taccsite_cms.contrib.taccsite_offset.models import get_direction_classname from .models import TaccsiteBlockquote @@ -58,7 +60,7 @@ def render(self, context, instance, placeholder): classes = concat_classnames([ 's-blockquote', - get_offset_classname(instance.offset), + get_direction_classname(instance.offset), instance.attributes.get('class'), ]) instance.attributes['class'] = classes diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index 81a73b898..1345c228d 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -7,7 +7,7 @@ from djangocms_attributes_field import fields -from taccsite_cms.contrib.taccsite_offset.models import TaccsiteOffset +from taccsite_cms.contrib.taccsite_offset.models import DIRECTION_CHOICES class TaccsiteBlockquote(CMSPlugin): """ @@ -50,7 +50,7 @@ class TaccsiteBlockquote(CMSPlugin): ) offset = models.CharField( - choices=TaccsiteOffset.DIRECTION_CHOICES, + choices=DIRECTION_CHOICES, blank=True, max_length=255, ) diff --git a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py index 973823d34..d780e9d9d 100644 --- a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py @@ -5,9 +5,9 @@ from django.utils.translation import gettext_lazy as _ -from taccsite_cms.contrib.helpers import concat_classnames, get_offset_classname +from taccsite_cms.contrib.helpers import concat_classnames -from .models import TaccsiteOffset +from .models import TaccsiteOffset, get_direction_classname @plugin_pool.register_plugin class TaccsiteOffsetPlugin(CMSPluginBase): @@ -45,7 +45,7 @@ def render(self, context, instance, placeholder): request = context['request'] classes = concat_classnames([ - get_offset_classname(instance.direction), + get_direction_classname(instance.direction), instance.attributes.get('class'), ]) instance.attributes['class'] = classes diff --git a/taccsite_cms/contrib/taccsite_offset/models.py b/taccsite_cms/contrib/taccsite_offset/models.py index a8afa1452..beb905351 100644 --- a/taccsite_cms/contrib/taccsite_offset/models.py +++ b/taccsite_cms/contrib/taccsite_offset/models.py @@ -7,16 +7,34 @@ from djangocms_attributes_field import fields +# Constants + +DIRECTION_CHOICES = ( + ('left', _('Left')), + # ('center', _('Center')), # GH-66: Support centered offset content + ('right', _('Right')), +) + +# Helpers + +def get_direction_classname(offset): + """Get offset content class based on standard offset value.""" + + # HELP: Should we limit input by coupling this map to DIRECTION_CHOICES? + switcher = { + 'right': 'o-offset-content--right', + 'left': 'o-offset-content--left' + } + + return switcher.get(offset, '') + +# Models + class TaccsiteOffset(CMSPlugin): """ Components > "Offset Content" Model https://confluence.tacc.utexas.edu/x/GIEjCQ """ - DIRECTION_CHOICES = ( - ('left', _('Left')), - ('right', _('Right')), - ) - direction = models.CharField( choices=DIRECTION_CHOICES, blank=True, From 956e12dce53209de38a72645b67b1de0c09254ee Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 10:13:00 -0500 Subject: [PATCH 23/92] GH-73: Texascale: Noop: Comment text tweak --- taccsite_custom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_custom b/taccsite_custom index 25f3575fc..03154f968 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 25f3575fc7b07ff09a83d894c7663815c4770c1c +Subproject commit 03154f9682970723cff9880fe63eeaa7e99b2827 From 27b3dd3990f847ba3c8e30dd3a18c2ad034eee0c Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 10:55:46 -0500 Subject: [PATCH 24/92] Quick: Update taccsite_custom --- taccsite_custom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taccsite_custom b/taccsite_custom index 3933a9b53..fc4ad9530 160000 --- a/taccsite_custom +++ b/taccsite_custom @@ -1 +1 @@ -Subproject commit 3933a9b53faa51a79fdfedf8aaad90b8400ad3eb +Subproject commit fc4ad953055cd3448a55543c585321dc5141f063 From 37228adb554157ed6b3070a382e6bc7e3b8c79aa Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 20:19:16 -0500 Subject: [PATCH 25/92] GH-93: Article List Plugin --- .../contrib/taccsite_article_list/__init__.py | 0 .../taccsite_article_list/cms_plugins.py | 69 ++++++++++++ .../migrations/0001_initial.py | 33 ++++++ .../migrations/__init__.py | 0 .../contrib/taccsite_article_list/models.py | 104 ++++++++++++++++++ .../templates/article_list.html | 19 ++++ taccsite_cms/settings.py | 1 + 7 files changed, 226 insertions(+) create mode 100644 taccsite_cms/contrib/taccsite_article_list/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_article_list/cms_plugins.py create mode 100644 taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py create mode 100644 taccsite_cms/contrib/taccsite_article_list/migrations/__init__.py create mode 100644 taccsite_cms/contrib/taccsite_article_list/models.py create mode 100644 taccsite_cms/contrib/taccsite_article_list/templates/article_list.html diff --git a/taccsite_cms/contrib/taccsite_article_list/__init__.py b/taccsite_cms/contrib/taccsite_article_list/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_article_list/cms_plugins.py b/taccsite_cms/contrib/taccsite_article_list/cms_plugins.py new file mode 100644 index 000000000..4156971f9 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_article_list/cms_plugins.py @@ -0,0 +1,69 @@ +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_article_list.models import ( + get_layout_classname, get_content_classname, get_style_classname +) + +from .models import TaccsiteArticleList + +@plugin_pool.register_plugin +class TaccsiteArticleListPlugin(CMSPluginBase): + """ + Components > "Article List" Plugin + https://confluence.tacc.utexas.edu/x/FIEjCQ + """ + module = 'TACC Site' + model = TaccsiteArticleList + name = _('Article List') + render_template = 'article_list.html' + + cache = True + text_enabled = False + allow_children = True + # TODO: Create taccsite_article_preview + # child_classes = ['TaccsiteArticlePreviewPlugin'] + + fieldsets = [ + (None, { + 'fields': ( + 'header_title_text', + 'footer_link_text', + ) + }), + (_('Options'), { + 'fields': ( + 'content_type', + ('layout_type', 'style_type') + ) + }), + (_('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([ + 'c-article-list', + get_layout_classname(instance.layout_type), + get_content_classname(instance.content_type), + get_style_classname(instance.style_type), + instance.attributes.get('class'), + ]) + instance.attributes['class'] = classes + + # for plugin_instance in instance.child_plugin_instances: + # plugin_instance.attributes['class'] += 'c-article-list__item' + + return context diff --git a/taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py new file mode 100644 index 000000000..bf7f26a50 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py @@ -0,0 +1,33 @@ +# Generated by Django 2.2.16 on 2021-06-23 01:21 + +from django.db import migrations, models +import django.db.models.deletion +import djangocms_attributes_field.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ] + + operations = [ + migrations.CreateModel( + name='TaccsiteArticleList', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_article_list_taccsitearticlelist', serialize=False, to='cms.CMSPlugin')), + ('header_title_text', models.CharField(blank=True, help_text='The title at the top of the list.', max_length=100)), + ('footer_link_text', models.CharField(blank=True, help_text='The "See All ..." link at the bottom of the list.', max_length=100)), + ('content_type', models.CharField(blank=True, choices=[('news', 'News'), ('docs', 'Documents'), ('allocs', 'Allocations'), ('events', 'Events')], max_length=255)), + ('layout_type', models.CharField(blank=True, choices=[('always-rows-N--even', '(always) N Even Rows'), ('widest-cols-2--even', '(at widest) 2 Equal Columns'), ('widest-cols-2--wide-narr', '(at widest) 2 Cols: 1 Wide, 1 Narrow'), ('widest-cols-2--narr-wide', '(at widest) 2 Cols: 1 Narrow, 1 Wide'), ('widest-cols-3--even', '(at widest) 3 Equal Columns')], default='always-rows-N--even', max_length=255)), + ('style_type', models.CharField(blank=True, choices=[('divided', 'Dividers Between Articles')], max_length=255)), + ('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_article_list/migrations/__init__.py b/taccsite_cms/contrib/taccsite_article_list/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_article_list/models.py b/taccsite_cms/contrib/taccsite_article_list/models.py new file mode 100644 index 000000000..5383e7c5f --- /dev/null +++ b/taccsite_cms/contrib/taccsite_article_list/models.py @@ -0,0 +1,104 @@ +from cms.models.pluginmodel import CMSPlugin +from django.utils.translation import gettext_lazy as _ + +from django.db import models + +from djangocms_attributes_field import fields + +# Constants + +CONTENT_CHOICES = ( + ('news', _('News')), + ('docs', _('Documents')), + ('allocs', _('Allocations')), + ('events', _('Events')), +) +LAYOUT_CHOICES = ( + ('always-rows-N--even', _('(always) N Even Rows')), + ('widest-cols-2--even', _('(at widest) 2 Equal Columns')), + ('widest-cols-2--wide-narr', _('(at widest) 2 Cols: 1 Wide, 1 Narrow')), + ('widest-cols-2--narr-wide', _('(at widest) 2 Cols: 1 Narrow, 1 Wide')), + ('widest-cols-3--even', _('(at widest) 3 Equal Columns')), +) +STYLE_CHOICES = ( + ('divided', _('Dividers Between Articles')), +) + +# Helpers + +def get_content_classname(value): + """Get content class based on value.""" + + # TODO: Couple this map to TYPE_CHOICES + switcher = { + 'news': 's-article-list--news', + 'docs': 's-article-list--links', + 'allocs': 's-article-list--allocations', + 'events': 's-article-list--events', + } + + return switcher.get(value, '') + +def get_layout_classname(value): + """Get layout class based on value.""" + + # TODO: Couple this map to LAYOUT_CHOICES + switcher = { + 'widest-cols-2--even': 'c-article-list--layout-a', + 'widest-cols-2--wide-narr': 'c-article-list--layout-b', + 'widest-cols-2--narr-wide': 'c-article-list--layout-c', + 'widest-cols-3--even': 'c-article-list--layout-d', + 'always-rows-N--even': 'c-article-list--layout-e', + } + + return switcher.get(value, '') + +def get_style_classname(value): + """Get style class based on value.""" + + # TODO: Couple this map to STYLE_CHOICES + switcher = { + 'divided': 'c-article-list--style-divided', + } + + return switcher.get(value, '') + +# Models + +class TaccsiteArticleList(CMSPlugin): + """ + Components > "Article List" Model + https://confluence.tacc.utexas.edu/x/FIEjCQ + """ + header_title_text = models.CharField( + help_text='The title at the top of the list.', + blank=True, + max_length=100, + ) + footer_link_text = models.CharField( + help_text='The "See All ..." link at the bottom of the list.', + blank=True, + max_length=100, + ) + + content_type = models.CharField( + choices=CONTENT_CHOICES, + blank=True, + max_length=255, + ) + layout_type = models.CharField( + choices=LAYOUT_CHOICES, + default=LAYOUT_CHOICES[0][0], + blank=True, + max_length=255, + ) + style_type = models.CharField( + choices=STYLE_CHOICES, + blank=True, + max_length=255, + ) + + attributes = fields.AttributesField() + + def get_short_description(self): + return self.header_title_text diff --git a/taccsite_cms/contrib/taccsite_article_list/templates/article_list.html b/taccsite_cms/contrib/taccsite_article_list/templates/article_list.html new file mode 100644 index 000000000..7fa55bc3e --- /dev/null +++ b/taccsite_cms/contrib/taccsite_article_list/templates/article_list.html @@ -0,0 +1,19 @@ +{% load cms_tags %} + +
+

+ {{ instance.header_title_text }} +

+ {% for plugin_instance in instance.child_plugin_instances %} + {#
#} + {% render_plugin plugin_instance %} + {% endfor %} + +
diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 4b548fb00..538fd4672 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -243,6 +243,7 @@ def getsecrets(): 'taccsite_cms.contrib.taccsite_sample', 'taccsite_cms.contrib.taccsite_blockquote', 'taccsite_cms.contrib.taccsite_offset', + 'taccsite_cms.contrib.taccsite_article_list', ] # Convert list of paths to list of dotted module names From b510c757342a8d4d978e73a03f6897baf31a41a9 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Tue, 22 Jun 2021 20:20:20 -0500 Subject: [PATCH 26/92] GH-93: Polish Existing Plugins --- .../contrib/taccsite_blockquote/cms_plugins.py | 5 ++--- taccsite_cms/contrib/taccsite_blockquote/models.py | 2 -- .../taccsite_blockquote/templates/blockquote.html | 2 +- taccsite_cms/contrib/taccsite_offset/cms_plugins.py | 4 +--- taccsite_cms/contrib/taccsite_offset/models.py | 10 ++++------ .../contrib/taccsite_offset/templates/offset.html | 6 +++--- taccsite_cms/contrib/taccsite_sample/cms_plugins.py | 1 + 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py index 9a9aef492..83cd1bada 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_blockquote/cms_plugins.py @@ -1,5 +1,3 @@ -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/cms_plugins.py#L41 - from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.utils.translation import gettext_lazy as _ @@ -21,8 +19,9 @@ class TaccsiteBlockquotePlugin(CMSPluginBase): name = _('Blockquote') render_template = 'blockquote.html' - cache = False + cache = True text_enabled = True + allow_children = False fieldsets = [ (None, { diff --git a/taccsite_cms/contrib/taccsite_blockquote/models.py b/taccsite_cms/contrib/taccsite_blockquote/models.py index 1345c228d..9313b15fd 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/models.py +++ b/taccsite_cms/contrib/taccsite_blockquote/models.py @@ -1,5 +1,3 @@ -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/models.py - from cms.models.pluginmodel import CMSPlugin from django.utils.translation import gettext_lazy as _ diff --git a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html index 9e66c7622..71fea29cd 100644 --- a/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html +++ b/taccsite_cms/contrib/taccsite_blockquote/templates/blockquote.html @@ -1,4 +1,4 @@ -
+

{{ instance.text }}

diff --git a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py index d780e9d9d..c2d1da73e 100644 --- a/taccsite_cms/contrib/taccsite_offset/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_offset/cms_plugins.py @@ -1,5 +1,3 @@ -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/cms_plugins.py#L41 - from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -20,7 +18,7 @@ class TaccsiteOffsetPlugin(CMSPluginBase): name = _('Offset Content') render_template = 'offset.html' - cache = False + cache = True text_enabled = False allow_children = True diff --git a/taccsite_cms/contrib/taccsite_offset/models.py b/taccsite_cms/contrib/taccsite_offset/models.py index beb905351..149941b80 100644 --- a/taccsite_cms/contrib/taccsite_offset/models.py +++ b/taccsite_cms/contrib/taccsite_offset/models.py @@ -1,5 +1,3 @@ -# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_content/models.py - from cms.models.pluginmodel import CMSPlugin from django.db import models @@ -17,16 +15,16 @@ # Helpers -def get_direction_classname(offset): - """Get offset content class based on standard offset value.""" +def get_direction_classname(value): + """Get direction class based on value.""" - # HELP: Should we limit input by coupling this map to DIRECTION_CHOICES? + # TODO: Couple this map to DIRECTION_CHOICES switcher = { 'right': 'o-offset-content--right', 'left': 'o-offset-content--left' } - return switcher.get(offset, '') + return switcher.get(value, '') # Models diff --git a/taccsite_cms/contrib/taccsite_offset/templates/offset.html b/taccsite_cms/contrib/taccsite_offset/templates/offset.html index 98edf0c42..583ca7ad0 100644 --- a/taccsite_cms/contrib/taccsite_offset/templates/offset.html +++ b/taccsite_cms/contrib/taccsite_offset/templates/offset.html @@ -1,7 +1,7 @@ {% load cms_tags %} -
- + diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/README.md b/taccsite_cms/contrib/taccsite_static_article_preview/README.md new file mode 100644 index 000000000..58dd6ec4c --- /dev/null +++ b/taccsite_cms/contrib/taccsite_static_article_preview/README.md @@ -0,0 +1,52 @@ +# Static Articles + +## Intention + +Support static addition of news articles that originate from a Core news site. + +A [dynamic solution that pulls form the Core news site](https://github.com/TACC/Core-CMS/issues/69) is preferable. + +But this is not available due to constrainst of architecture, time, or ability. + +## Architectural Decisions + +## Add Image via Child Plugin Instead of Via Fields + +Ideally, the image fields are in the plugin, not a child plugin. + +Wesley failed to achieve that functionality: +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 that he [should not try to reduce `AbstractPicture`](https://stackoverflow.com/a/3674714/11817077). + +This is the relevant code he abandoned: +```python +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 + + def clean(self): + skip_image_validation() +``` diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/__init__.py b/taccsite_cms/contrib/taccsite_static_article_preview/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py b/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py new file mode 100644 index 000000000..d2754a3dc --- /dev/null +++ b/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py @@ -0,0 +1,99 @@ +from cms.plugin_pool import plugin_pool +from django.utils.translation import gettext_lazy as _ + +from taccsite_cms.contrib.helpers import ( + concat_classnames, + insert_at_position, + CMSPluginBaseWithMaxChildren +) + +from .models import TaccsiteStaticNewsArticlePreview, MEDIA_SUPPORT_CHOICES + +# Base + +class ArticlePreviewPlugin(CMSPluginBaseWithMaxChildren): + cache = True + text_enabled = False + allow_children = False + + fieldsets = [ + (_('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([ + 'c-article-preview', + instance.attributes.get('class'), + ]) + instance.attributes['class'] = classes + + context.update({ + 'kind': self.kind + }) + return context + +# Plugins + +@plugin_pool.register_plugin +class TaccsiteStaticNewsArticlePreviewPlugin(ArticlePreviewPlugin): + """ + Components > "(Static) News Article Preview" Plugin + https://confluence.tacc.utexas.edu/x/OYAjCQ + """ + module = 'TACC Site' + model = TaccsiteStaticNewsArticlePreview + name = _('(Static) News Article Preview') + render_template = 'static_article_preview.html' + + cache = True + text_enabled = False + allow_children = False + child_classes = [ + 'PicturePlugin', # HELP: Why is this not available in plugin list? + 'Bootstrap4PicturePlugin' + ] + parent_classes = [ + 'TaccsiteArticleListPlugin' + ] + # NOTE: Should article previews be allowed to exist in isolation? + # Consider [hero banner](https://github.com/TACC/Core-CMS/issues/134). + # require_parent = True + + fieldsets = insert_at_position(0, ArticlePreviewPlugin.fieldsets, [ + (None, { + # To enable these fields, see `./README.md` + # 'fields': ('picture', 'external_picture') + 'fields': ('title_text', 'abstract_text') + }), + (_('Image'), { + # To enable these fields, see `./README.md` + # 'fields': ('picture', 'external_picture') + 'fields': ('media_support',) + }), + (_('Metadata'), { + 'fields': ('publish_date', 'type_text', 'author_text') + }), + ]) + + # Custom Properties + + kind = 'news' + + # Set `readonly_fields` that can be populated upon instance creation + # SEE: https://stackoverflow.com/a/17614057/11817077 + # HELP: Instead, how can we disable a field with minimal effort? + def get_readonly_fields(self, request, obj=None): + if obj: # i.e. user is editing instance + return ['media_support'] if len(MEDIA_SUPPORT_CHOICES) == 1 else [] + else: # i.e. user is creating instance + return [] diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_static_article_preview/migrations/0001_initial.py new file mode 100644 index 000000000..9eeed0fd2 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_static_article_preview/migrations/0001_initial.py @@ -0,0 +1,34 @@ +# Generated by Django 2.2.16 on 2021-06-23 23:08 + +from django.db import migrations, models +import django.db.models.deletion +import djangocms_attributes_field.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ] + + operations = [ + migrations.CreateModel( + name='TaccsiteStaticNewsArticlePreview', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_static_article_preview_taccsitestaticnewsarticlepreview', serialize=False, to='cms.CMSPlugin')), + ('media_support', models.CharField(choices=[('nested', 'Nest a single Picture / Image plugin inside this plugin.')], default='nested', max_length=255, verbose_name='How to Add an Image')), + ('title_text', models.CharField(default='', help_text='The title for the article.', max_length=50, verbose_name='Title')), + ('abstract_text', models.TextField(default='', help_text='A summary of the article', verbose_name='Abstract')), + ('type_text', models.CharField(blank=True, help_text='The type of the article, ex: "Science News", "Press Release" (manual entry).', max_length=50, verbose_name='Type')), + ('author_text', models.CharField(blank=True, help_text='The author of the article (manual entry).', max_length=50, verbose_name='Author')), + ('publish_date', models.DateField(blank=True, help_text='The date the article was published (manual entry). Format: YYYY-MM-DD', null=True, verbose_name='Date Published')), + ('attributes', djangocms_attributes_field.fields.AttributesField(default=dict)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/migrations/__init__.py b/taccsite_cms/contrib/taccsite_static_article_preview/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/models.py b/taccsite_cms/contrib/taccsite_static_article_preview/models.py new file mode 100644 index 000000000..b3cad7e19 --- /dev/null +++ b/taccsite_cms/contrib/taccsite_static_article_preview/models.py @@ -0,0 +1,82 @@ +from cms.models.pluginmodel import CMSPlugin +from django.utils.translation import gettext_lazy as _ + +from django.db import models + +from djangocms_attributes_field import fields + +# Constants + +MEDIA_SUPPORT_CHOICES = ( + ('nested', _('Nest a single Picture / Image plugin inside this plugin.')), + # ('direct', _('Choose / Define an image directly within this plugin.')), +) + +# Helpers + +# This field lets us: +# - (for user) describe how to add media +# - (for code) identify instances added before media could be directly added +def create_media_support_field(blank=False): + return models.CharField( + choices=MEDIA_SUPPORT_CHOICES, + verbose_name=_('How to Add an Image'), + default=MEDIA_SUPPORT_CHOICES[0][0], + blank=blank, + max_length=255, + ) + +def create_title_text_field(blank=True): + return models.CharField( + verbose_name=_('Title'), + help_text='The title for the article.', + blank=blank, + max_length=50, + default='' + ) + +def create_abstract_text_field(blank=True): + return models.TextField( + verbose_name=_('Abstract'), + help_text='A summary of the article', + blank=blank, + default='' + ) + +def create_type_text_field(blank=True): + return models.CharField( + verbose_name=_('Type'), + help_text='The type of the article, ex: "Science News", "Press Release" (manual entry).', + blank=blank, + max_length=50 + ) + +def create_author_text_field(blank=True): + return models.CharField( + verbose_name=_('Author'), + help_text='The author of the article (manual entry).', + blank=blank, + max_length=50, + ) + +def create_publish_date_field(blank=True): + return models.DateField( + verbose_name=_('Date Published'), + help_text='The date the article was published (manual entry). Format: YYYY-MM-DD', + blank=blank, + null=True, + ) + + + +# Models + +class TaccsiteStaticNewsArticlePreview(CMSPlugin): + media_support = create_media_support_field(blank=False) + title_text = create_title_text_field(blank=False) + abstract_text = create_abstract_text_field(blank=False) + type_text = create_type_text_field() + author_text = create_author_text_field() + publish_date = create_publish_date_field() + + attributes = fields.AttributesField() diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/templates/static_article_preview.html b/taccsite_cms/contrib/taccsite_static_article_preview/templates/static_article_preview.html new file mode 100644 index 000000000..a4ad242ed --- /dev/null +++ b/taccsite_cms/contrib/taccsite_static_article_preview/templates/static_article_preview.html @@ -0,0 +1,41 @@ +{% load cms_tags %} + +
+ {# Media e.g. image thumbnail #} + {% for plugin_instance in instance.child_plugin_instances %} + {% render_plugin plugin_instance %} + {% endfor %} + + {# Title #} +

+ {{ instance.title_text }} +

+ + {# Abstract #} + {% if kind != 'allocs' %} +

+ {{ instance.abstract_text }} +

+ {% endif %} + + {# Date #} + {% if kind != 'docs' %} + + {% endif %} + + {# Type #} + {% if kind == 'news' %} + {{ instance.type_text }} + {% endif %} + + {# Author #} + {# FAQ: Not shown in design #} + {% comment %} + {{ instance.author_text }} + {% endcomment %} +
diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 538fd4672..6fd90c2da 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -244,6 +244,7 @@ def getsecrets(): 'taccsite_cms.contrib.taccsite_blockquote', 'taccsite_cms.contrib.taccsite_offset', 'taccsite_cms.contrib.taccsite_article_list', + 'taccsite_cms.contrib.taccsite_static_article_preview', ] # Convert list of paths to list of dotted module names From c266eec4a5103860afe88228248776d8d0eb7587 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 23 Jun 2021 18:37:32 -0500 Subject: [PATCH 28/92] GH-93: Rename Article List Plugin (add Static) - Add "(Static)" to "Article List" plugin human name. - Add `static_` to `article_list` plugin code name. - Move "(Static)" in "Article Preview" plugin human name. --- .../README.md | 0 .../__init__.py | 0 .../cms_plugins.py | 4 ++-- .../migrations/0001_initial.py | 4 ++-- .../migrations/__init__.py | 0 .../models.py | 0 .../templates/article_list.html | 0 .../contrib/taccsite_static_article_preview/cms_plugins.py | 2 +- taccsite_cms/settings.py | 2 +- 9 files changed, 6 insertions(+), 6 deletions(-) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/README.md (100%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/__init__.py (100%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/cms_plugins.py (94%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/migrations/0001_initial.py (90%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/migrations/__init__.py (100%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/models.py (100%) rename taccsite_cms/contrib/{taccsite_article_list => taccsite_static_article_list}/templates/article_list.html (100%) diff --git a/taccsite_cms/contrib/taccsite_article_list/README.md b/taccsite_cms/contrib/taccsite_static_article_list/README.md similarity index 100% rename from taccsite_cms/contrib/taccsite_article_list/README.md rename to taccsite_cms/contrib/taccsite_static_article_list/README.md diff --git a/taccsite_cms/contrib/taccsite_article_list/__init__.py b/taccsite_cms/contrib/taccsite_static_article_list/__init__.py similarity index 100% rename from taccsite_cms/contrib/taccsite_article_list/__init__.py rename to taccsite_cms/contrib/taccsite_static_article_list/__init__.py diff --git a/taccsite_cms/contrib/taccsite_article_list/cms_plugins.py b/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py similarity index 94% rename from taccsite_cms/contrib/taccsite_article_list/cms_plugins.py rename to taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py index de70d8b68..7fe55c3a2 100644 --- a/taccsite_cms/contrib/taccsite_article_list/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py @@ -3,7 +3,7 @@ from django.utils.translation import gettext_lazy as _ from taccsite_cms.contrib.helpers import concat_classnames -from taccsite_cms.contrib.taccsite_article_list.models import ( +from taccsite_cms.contrib.taccsite_static_article_list.models import ( get_layout_classname, get_content_classname, get_style_classname ) @@ -17,7 +17,7 @@ class TaccsiteArticleListPlugin(CMSPluginBase): """ module = 'TACC Site' model = TaccsiteArticleList - name = _('Article List') + name = _('Article List (Static)') render_template = 'article_list.html' cache = True diff --git a/taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py b/taccsite_cms/contrib/taccsite_static_article_list/migrations/0001_initial.py similarity index 90% rename from taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py rename to taccsite_cms/contrib/taccsite_static_article_list/migrations/0001_initial.py index bf7f26a50..a36879020 100644 --- a/taccsite_cms/contrib/taccsite_article_list/migrations/0001_initial.py +++ b/taccsite_cms/contrib/taccsite_static_article_list/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.16 on 2021-06-23 01:21 +# Generated by Django 2.2.16 on 2021-06-23 23:31 from django.db import migrations, models import django.db.models.deletion @@ -17,7 +17,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='TaccsiteArticleList', fields=[ - ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_article_list_taccsitearticlelist', serialize=False, to='cms.CMSPlugin')), + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='taccsite_static_article_list_taccsitearticlelist', serialize=False, to='cms.CMSPlugin')), ('header_title_text', models.CharField(blank=True, help_text='The title at the top of the list.', max_length=100)), ('footer_link_text', models.CharField(blank=True, help_text='The "See All ..." link at the bottom of the list.', max_length=100)), ('content_type', models.CharField(blank=True, choices=[('news', 'News'), ('docs', 'Documents'), ('allocs', 'Allocations'), ('events', 'Events')], max_length=255)), diff --git a/taccsite_cms/contrib/taccsite_article_list/migrations/__init__.py b/taccsite_cms/contrib/taccsite_static_article_list/migrations/__init__.py similarity index 100% rename from taccsite_cms/contrib/taccsite_article_list/migrations/__init__.py rename to taccsite_cms/contrib/taccsite_static_article_list/migrations/__init__.py diff --git a/taccsite_cms/contrib/taccsite_article_list/models.py b/taccsite_cms/contrib/taccsite_static_article_list/models.py similarity index 100% rename from taccsite_cms/contrib/taccsite_article_list/models.py rename to taccsite_cms/contrib/taccsite_static_article_list/models.py diff --git a/taccsite_cms/contrib/taccsite_article_list/templates/article_list.html b/taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html similarity index 100% rename from taccsite_cms/contrib/taccsite_article_list/templates/article_list.html rename to taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html diff --git a/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py b/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py index d2754a3dc..c2b04cb1f 100644 --- a/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_static_article_preview/cms_plugins.py @@ -52,7 +52,7 @@ class TaccsiteStaticNewsArticlePreviewPlugin(ArticlePreviewPlugin): """ module = 'TACC Site' model = TaccsiteStaticNewsArticlePreview - name = _('(Static) News Article Preview') + name = _('News Article Preview (Static)') render_template = 'static_article_preview.html' cache = True diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 6fd90c2da..aa633dbba 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -243,7 +243,7 @@ def getsecrets(): 'taccsite_cms.contrib.taccsite_sample', 'taccsite_cms.contrib.taccsite_blockquote', 'taccsite_cms.contrib.taccsite_offset', - 'taccsite_cms.contrib.taccsite_article_list', + 'taccsite_cms.contrib.taccsite_static_article_list', 'taccsite_cms.contrib.taccsite_static_article_preview', ] From 3bf3ff88e51c81ae74cda80b24df2fb9624f5086 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 23 Jun 2021 18:40:09 -0500 Subject: [PATCH 29/92] GH-93: StaticArticleList: + footer_link_url TODOs --- taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py | 1 + taccsite_cms/contrib/taccsite_static_article_list/models.py | 1 + .../taccsite_static_article_list/templates/article_list.html | 1 + 3 files changed, 3 insertions(+) diff --git a/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py b/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py index 7fe55c3a2..95dfd20e8 100644 --- a/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_static_article_list/cms_plugins.py @@ -32,6 +32,7 @@ class TaccsiteArticleListPlugin(CMSPluginBase): 'fields': ( 'header_title_text', 'footer_link_text', + # TODO: Add `footer_link_url` ) }), (_('Options'), { diff --git a/taccsite_cms/contrib/taccsite_static_article_list/models.py b/taccsite_cms/contrib/taccsite_static_article_list/models.py index abdb2b792..43d0c9df1 100644 --- a/taccsite_cms/contrib/taccsite_static_article_list/models.py +++ b/taccsite_cms/contrib/taccsite_static_article_list/models.py @@ -80,6 +80,7 @@ class TaccsiteArticleList(CMSPlugin): blank=True, max_length=100, ) + # TODO: Add `footer_link_url` content_type = models.CharField( choices=CONTENT_CHOICES, diff --git a/taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html b/taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html index 98f23fd84..28a19e9a3 100644 --- a/taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html +++ b/taccsite_cms/contrib/taccsite_static_article_list/templates/article_list.html @@ -11,6 +11,7 @@

{% render_plugin plugin_instance %} {% endfor %}