Support #10783
best way to add extra attribute kinds?
Start date:
01 May 2016
Due date:
% Done:
100%
Estimated time:
Patch proposed:
No
Planning:
Description
For now new attribute kinds are defined from config.py, like this:
from django import forms class NrnField(forms.CharField): def validate(self, value): super(NrnField, self).validate(value) if not value: return try: if (97 - int(value[:9]) % 97) != int(value[-2:]): raise ValueError() except ValueError: raise forms.ValidationError("Invalid format") A2_ATTRIBUTE_KINDS = [{ 'label': u'National Register Number', 'name': 'nrn', 'field_class': NrnField, }]
but I'd prefer to have this in a proper module.
I'm guessing we'd need a new extension point in plugins and change get_attribute_kinds
to chain through them, but maybe you have a different suggestion?
Associated revisions
allow plugin to provide attribute kinds (fixes #10783)
History
Updated by Benjamin Dauvergne over 6 years ago
- Status changed from Nouveau to Résolu (à déployer)
- % Done changed from 0 to 100
Appliqué par commit authentic2|e7248a8011a6d55ba39ef128c73ce42a8737c397.
Updated by Frédéric Péters over 6 years ago
I can dig into the commit but a short explanation would be faster.
Updated by Benjamin Dauvergne over 6 years ago
Just add an attribute_kinds property or method to your plugin, it must return a list of dictionnaries (like A2_ATTRIBUTE_KINDS).
add helper to collect data from plugins (#10783)