-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
ed9562e
20e9c72
43baf64
9c991dd
f2aa758
771e891
3e2379e
44f809e
e8f05f4
0cb0d34
bace7d6
2af31d0
d7e0252
83c2aaa
2c8c766
edd3113
1e170a1
c13e303
cbcf5bc
8440231
12db8d1
c86075e
8653a17
d992a73
5aef125
ab40f72
994a405
37a8a3f
5216037
1beecad
73bcc7e
6a34540
4dd0972
b8c99db
337abd1
b7f8f06
fb009b6
88218ec
765736e
2bc4487
9d8d6ee
78e3edc
eddbe42
9af5961
e33477b
27d0321
9c6fa8f
7c5a1b4
cd2a0a3
7f733f3
effc0d9
792d9fc
b20d9c4
7349d70
00ea82d
da8d5c1
3650715
892a8c4
7152a29
8f96de5
33474c0
dfaa142
5a7caff
d8485fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? To title |
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' |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What? Consistent (and translatable) plugin identification. Use custom form layout. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
), | ||
] |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
---|---|---|
@@ -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', | ||
), | ||
] |
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; | ||
} | ||
|
||
} |
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> |
There was a problem hiding this comment.
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.