mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Citadel: Update schemas
Co-authored-by: Pedro Lourenço <pedro.lourenco@cern.ch>
This commit is contained in:
parent
145b3f15c5
commit
d768f71767
@ -11,7 +11,8 @@ from marshmallow import fields, pre_load
|
||||
|
||||
from indico.modules.search.base import SearchTarget
|
||||
from indico.modules.search.result_schemas import (AggregationSchema, AttachmentResultSchema, BucketSchema,
|
||||
EventResultSchema, ResultItemSchema, ResultSchema)
|
||||
EventNoteResultSchema, EventResultSchema, ResultItemSchema,
|
||||
ResultSchema)
|
||||
|
||||
|
||||
class CitadelEventResultSchema(EventResultSchema):
|
||||
@ -26,10 +27,19 @@ class CitadelAttachmentResultSchema(AttachmentResultSchema):
|
||||
@pre_load
|
||||
def _translate_keys(self, data, **kwargs):
|
||||
data = data.copy()
|
||||
data['user'] = data.pop('persons', None)
|
||||
data['attachment_type'] = data.pop('type_format')
|
||||
return data
|
||||
|
||||
|
||||
class CitadelEventNoteResultSchema(EventNoteResultSchema):
|
||||
@pre_load
|
||||
def _translate_keys(self, data, **kwargs):
|
||||
data = data.copy()
|
||||
data['user'] = data.pop('persons', None)
|
||||
return data
|
||||
|
||||
|
||||
class _CitadelBucketSchema(BucketSchema):
|
||||
@pre_load
|
||||
def _make_filter(self, data, **kwargs):
|
||||
@ -52,6 +62,7 @@ class CitadelResultItemSchema(ResultItemSchema):
|
||||
**ResultItemSchema.type_schemas,
|
||||
SearchTarget.event.name: CitadelEventResultSchema,
|
||||
SearchTarget.attachment.name: CitadelAttachmentResultSchema,
|
||||
SearchTarget.event_note.name: CitadelEventNoteResultSchema,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -151,6 +151,8 @@ class AttachmentRecordSchema(RecordSchema, AttachmentSchema):
|
||||
@post_dump
|
||||
def _translate_keys(self, data, **kwargs):
|
||||
data['type_format'] = data.pop('attachment_type')
|
||||
if user := data['_data'].pop('user', None):
|
||||
data['_data']['persons'] = user
|
||||
return data
|
||||
|
||||
|
||||
@ -208,6 +210,8 @@ class _EventNoteDataSchema(EventNoteSchema):
|
||||
def _transform(self, data, **kwargs):
|
||||
if desc := data.get('content'):
|
||||
data['content'] = strip_tags(desc).strip()
|
||||
if user := data.pop('user', None):
|
||||
data['persons'] = user
|
||||
return data
|
||||
|
||||
|
||||
|
||||
@ -188,7 +188,7 @@ def test_dump_attachment(db, dummy_user, dummy_contribution):
|
||||
'filename': 'dummy_file.txt',
|
||||
'site': 'http://localhost',
|
||||
'title': 'Dummy Attachment',
|
||||
'user': {'name': 'Guinea Pig'},
|
||||
'persons': {'name': 'Guinea Pig'},
|
||||
},
|
||||
'attachment_id': attachment.id,
|
||||
'category_id': category_id,
|
||||
@ -247,7 +247,7 @@ def test_dump_event_note(db, dummy_user, dummy_event, dummy_contribution, link_t
|
||||
'content': 'this is a dummy note',
|
||||
'site': 'http://localhost',
|
||||
'title': f'{note.object.title} - Notes/Minutes',
|
||||
'user': {'name': 'Guinea Pig'}
|
||||
'persons': {'name': 'Guinea Pig'}
|
||||
},
|
||||
'category_id': category_id,
|
||||
'category_path': [
|
||||
|
||||
@ -77,9 +77,9 @@ class CitadelProvider(IndicoSearchProvider):
|
||||
|
||||
placeholders = {
|
||||
'title': ('_data.title', _('The title an event, contribution, etc.)')),
|
||||
'person': ('_data.persons.name', _("A speaker, author or event chair's name")),
|
||||
'affiliation': ('_data.persons.affiliation', _("A speaker, author or event chair's affiliation")),
|
||||
'type': ('type', _('An entry type (such as conference, meeting, file, etc.)')),
|
||||
'person': ('_data.persons_index.name', _("A speaker, author or event chair's name")),
|
||||
'affiliation': ('_data.persons_index.affiliation', _("A speaker, author or event chair's affiliation")),
|
||||
'type': ('type_any', _('An entry type (such as conference, meeting, file, etc.)')),
|
||||
'venue': ('_data.location.venue_name', _("Name of the venue")),
|
||||
'room': ('_data.location.room_name', _("Name of the room")),
|
||||
'address': ('_data.location.address', _("Address of the venue")),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user