Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add plugin for rapid generation of staff pages - update UI & UX #269

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ed9562e
feat(tup-cms)!: save progress of ui/ux updates
wesleyboar Jul 14, 2023
20e9c72
style(tup-cms): missing html end tag slash
wesleyboar Jul 14, 2023
43baf64
Merge branch 'task/TUP-125--staff-page-plugin' into task/TUP-125--sta…
wesleyboar Jul 25, 2023
9c991dd
chore: rm .vscode/settings.json
wesleyboar Jul 25, 2023
f2aa758
fix: restore forms.py (untested)
wesleyboar Aug 1, 2023
771e891
fix: restore models.py changes (untested)
wesleyboar Aug 1, 2023
3e2379e
fix: restore forms.py load
wesleyboar Aug 1, 2023
44f809e
fix: articles not rendering (mismatched key)
wesleyboar Aug 8, 2023
e8f05f4
fix: main col for articles with large content
wesleyboar Aug 8, 2023
0cb0d34
Merge branch 'task/TUP-125--staff-page-plugin' into task/TUP-125--sta…
wesleyboar Aug 9, 2023
bace7d6
feat: split name into first and last name
wesleyboar Aug 11, 2023
2af31d0
fix: reduce first and last name to 110 chars
wesleyboar Aug 11, 2023
d7e0252
Merge branch 'task/TUP-125--staff-page-plugin--name-as-first-and-last…
wesleyboar Aug 11, 2023
83c2aaa
fix: only require names, title, and email
wesleyboar Aug 11, 2023
2c8c766
Add plugin for rapid generation of staff pages - require only certain…
wesleyboar Aug 11, 2023
edd3113
feat: add title2 (2nd, equal, optional job title)
wesleyboar Aug 11, 2023
1e170a1
fix: replace template name w/ first_… and last_…
wesleyboar Aug 11, 2023
c13e303
Merge branch 'task/TUP-125--staff-page-plugin--name-as-first-and-last…
wesleyboar Aug 11, 2023
cbcf5bc
Merge branch 'task/TUP-125--staff-page-plugin--require-only-certain-f…
wesleyboar Aug 11, 2023
8440231
feat: add post_nomial
wesleyboar Aug 11, 2023
12db8d1
fix: remove templatetag (overkill)
wesleyboar Aug 11, 2023
c86075e
Merge branch 'task/TUP-125--staff-page-plugin' into task/TUP-125--sta…
wesleyboar Aug 11, 2023
8653a17
fix: markup should match live pages
wesleyboar Aug 11, 2023
d992a73
refactor: move all ui context work into template
wesleyboar Aug 11, 2023
5aef125
chore: remvoe superfluous edits of original code
wesleyboar Aug 11, 2023
ab40f72
feat: form layout and field labels
wesleyboar Aug 11, 2023
994a405
fix: cms_plugins name translate and single quotes
wesleyboar Aug 11, 2023
37a8a3f
feat: add help_text
wesleyboar Aug 11, 2023
5216037
fix: remove verbose name for most wysiwig fields
wesleyboar Aug 11, 2023
1beecad
fix: remove "Phone number" verbose name
wesleyboar Aug 11, 2023
73bcc7e
fix: rename post_nomial to post_nomials
wesleyboar Aug 11, 2023
6a34540
chore: migrations
wesleyboar Aug 11, 2023
4dd0972
refactor: no form ui in models, rename a field
wesleyboar Aug 11, 2023
b8c99db
refactor: do not use blank in models.py
wesleyboar Aug 11, 2023
337abd1
docs: encourage photo and bio
wesleyboar Aug 11, 2023
b7f8f06
fix: do not require photo
wesleyboar Aug 11, 2023
fb009b6
fix: markup conditionals
wesleyboar Aug 11, 2023
88218ec
refactor: squash migrations
wesleyboar Aug 11, 2023
765736e
feat: help text for secondary job title
wesleyboar Aug 16, 2023
2bc4487
chore: migration reducing name field lengths
wesleyboar Aug 16, 2023
9d8d6ee
feat: remove "experience" field
wesleyboar Aug 16, 2023
78e3edc
feat: s-staff-profile.css
wesleyboar Aug 16, 2023
eddbe42
feat: at content wrap, undo c-content-block styles
wesleyboar Aug 16, 2023
9af5961
docs: ntoe why s-staff-profile is global css
wesleyboar Aug 16, 2023
e33477b
refactor: staff_profile css and js — ⚠️ untested
wesleyboar Aug 16, 2023
27d0321
fix: load staff_profile css
wesleyboar Aug 16, 2023
9c6fa8f
fix: bugs in staff_profile js — ⚠️ incomplete
wesleyboar Aug 16, 2023
7c5a1b4
fix: bugs in staff_profile js — ✓ complete
wesleyboar Aug 17, 2023
cd2a0a3
fix: move image ot after job title, not just name
wesleyboar Aug 17, 2023
7f733f3
feat: use ut seal if no staff photo
wesleyboar Aug 17, 2023
effc0d9
style: captialization in css comments
wesleyboar Aug 17, 2023
792d9fc
style: consistency in css comments
wesleyboar Aug 17, 2023
b20d9c4
feat: model access via admin interface
wesleyboar Aug 17, 2023
7349d70
style: nx format:write
wesleyboar Aug 17, 2023
00ea82d
chore: remove excess property on admin class
wesleyboar Aug 17, 2023
da8d5c1
docs: in css comment warn about coupled html & css
wesleyboar Aug 17, 2023
3650715
fix: donot require photo field
wesleyboar Aug 17, 2023
892a8c4
feat: to load staff profile css+js on manual page
wesleyboar Aug 17, 2023
7152a29
refactor: c-staff-profile → s-staff-profile
wesleyboar Aug 17, 2023
8f96de5
docs: remove inaccurate comment
wesleyboar Aug 17, 2023
33474c0
docs: remove excess comment
wesleyboar Aug 17, 2023
dfaa142
docs: asset comment cleanup
wesleyboar Aug 17, 2023
5a7caff
fix: remove experience from forms and output
wesleyboar Aug 17, 2023
d8485fd
chore: move 'education" to bottom of form
wesleyboar Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/tup-cms/src/apps/staff_profile/admin.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? To create "Staff profile plugins" in /admin interface.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from cms.admin.placeholderadmin import FrontendEditableAdminMixin
from django.contrib import admin
from .models import StaffProfilePlugin
from .forms import StaffProfilePluginForm, fieldsets

