bifurqué depuis cliss21/creme_center_fibois
feat(pilote_extended): customise l'affichage d'une organisation
+ ajout de champs standardmain
Parent
3ad92614eb
révision
eb18d23c9f
|
@ -4,12 +4,13 @@ from creme.creme_core.management.commands.creme_populate import BasePopulator
|
|||
from creme.creme_core.models import BrickDetailviewLocation
|
||||
|
||||
from .. import bricks
|
||||
from .brick import PopulateBrickMixin
|
||||
from .form import PopulateFormMixin
|
||||
|
||||
HAT = BrickDetailviewLocation.HAT
|
||||
|
||||
|
||||
class Populator(BasePopulator, PopulateFormMixin):
|
||||
class Populator(BasePopulator, PopulateFormMixin, PopulateBrickMixin):
|
||||
dependencies = ['creme_core', 'persons']
|
||||
overwrite = True
|
||||
|
||||
|
@ -45,9 +46,6 @@ class Populator(BasePopulator, PopulateFormMixin):
|
|||
order=1,
|
||||
)
|
||||
|
||||
def _populate_bricks(self):
|
||||
pass
|
||||
|
||||
def populate(self):
|
||||
self._populate_rel()
|
||||
self._populate_form()
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from creme.creme_core.core.entity_cell import EntityCellRegularField
|
||||
from creme.creme_core.models import (
|
||||
BrickDetailviewLocation,
|
||||
CustomBrickConfigItem,
|
||||
)
|
||||
|
||||
LEFT = BrickDetailviewLocation.LEFT
|
||||
|
||||
|
||||
class PopulateBrickMixin:
|
||||
def _populate_bricks(self):
|
||||
# if overwrite, erase and rewind
|
||||
if self.overwrite:
|
||||
CustomBrickConfigItem.objects.filter(
|
||||
id__in=('persons-organisation_identification',)
|
||||
).delete()
|
||||
# do not populate if it is already done
|
||||
if CustomBrickConfigItem.objects.filter(
|
||||
id='persons-organisation_identification'
|
||||
).exists():
|
||||
return
|
||||
# remove complementary info
|
||||
BrickDetailviewLocation.objects.filter(
|
||||
brick_id='customblock-persons-organisation_complementary'
|
||||
).delete()
|
||||
|
||||
get_or_create_cbci = CustomBrickConfigItem.objects.get_or_create
|
||||
build_cell = EntityCellRegularField.build
|
||||
|
||||
# remove complementary info
|
||||
BrickDetailviewLocation.objects.filter(
|
||||
brick_id='customblock-persons-organisation_complementary'
|
||||
).delete()
|
||||
# replace with our
|
||||
cbci_orga_identification, created = get_or_create_cbci(
|
||||
id='persons-organisation_identification',
|
||||
defaults={
|
||||
'name': "Identification de l'organisation",
|
||||
'content_type': self.Organisation,
|
||||
'cells': [
|
||||
build_cell(self.Organisation, 'name'),
|
||||
build_cell(self.Organisation, 'activite'),
|
||||
build_cell(self.Organisation, 'activite_secondaire'),
|
||||
build_cell(self.Organisation, 'staff_size'),
|
||||
build_cell(self.Organisation, 'naf'),
|
||||
build_cell(self.Organisation, 'siret'),
|
||||
build_cell(self.Organisation, 'siren'),
|
||||
build_cell(self.Organisation, 'legal_form'),
|
||||
build_cell(self.Organisation, 'capital'),
|
||||
build_cell(self.Organisation, 'image'),
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
# create display
|
||||
BrickDetailviewLocation.objects.multi_create(
|
||||
defaults={'model': self.Organisation, 'zone': LEFT},
|
||||
data=[
|
||||
{'brick': cbci_orga_identification.brick_id, 'order': 5},
|
||||
],
|
||||
)
|
|
@ -70,6 +70,13 @@ class PopulateFormMixin:
|
|||
(ecrf, {'name': 'name'}),
|
||||
(ecrf, {'name': 'activite'}),
|
||||
(ecrf, {'name': 'activite_secondaire'}),
|
||||
(ecrf, {'name': 'staff_size'}),
|
||||
(ecrf, {'name': 'naf'}),
|
||||
(ecrf, {'name': 'siret'}),
|
||||
(ecrf, {'name': 'siren'}),
|
||||
(ecrf, {'name': 'legal_form'}),
|
||||
(ecrf, {'name': 'capital'}),
|
||||
(ecrf, {'name': 'image'}),
|
||||
],
|
||||
},
|
||||
AddressesGroup(model=self.Organisation),
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket