Support #10783
best way to add extra attribute kinds?
Début:
01 mai 2016
Echéance:
% réalisé:
100%
Temps estimé:
Patch proposed:
Non
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?
Révisions associées
allow plugin to provide attribute kinds (fixes #10783)
Historique
Mis à jour par Benjamin Dauvergne il y a presque 8 ans
- Statut changé de Nouveau à Résolu (à déployer)
- % réalisé changé de 0 à 100
Appliqué par commit authentic2|e7248a8011a6d55ba39ef128c73ce42a8737c397.
Mis à jour par Frédéric Péters il y a presque 8 ans
I can dig into the commit but a short explanation would be faster.
Mis à jour par Benjamin Dauvergne il y a presque 8 ans
Just add an attribute_kinds property or method to your plugin, it must return a list of dictionnaries (like A2_ATTRIBUTE_KINDS).
Mis à jour par Benjamin Dauvergne il y a plus de 7 ans
- Statut changé de Résolu (à déployer) à Fermé
add helper to collect data from plugins (#10783)