class StaffProfilePluginAdmin(FrontendEditableAdminMixin, admin.ModelAdmin):
form = StaffProfilePluginForm
fieldsets = fieldsets
list_display = ('id', 'first_name', 'last_name', 'department', 'email')
list_filter = ('department', 'title')
search_fields = ('first_name', 'last_name', 'email')

admin.site.register(StaffProfilePlugin, StaffProfilePluginAdmin)
2 changes: 2 additions & 0 deletions apps/tup-cms/src/apps/staff_profile/apps.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? To title /admin page under "TACC STAFF PROFILES" (rather than "STAFF_PROFILE"),

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

class StaffProfileConfig(AppConfig):
verbose_name = _("TACC Staff Profiles")
name = 'apps.staff_profile'
7 changes: 4 additions & 3 deletions apps/tup-cms/src/apps/staff_profile/cms_plugins.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? Consistent (and translatable) plugin identification. Use custom form layout.

Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
from djangocms_text_ckeditor.widgets import TextEditorWidget

from .models import StaffProfilePlugin
from .forms import StaffProfilePluginForm
from .forms import StaffProfilePluginForm, fieldsets


@plugin_pool.register_plugin
class StaffProfilePlugin(CMSPluginBase):
module = "TUP CMS"
name = "Staff Profile"
module = 'TUP CMS'
name = _('Staff Profile')
form = StaffProfilePluginForm
model = StaffProfilePlugin
render_template = "staff_profile/profile.html"
cache = False

fieldsets = fieldsets

