A Person content type for Plone.
Project description
Person content type for Plone
Features
collective.person provides a content type representing a Person.
Content Types
Person: A content type representing a person
Behaviors
| name | title | description |
|---|---|---|
collective.person.person |
Person Behavior | Fields with basic person information |
collective.person.user |
Link Person to Plone User | Adapts a Person to link it to a Plone User |
collective.person.namefromusername |
Name from username | Use the username field as name (basis for the id) |
Permissions
| id | title | Usage |
|---|---|---|
| collective.person.person.add | collective.person: Add Person | Control the creation of a new Person content item |
Catalog Indexes
This package adds Indexes and Metadata to Portal Catalog.
| Content Attribute | Index Type | Metadata | Comment |
|---|---|---|---|
| roles | KeywordIndex | ✅ | -- |
| username | FieldIndex | ✅ | Used when collective.person.user behavior is enabled |
See it in action
This package is being used by the following sites:
- TODO
Documentation
Installation
Add collective.person as a dependency on your package's setup.py
install_requires = [
"Plone",
"plone.restapi",
"collective.person",
],
Also, add collective.person to your package's configure.zcml (or dependencies.zcml):
<include package="collective.person" />
Generic Setup
To automatically enable this package when your add-on is installed, add the following line inside the package's profiles/default/metadata.xml dependencies element:
<dependency>profile-collective.person:default</dependency>
Source Code and Contributions
We welcome contributions to collective.person.
You can create an issue in the issue tracker, or contact a maintainer.
Development setup
You need a working Python environment version 3.8 or later.
Then install the dependencies and a development instance using:
make install
By default, we use the latest Plone version in the 6.x series.
Update translations
make i18n
Format codebase
make format
Lint codebase
make lint
Run tests
make test
Extending collective.person
Customizing how the title is generated
collective.person provides two built-in strategies for generating the title of a Person object:
-
First and Last Name (
first_last): The title is generated using the template{first_name} {last_name}. Example:first_name="Douglas",last_name="Adams"→ Douglas Adams -
Last and First Name (
last_first): The title is generated using the template{last_name}, {first_name}. Example:first_name="Douglas",last_name="Adams"→ Adams, Douglas
You can select the preferred option in the Person control panel.
Providing your own title generator
If the default options do not fit your needs, you can register a custom utility that implements the collective.person.interfaces.IPersonTitle interface.
Step 1: Create your generator
For example, create a file called title_generator.py in your package:
from collective.person.content.person import Person
from collective.person.interfaces import IPersonTitle
from zope.interface import implementer
@implementer(IPersonTitle)
class MyTitleGenerator:
"""Return the title with a custom prefix."""
name: str = "My title generator"
def title(self, context: Person) -> str:
"""Return the title of the person."""
first_name = context.first_name
last_name = context.last_name or ""
return f"Human {first_name} {last_name}".strip()
Step 2: Register the utility
In your configure.zcml, add:
<utility
factory=".title_generator.MyTitleGenerator"
name="my_title_generator"
/>
Step 3: Activate your generator
To make your generator the default after installation, update the registry via GenericSetup by adding a registry.xml file in your profile:
<?xml version="1.0" encoding="utf-8"?>
<registry>
<records
interface="collective.person.controlpanel.interfaces.IPersonSettings"
prefix="person">
<value key="title_utility" purge="false">my_title_generator</value>
</records>
</registry>
License
The project is licensed under GPLv2.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file collective_person-1.0.0b2.tar.gz.
File metadata
- Download URL: collective_person-1.0.0b2.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
272310fc9db796ba1533fec2273b711fe744b5cb656810ab68f217cd1788bf5a
|
|
| MD5 |
942351a1d611da58078f9568b1552eb9
|
|
| BLAKE2b-256 |
5b824cd195fefeeb1271fb615dd388f72bdbc39694e85c67175fd796265793c0
|
File details
Details for the file collective_person-1.0.0b2-py3-none-any.whl.
File metadata
- Download URL: collective_person-1.0.0b2-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a08dd2d855f82a7cbb3660ecf4c6d40b46dcf4418042f48724d43a470ed03cf
|
|
| MD5 |
bd86ba9c5f59d573bef789f8a24d8191
|
|
| BLAKE2b-256 |
2852317d74094e67cf609143032f663edb5f3a0662f5a3cfbe165351f5894e47
|