40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
|
from django_elasticsearch_dsl import DocType, Index, fields
|
||
|
from .models import Stage, AvisStage, AvisLieu
|
||
|
|
||
|
stage = Index('stages')
|
||
|
stage.settings(
|
||
|
number_of_shards=1,
|
||
|
number_of_replicas=0
|
||
|
)
|
||
|
|
||
|
@stage.doc_type
|
||
|
class StageDocument(DocType):
|
||
|
lieux = fields.ObjectField(properties={
|
||
|
'nom': fields.StringField(),
|
||
|
'pays': fields.StringField(),
|
||
|
})
|
||
|
thematiques = fields.StringField()
|
||
|
matieres = fields.StringField()
|
||
|
|
||
|
class Meta:
|
||
|
model = Stage
|
||
|
fields = [
|
||
|
'sujet',
|
||
|
'encadrants',
|
||
|
'type_stage',
|
||
|
'niveau_scol',
|
||
|
'structure'
|
||
|
]
|
||
|
|
||
|
def prepare_thematiques(self, instance):
|
||
|
return ", ".join(instance.thematiques.all().values_list("slug", flat=True))
|
||
|
|
||
|
def prepare_matieres(self, instance):
|
||
|
return ", ".join(instance.matieres.all().values_list("slug", flat=True))
|
||
|
|
||
|
def prepare_niveau_scol(self, instance):
|
||
|
return instance.get_niveau_scol_display()
|
||
|
|
||
|
def prepare_type_stage(self, instance):
|
||
|
return instance.type_stage_fancy
|