def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
Expand Down
103 changes: 96 additions & 7 deletions apps/tup-cms/src/apps/staff_profile/forms.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? Set which fields are required. Add help text and custom labels. Define custom form layout.

Original file line number Diff line number Diff line change
@@ -1,13 +1,102 @@

from django.forms.models import ModelForm
from django import forms
from django.utils.translation import gettext_lazy as _
from djangocms_text_ckeditor.widgets import TextEditorWidget

from .models import StaffProfilePlugin

class StaffProfilePluginForm(ModelForm):
description = forms.CharField(widget=TextEditorWidget, required=False)
publications = forms.CharField(widget=TextEditorWidget, required=False)
projects = forms.CharField(widget=TextEditorWidget, required=False)
education = forms.CharField(widget=TextEditorWidget, required=False)
research_areas = forms.CharField(widget=TextEditorWidget, required=False)
memberships = forms.CharField(widget=TextEditorWidget, required=False)
experience = forms.CharField(widget=TextEditorWidget, required=False)
first_name = forms.CharField(
required=True,
help_text=_('If desired, include middle name.')
)
last_name = forms.CharField(
required=True
)
post_nomials = forms.CharField(
required=False,
label=_('Post-nomials'),
help_text=_('E.g. Ph.D., B.S., M.B.A.')
)
title = forms.CharField(
required=True,
label=_('Job title')
)
title2 = forms.CharField(
required=False,
label=_('Secondary job title'),
help_text=_('Only necessary if the first job title is "Manager".')
)
email = forms.CharField(
required=True
)
department = forms.CharField(
required=False,
label=_('Group / Department')
)

description = forms.CharField(
widget=TextEditorWidget,
required=False,
label=_('Biography')
)

publications = forms.CharField(
widget=TextEditorWidget,
required=False,
label=_('Selected Publications')
)
projects = forms.CharField(
widget=TextEditorWidget,
required=False,
label=_('Current Projects')
)
education = forms.CharField(
widget=TextEditorWidget,
required=False
)
research_areas = forms.CharField(
widget=TextEditorWidget,
required=False,
label=_('Areas of Research')
)
memberships = forms.CharField(
widget=TextEditorWidget,
required=False
)

fieldsets = [
(_('Name'), {
'fields': (
('first_name', 'last_name', 'post_nomials'),
)
}),
(_('Role'), {
'fields': (
('title', 'title2'),
('department'),
)
}),
(_('Contact'), {
'fields': (
('email', 'phone'),
)
}),
(_('Introduction'), {
'description': 'We encourage all staff to have a professional photo and a brief professional bio.',
'fields': (
'photo',
'description',
)
}),
(_('Other'), {
'fields': (
'publications',
'projects',
'research_areas',
'memberships',
'education',
)
}),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.2.18 on 2023-08-11 23:16

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import filer.fields.image


class Migration(migrations.Migration):

dependencies = [
('filer', '__first__'),
('staff_profile', '0002_split_name_into_first_and_last'),
]

operations = [
migrations.AlterField(
model_name='staffprofileplugin',
name='photo',
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.FILER_IMAGE_MODEL),
),
migrations.AddField(
model_name='staffprofileplugin',
name='post_nomials',
field=models.CharField(max_length=100),
),
migrations.AddField(
model_name='staffprofileplugin',
name='title2',
field=models.CharField(max_length=100),
),
]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help! Git got confused or I screwed up.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 3.2.18 on 2023-08-11 15:30
# Generated by Django 3.2.18 on 2023-08-16 16:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('staff_profile', '0002_split_name_into_first_and_last'),
('staff_profile', '0003_reduce_first_last_name_length_squashed_0009_do_not_require_photo'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-08-16 16:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('staff_profile', '0004_reduce_name_field_lengths'),
]

operations = [
migrations.RemoveField(
model_name='staffprofileplugin',
name='experience',
),
]
6 changes: 3 additions & 3 deletions apps/tup-cms/src/apps/staff_profile/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from cms.models.pluginmodel import CMSPlugin
from django.utils.translation import gettext_lazy as _
from filer.fields.image import FilerImageField
from django.db import models

