Si vous constatez la perte de tickets, de commentaires ou de projets, veuillez consulter la page https://status.framasoft.org/incident/626.

...
 
Commits (17)
Wagtail Person
==============
Add a person and a persons index pages to Wagtail as well as a person
block for StreamFields. This app provide a basic CSS and templates, feel
free to customize it.
On a CMS, we regularly need to represent an author, a speaker, a
person. To avoid repetition and duplication of datas about this, this
app add a person model to Wagtail, with admin UI. Do not hesitate to
use it on your blog or lectures appilaciton.
This model is accompanied by a Person page model and a Persons index
page model. Each Person page is linked to a Person model to see it on
your website.
This app also provide a basic CSS and templates, feel free to
customize it.
Important
---------
Since version 0.9.8, the Person Page model has been split in 2 models:
- A Person model
- A Person page model, with a many2one to a Person model
Install
......@@ -22,6 +38,8 @@ INSTALLED_APPS = [
# …
'wagtailperson',
# …
'wagtail.contrib.modeladmin',
# …
]
```
......@@ -35,26 +53,33 @@ Then, finally, apply migration scripts:
Use
---
This application provide 2 pages models:
This application add a new entry to the administration menu, called
"Author or Person". From this menu, you can add a new author or
person.
If you want to link one of your wagtail page models, or django models,
to a person: Simply add a many2one field linked to
`wagtailperson.models.Person`.
This application also provide 2 pages models:
- A person page: Represent someone, can be used mostly everywhere in
the pages tree
- A person index page: A root page for persons pages, it list each of
person it had as children pages and can only have person pages as
children
- A Person page: Show puplicly someone, can be used mostly
everywhere in the pages tree
- A Persons index page: A root page for Persons pages, it list each
of Persons pages it had as children pages and can only have Person
pages as children
The person index page can be useful to group persons, globally or per
group.
A person page got multiple fields:
- Name
A person got multiple fields:
- Picture
- Titles
- Name
- Tags
- Introduction
- Abstract
- Extra informations
This application also provide a person block for StreamField at
This application also provide a person block for StreamField, at
`wagtailperson.blocks.PersonBlock`. Feel free to use it on your models
StreamField.
......
......@@ -39,6 +39,7 @@ INSTALLED_APPS = [
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail.contrib.modeladmin',
'modelcluster',
'taggit',
......
# Generated by Django 2.2.4 on 2020-02-25 15:46
import django.core.validators
from django.db import migrations
import wagtail.core.blocks
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('home', '0003_homepage_body'),
]
operations = [
migrations.AlterField(
model_name='homepage',
name='body',
field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.StructBlock([('header_level', wagtail.core.blocks.ChoiceBlock(choices=[('h1', 'H1'), ('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5'), ('h6', 'H6')], label='Header level')), ('text', wagtail.core.blocks.CharBlock(label='Text'))])), ('link', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.CharBlock(label='Description')), ('url', wagtail.core.blocks.URLBlock(label='URL', validators=[django.core.validators.URLValidator(['http', 'https', 'ftp', 'ftps', 'mailto', 'xmpp', 'tel'])]))])), ('person', wagtail.core.blocks.StructBlock([('person_page', wagtail.core.blocks.PageChooserBlock(label='Person or author page', page_type=['wagtailperson.PersonPage']))])), ('paragraph', wagtail.core.blocks.RichTextBlock())], blank=True),
),
]
......@@ -63,8 +63,8 @@ class LinkBlock(blocks.StructBlock):
class PersonBlock(blocks.StructBlock):
"""A person block, linked to a person page"""
person = blocks.PageChooserBlock(
label=_('Person page'),
person_page = blocks.PageChooserBlock(
label=_('Person or author page'),
target_model='wagtailperson.PersonPage',
)
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-21 23:41+0200\n"
"POT-Creation-Date: 2020-02-26 21:54+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -20,7 +20,7 @@ msgstr ""
#: apps.py:7
msgid "Wagtail Person"
msgstr "Wagtail Persone"
msgstr "Wagtail Personne"
#: blocks.py:24
msgid "Header level"
......@@ -28,100 +28,90 @@ msgstr "Niveau d'en-tête"
#: blocks.py:27
msgid "Text"
msgstr "Text"
msgstr "Texte"
#: blocks.py:33
msgid "Header"
msgstr "Header"
msgstr "En-tête"
#: blocks.py:39
msgid "Description"
msgstr "Description"
#: blocks.py:42
#: blocks.py:42 models.py:52
msgid "URL"
msgstr "URL"
#: blocks.py:61
msgid "Link"
msgstr "Link"
msgstr "Lien"
#: blocks.py:67
msgid "Person page"
#: blocks.py:67 models.py:131
#, fuzzy
#| msgid "Person page"
msgid "Person or author page"
msgstr "Page de personne"
#: blocks.py:74 models.py:83
#: blocks.py:74 models.py:44 models.py:121
msgid "Person"
msgstr "Persone"
msgstr "Personne"
#: models.py:48
msgid "Label"
msgstr "Label"
#: models.py:35
#: models.py:62
msgid "Person's extrernal link"
msgstr "Lien externe d'une personne"
#: models.py:63
msgid "Person's extrernal links"
msgstr "Liens externes d'une personne"
#: models.py:77
msgid "Picture"
msgstr "Photo"
#: models.py:38
#: models.py:80
msgid "Name"
msgstr "Nom"
#: models.py:42
msgid "Custom titles"
msgstr "Titres personnalisés"
#: models.py:45
msgid "Some custom titles, separated by commas"
msgstr "Quelques titres personnalisés, séparés par des virgules"
#: models.py:48
#: models.py:85
msgid "Introduction"
msgstr "Introduction"
#: models.py:51
#: models.py:88
msgid "Shown on the short descriptions"
msgstr "Montré sur les descriptions courtes"
#: models.py:55
#: models.py:92
msgid "Abstract"
msgstr "Résumé"
#: models.py:68
msgid "Extra informations"
msgstr "Informations supplémentaires"
#: models.py:75
msgid "Titles"
msgstr "Titres"
#: models.py:84
msgid "Persons"
msgstr "Personnes"
#: models.py:108
msgid "Title"
msgstr "Title"
#: models.py:113
msgid "Person title"
msgstr "Titre de la personne"
#: models.py:101
msgid "link"
msgstr "lien"
#: models.py:114
msgid "Person titles"
msgstr "Titres de personne"
#: models.py:105
msgid "Person or author"
msgstr "Personne ou auteur"
#: models.py:138
msgid "Person Title Page"
msgstr "Page de titre de personne"
#: models.py:106 wagtail_hooks.py:15
msgid "Persons or authors"
msgstr "Personnes ou auteurs"
#: models.py:139
msgid "Person Title Pages"
msgstr "Pages de titre de personne"
#: models.py:132
msgid "Person or author pages"
msgstr "Pages de personne ou auteur"
#: models.py:149
#: models.py:143
msgid "Intro"
msgstr "Intro"
#: models.py:159
msgid "Person Index Page"
msgstr "Page d'index des personnes"
#: models.py:153
msgid "Persons or authors Index Page"
msgstr "Page d'index des personnes ou auteurs"
#: models.py:160
msgid "Person Index Pages"
msgstr "Pages d'index des personnes"
#: models.py:154
msgid "Persons or authors Index Pages"
msgstr "Pages d'index des personnes ou auteurs"
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-21 23:41+0200\n"
"POT-Creation-Date: 2020-02-26 21:54+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -20,7 +20,7 @@ msgstr ""
#: apps.py:7
msgid "Wagtail Person"
msgstr "Wagtail Persone"
msgstr "Wagtail Personne"
#: blocks.py:24
msgid "Header level"
......@@ -28,100 +28,90 @@ msgstr "Niveau d'en-tête"
#: blocks.py:27
msgid "Text"
msgstr "Text"
msgstr "Texte"
#: blocks.py:33
msgid "Header"
msgstr "Header"
msgstr "En-tête"
#: blocks.py:39
msgid "Description"
msgstr "Description"
#: blocks.py:42
#: blocks.py:42 models.py:52
msgid "URL"
msgstr "URL"
#: blocks.py:61
msgid "Link"
msgstr "Link"
msgstr "Lien"
#: blocks.py:67
msgid "Person page"
#: blocks.py:67 models.py:131
#, fuzzy
#| msgid "Person page"
msgid "Person or author page"
msgstr "Page de personne"
#: blocks.py:74 models.py:83
#: blocks.py:74 models.py:44 models.py:121
msgid "Person"
msgstr "Persone"
msgstr "Personne"
#: models.py:48
msgid "Label"
msgstr "Label"
#: models.py:35
#: models.py:62
msgid "Person's extrernal link"
msgstr "Lien externe d'une personne"
#: models.py:63
msgid "Person's extrernal links"
msgstr "Liens externes d'une personne"
#: models.py:77
msgid "Picture"
msgstr "Photo"
#: models.py:38
#: models.py:80
msgid "Name"
msgstr "Nom"
#: models.py:42
msgid "Custom titles"
msgstr "Titres personnalisés"
#: models.py:45
msgid "Some custom titles, separated by commas"
msgstr "Quelques titres personnalisés, séparés par des virgules"
#: models.py:48
#: models.py:85
msgid "Introduction"
msgstr "Introduction"
#: models.py:51
#: models.py:88
msgid "Shown on the short descriptions"
msgstr "Montré sur les descriptions courtes"
#: models.py:55
#: models.py:92
msgid "Abstract"
msgstr "Résumé"
#: models.py:68
msgid "Extra informations"
msgstr "Informations supplémentaires"
#: models.py:75
msgid "Titles"
msgstr "Titres"
#: models.py:84
msgid "Persons"
msgstr "Personnes"
#: models.py:108
msgid "Title"
msgstr "Title"
#: models.py:113
msgid "Person title"
msgstr "Titre de la personne"
#: models.py:101
msgid "link"
msgstr "lien"
#: models.py:114
msgid "Person titles"
msgstr "Titres de personne"
#: models.py:105
msgid "Person or author"
msgstr "Personne ou auteur"
#: models.py:138
msgid "Person Title Page"
msgstr "Page de titre de personne"
#: models.py:106 wagtail_hooks.py:15
msgid "Persons or authors"
msgstr "Personnes ou auteurs"
#: models.py:139
msgid "Person Title Pages"
msgstr "Pages de titre de personne"
#: models.py:132
msgid "Person or author pages"
msgstr "Pages de personne ou auteur"
#: models.py:149
#: models.py:143
msgid "Intro"
msgstr "Intro"
#: models.py:159
msgid "Person Index Page"
msgstr "Page d'index des personnes"
#: models.py:153
msgid "Persons or authors Index Page"
msgstr "Page d'index des personnes ou auteurs"
#: models.py:160
msgid "Person Index Pages"
msgstr "Pages d'index des personnes"
#: models.py:154
msgid "Persons or authors Index Pages"
msgstr "Pages d'index des personnes ou auteurs"
# Generated by Django 2.2.4 on 2020-02-20 18:54
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
import taggit.managers
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('taggit', '0003_taggeditem_add_unique_index'),
('wagtailimages', '0001_squashed_0021'),
('wagtailperson', '0004_auto_20190821_2153'),
]
operations = [
migrations.CreateModel(
name='Person',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=250, verbose_name='Name')),
('intro', models.CharField(blank=True, help_text='Shown on the short descriptions', max_length=250, verbose_name='Introduction')),
('abstract', wagtail.core.fields.RichTextField(blank=True, verbose_name='Abstract')),
('picture', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='Picture')),
],
options={
'verbose_name': 'Person or author',
'verbose_name_plural': 'Persons or authors',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='PersonExtrernalLink',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('label', models.CharField(max_length=255, verbose_name='Label')),
('url', models.URLField(max_length=255, verbose_name='URL')),
('person', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='external_links', to='wagtailperson.Person', verbose_name='Person')),
],
options={
'verbose_name': "Person's extrernal link",
'verbose_name_plural': "Person's extrernal links",
},
),
migrations.CreateModel(
name='PersonTag',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('content_object', modelcluster.fields.ParentalKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tagged_items', to='wagtailperson.Person')),
('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='wagtailperson_persontag_items', to='taggit.Tag')),
],
options={
'abstract': False,
},
),
migrations.DeleteModel(
name='PersonTitle',
),
migrations.AlterModelOptions(
name='personindexpage',
options={'verbose_name': 'Persons or authors Index Page', 'verbose_name_plural': 'Persons or authors Index Pages'},
),
migrations.AlterModelOptions(
name='personpage',
options={'ordering': ['title'], 'verbose_name': 'Person or author page', 'verbose_name_plural': 'Person or author pagess'},
),
migrations.RemoveField(
model_name='personpage',
name='abstract',
),
migrations.RemoveField(
model_name='personpage',
name='custom_titles',
),
migrations.RemoveField(
model_name='personpage',
name='extra_infos',
),
migrations.RemoveField(
model_name='personpage',
name='intro',
),
migrations.RemoveField(
model_name='personpage',
name='name',
),
migrations.RemoveField(
model_name='personpage',
name='picture',
),
migrations.DeleteModel(
name='PersonTitlePage',
),
migrations.AddField(
model_name='person',
name='tags',
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='wagtailperson.PersonTag', to='taggit.Tag', verbose_name='Tags'),
),
migrations.AddField(
model_name='personpage',
name='person',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='wagtailperson.Person', verbose_name='Person'),
),
]
......@@ -2,11 +2,15 @@ from django.db import models
from django.utils.translation import gettext as _
from django.utils.text import slugify
from modelcluster.fields import ParentalKey
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField, StreamField
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from taggit.models import TaggedItemBase
from taggit.managers import TaggableManager
from wagtail.snippets.models import register_snippet
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.admin.edit_handlers import (
FieldPanel,
InlinePanel,
......@@ -18,13 +22,51 @@ from wagtail.images.blocks import ImageChooserBlock
from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.embeds.blocks import EmbedBlock
from wagtailperson.blocks import (
HeaderBlock,
LinkBlock,
)
# Models
class PersonPage(Page):
class PersonTag(TaggedItemBase):
"""A tag, related to a person"""
content_object = ParentalKey(
'Person',
related_name='tagged_items',
on_delete=models.CASCADE,
null=True,
)
class PersonExtrernalLink(Orderable, models.Model):
"""A person's external link"""
person = ParentalKey(
'Person',
on_delete=models.CASCADE,
verbose_name=_('Person'),
related_name='external_links'
)
label = models.CharField(
verbose_name=_('Label'),
max_length=255,
)
url = models.URLField(
verbose_name=_('URL'),
max_length=255,
)
panels = [
FieldPanel('label'),
FieldPanel('url'),
]
class Meta:
verbose_name = _("Person's extrernal link")
verbose_name_plural = _("Person's extrernal links")
def __str__(self):
return self.label
class Person(ClusterableModel):
"""A person"""
picture = models.ForeignKey(
'wagtailimages.Image',
......@@ -38,12 +80,7 @@ class PersonPage(Page):
verbose_name=_('Name'),
max_length=250,
)
custom_titles = models.CharField(
verbose_name=_('Custom titles'),
max_length=250,
blank=True,
help_text=_('Some custom titles, separated by commas'),
)
tags = TaggableManager(through=PersonTag, blank=True)
intro = models.CharField(
verbose_name=_('Introduction'),
max_length=250,
......@@ -54,92 +91,49 @@ class PersonPage(Page):
blank=True,
verbose_name=_('Abstract'),
)
extra_infos = StreamField(
[
('heading', HeaderBlock()),
('link', LinkBlock()),
('paragraph', blocks.RichTextBlock()),
('quote', blocks.BlockQuoteBlock()),
('image', ImageChooserBlock()),
('document', DocumentChooserBlock()),
('embed', EmbedBlock()),
],
blank=True,
verbose_name=_('Extra informations'),
)
# Editor panels configuration
content_panels = [
FieldPanel('name'),
panels = [
ImageChooserPanel('picture'),
InlinePanel('titles', label=_('Titles')),
FieldPanel('custom_titles'),
FieldPanel('name'),
FieldPanel('tags'),
FieldPanel('intro'),
FieldPanel('abstract'),
StreamFieldPanel('extra_infos'),
InlinePanel('external_links', label=_('link')),
]
class Meta:
verbose_name = _('Person')
verbose_name_plural = _('Persons')
verbose_name = _('Person or author')
verbose_name_plural = _('Persons or authors')
ordering = ['name']
def __str__(self):
return self.name
def save(self, *args, **kwargs):
"""Override save to populate title and slug"""
self.title = self.name
if not self.slug:
self.slug = slugify(self.name, allow_unicode=True)
return super(PersonPage, self).save(*args, **kwargs)
def custom_titles_list(self):
"""Get custom titles, in form of a list of strings"""
if not self.custom_titles:
return []
return self.custom_titles.split(',')
@register_snippet
class PersonTitle(models.Model):
"""The title of a person"""
title = models.CharField(
verbose_name=_('Title'),
max_length=250,
)
class Meta:
verbose_name = _('Person title')
verbose_name_plural = _('Person titles')
ordering = ['title']
# Models
def __str__(self):
return self.title
class PersonTitlePage(Orderable):
"""A many-to-many retation between PensonPage and PersonTitle"""
page = ParentalKey(
PersonPage,
related_name='titles',
)
title = models.ForeignKey(
PersonTitle,
on_delete=models.CASCADE,
related_name='+',
class PersonPage(Page):
"""A person"""
person = models.ForeignKey(
Person,
on_delete=models.PROTECT,
verbose_name=_('Person'),
null=True,
)
panels = [
FieldPanel('title'),
# Editor panels configuration
content_panels = Page.content_panels + [
FieldPanel('person'),
]
class Meta:
verbose_name = _('Person Title Page')
verbose_name_plural = _('Person Title Pages')
verbose_name = _('Person or author page')
verbose_name_plural = _('Person or author pages')
ordering = ['title']
def __str__(self):
return self.title.title
return self.title
class PersonIndexPage(Page):
......@@ -156,8 +150,8 @@ class PersonIndexPage(Page):
subpage_types = ['wagtailperson.PersonPage']
class Meta:
verbose_name = _('Person Index Page')
verbose_name_plural = _('Person Index Pages')
verbose_name = _('Persons or authors Index Page')
verbose_name_plural = _('Persons or authors Index Pages')
def __str__(self):
return self.title
......@@ -172,7 +166,7 @@ class PersonIndexPage(Page):
for page
in self.get_children().live()
),
key=lambda person: person.name
key=lambda person_page: person_page.person.name
)
context['person_pages'] = person_pages
return context
......@@ -18,13 +18,13 @@
margin-top: 30px;
}
.person .description ul.titles {
.person .description ul.tags {
list-style-type: none;
padding: 0;
margin-top: 0;
}
.person .description ul.titles li {
.person .description ul.tags li {
font-weight: bold;
}
......
......@@ -4,8 +4,8 @@
<link rel="stylesheet" href="{% static 'wagtailperson/css/person.css' %}" type="text/css"/>
{% with person=value.person %}
<a class="person short_description" href="{% pageurl person %}">
{% with person=value.person_page.person %}
<a class="person short_description" href="{% pageurl value.person_page %}">
<div class="person short_description">
{% if person.picture %}
<div class="picture">
......@@ -14,12 +14,9 @@
{% endif %}
<div class="description">
<h2>{{ person.name }}</h1>
<ul class="titles">
{% for title in person.titles.all %}
<li>{{ title.title }}</li>
{% endfor %}
{% for title in person.custom_titles_list %}
<li>{{ title }}</li>
<ul class="tags">
{% for tag in person.tags.all %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
<p class="intro">
......
......@@ -15,30 +15,29 @@
<div class="intro">{{ page.intro|richtext }}</div>
{% for person in person_pages %}
<a class="person short_description" href="{% pageurl person %}">
<div class="person short_description">
{% if person.picture %}
<div class="picture">
{% image person.picture fill-100x150 %}
{% for person_page in person_pages %}
{% with person=person_page.person %}
<a class="person short_description" href="{% pageurl person_page %}">
<div class="person short_description">
{% if person.picture %}
<div class="picture">
{% image person.picture fill-100x150 %}
</div>
{% endif %}
<div class="description">
<h2>{{ person.name }}</h2>
<ul class="tags">
{% for title in person.tags.all %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
<p class="intro">
{{ person.intro }}
</p>
</div>
{% endif %}
<div class="description">
<h2>{{ person.name }}</h2>
<ul class="titles">
{% for title in person.titles.all %}
<li>{{ title.title }}</li>
{% endfor %}
{% for title in person.custom_titles_list %}
<li>{{ title }}</li>
{% endfor %}
</ul>
<p class="intro">
{{ person.intro }}
</p>
</div>
</div>
</a>
</a>
{% endwith %}
{% endfor %}
{% endblock %}
......@@ -11,28 +11,22 @@
{% block body_class %}template-personpage{% endblock %}
{% block content %}
<h1>{{ page.name }}</h1>
<h1>{{ page.person.name }}</h1>
<div class="person full_description">
{% if page.picture %}
{% if page.person.picture %}
<div class="picture">
{% image page.picture original %}
{% image page.person.picture original %}
</div>
{% endif %}
<div class="description">
<ul class="titles">
{% for title in page.titles.all %}
<li>{{ title.title }}</li>
{% endfor %}
{% for title in page.custom_titles_list %}
<li>{{ title }}</li>
<ul class="tags">
{% for tag in page.person.tags.all %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
<p class="abstract">
{{ page.abstract|richtext }}
{{ page.person.abstract|richtext }}
</p>
<div class="extra_infos">
{% include_block page.extra_infos %}
</div>
</div>
</div>
{% endblock %}
from django.utils.html import format_html_join
from django.conf import settings
from wagtail.core import hooks
from django.utils.translation import gettext as _
from wagtail.contrib.modeladmin.options import (
ModelAdmin,
modeladmin_register,
)
from .models import (
Person,
)
@hooks.register('insert_editor_js')
def editor_js():
"""Insert slof_from_name javascript in admin javascript"""
js_files = [
'wagtailperson/js/slug_from_person_name.js',
]
js_includes = format_html_join(
'\n',
'<script src="{0}{1}"></script>',
(
(settings.STATIC_URL, filename)
for filename
in js_files
),
)
return js_includes
class PersonModelAdmin(ModelAdmin):
"""Define the person model integration to the admin ui"""
model = Person
menu_label = _('Persons or authors')
menu_icon = 'user'
menu_order = 200
list_display = ('name',)
list_filter = ('tags',)
search_field = ('name',)
modeladmin_register(PersonModelAdmin)