-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implement board member details as snippet #1189
base: main
Are you sure you want to change the base?
Conversation
from lametro.models import LAMetroPerson, BoardMemberDetails | ||
|
||
|
||
@receiver(post_save, sender=LAMetroPerson) |
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.
Will handle instantiating details for new members moving forward. To backfill, we simply need to call save on all existing board members.
_revisions = GenericRelation( | ||
"wagtailcore.Revision", related_query_name="member_details" | ||
) | ||
|
||
@property | ||
def revisions(self): | ||
return self._revisions |
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.
council_post = self.person.latest_council_membership.post | ||
context["qualifying_post"] = council_post.acting_label | ||
|
||
context["preview"] = True |
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.
The map and committee/board report modules require a bunch of extra context, so I use this to purposefully omit them from page previews. (I also added a note to the admin interface.)
@@ -0,0 +1,4 @@ | |||
{% load wagtailadmin_tags %} |
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.
More or less stolen from the Wagtail source code, to make the status icon in the board member details snippet list link to the person detail page.
return user.has_perm(self._get_permission_name(action)) | ||
|
||
|
||
class BoardMemberFilterSet(django_filters.FilterSet): |
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.
This is a django-filter
filter set, which I'm using to add custom filters for whether a person is a current board member and what body they belong to, on the board member detail snippet listing page.
HelpPanel( | ||
content=( | ||
"<p>On this page, you can manage a board member's headshot and " | ||
"bio. All other details and relationships, e.g., memberships, " | ||
"should be managed in Legistar.</p>" | ||
"<p><strong>Note:</strong> The page preview excludes " | ||
"the map and committee and board report modules displayed " | ||
"on the live page.</p>" | ||
) | ||
), |
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.
🙃
register_snippet(BoardMemberDetailsViewSet) | ||
|
||
|
||
class UserBarLink: |
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.
I pulled some reusable things out of the model admin link so I could also use them for the snippet edit link.
finder = AdminURLFinder() | ||
return finder.get_edit_url(snippet) |
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.
Overview
This PR adds a Django model for board member headshots and bios and registers as a snippet for editing in the CMS. It also deprecates the
headshot_url
property, instead creating a shared template block that renders the right thing given a person instance and, optionally, a way to request the original aspect ratio, instead of a square thumbnail.Connects #1176
Demo
Notes
I decided to go ahead and implement this as a snippet, since the
modeladmin
module is deprecated in the next version of Wagtail, so using snippets now makes our migration path easier moving forward. I'm wondering if we might want to do this in #1185, too. https://docs.wagtail.org/en/v5.2.1/reference/contrib/modeladmin/migrating_to_snippets.htmlTesting Instructions
tktktktk