Expand All @@ -10,18 +9,19 @@ class StaffProfilePlugin(CMSPlugin):
"""
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
post_nomials = models.CharField(max_length=100)
title = models.CharField(max_length=100)
title2 = models.CharField(max_length=100)
email = models.CharField(max_length=100)
department = models.CharField(max_length=100)
phone = models.CharField(max_length=50, null=True)

description = models.TextField()

photo = FilerImageField(on_delete=models.CASCADE, null=True)
photo = FilerImageField(on_delete=models.CASCADE, null=True, blank=True)

publications = models.TextField(null=True)
projects = models.TextField(null=True)
education = models.TextField(null=True)
research_areas = models.TextField(null=True)
memberships = models.TextField(null=True)
experience = models.TextField(null=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* To add more space beneath lists */
/* TODO: Consider changing this in core-styles.base.css */
/* TODO: Alternatively, consider adding this to core-styles.cms.css */
.s-staff-profile :is(dl, ul, ol) {
/* To mimic core-styles.cms.css <p> */
margin-bottom: 2rem; /* overwrites core-styles.base.css */
}

/* When sidebar is under main content */
/* WARNING: This query assumes Bootstrap 4 grid classes "col-sm-12 col-md-6" */
@media only screen and (max-width: 767px) {

/* To remove bullets in a c-content-block */
:is(.c-content-block, .content-block) ul {
list-style-type: none;
}

/* To undo c-content-block styles (Core-Styles) */
:is(.c-content-block, .content-block) {
margin-bottom: unset;
padding: unset;
}
:is(.c-content-block, .content-block) :is(h1, h2, h3, h4, h5, h6) {
border-left: unset;
padding-left: unset;
}
/* To retain space between staff image and a content block beneath */
:is(.c-content-block, .content-block) img {
margin-bottom: var(--global-space--pattern-pad); /* mimics c-content-block padding */
}

/* To undo c-content-block styles (TUP-CMS) */
:is(.c-content-block, .content-block) + :is(.c-content-block, .content-block) {
margin-top: unset;
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Move image on load and on window resize */

const mainColumn = document.querySelector(
'.row.s-staff-profile > .col:nth-child(1)'
);
const sideColumn = document.querySelector(
'.row.s-staff-profile > .col:nth-child(2)'
);
const mainHeader = mainColumn.querySelector(':scope > h2');
const image = sideColumn.querySelector(':scope > *:first-child');

/** Move image to side column on wide screen, otherwise to main column */
function moveImage() {
const isWideScreen = window.matchMedia('(min-width: 768px)').matches;

if (isWideScreen) {
if (!sideColumn.contains(image)) {
sideColumn.prepend(image);
if (window.DEBUG) console.log('Staff image should be in side column');
}
} else {
if (!mainColumn.contains(image)) {
mainHeader.after(image);
if (window.DEBUG) console.log('Staff image should be in main column');
}
}
}

moveImage();
// HELP: Can event be limited to width resize only? Is it worth it?
// SEE: https://stackoverflow.com/a/71782892/11817077
window.addEventListener('resize', () => {
moveImage();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% if content %}
<h3>{{title}}</h3>
{{content | safe}}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if content %}
<aside class="content-block">
<h3>{{title}}</h3>
{{content | safe}}
</aside>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if instance.post_nomials %}
{{instance.first_name}} {{instance.last_name}}, {{instance.post_nomials}}
{% else %}
{{instance.first_name}} {{instance.last_name}}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load static %}

<div class="content-block">
{% if instance.photo %}
<img
src="{{instance.photo.url}}"
title="{% spaceless %}
{% if instance.photo.default_alt_text %}
{{instance.photo.default_alt_text}}
{% else %}
{% include './display_name.html' %}
{% endif %}
{% endspaceless %}"
class="img-fluid"
/>
{% else %}
<img
src="{% static 'staff_profile/img/ut-seal.svg' %}"
title="University of Texas at Austin"
class="img-fluid"
/>
{% endif %}
</div>
Loading