Example #1
0
 def _serialize_person_link(self, principal):
     from indico.modules.events.persons.schemas import PersonLinkSchema
     data = PersonLinkSchema().dump(principal)
     data['roles'] = []
     if principal.is_speaker:
         data['roles'].append('speaker')
     return data
Example #2
0
 def _serialize_person_link(self, principal):
     from indico.modules.events.persons.schemas import PersonLinkSchema
     data = PersonLinkSchema().dump(principal)
     data['roles'] = []
     if (self.get_form().is_submitted()
             and self.data[principal]) or (principal.event
                                           and principal.is_submitter):
         data['roles'].append('submitter')
     return data
Example #3
0
 def _serialize_person_link(self, principal):
     from indico.modules.events.persons.schemas import PersonLinkSchema
     data = PersonLinkSchema().dump(principal)
     data['roles'] = []
     if principal.is_speaker:
         data['roles'].append('speaker')
     is_submitter = (self.data[principal] if self.get_form().is_submitted()
                     else principal.contribution and principal.is_submitter)
     data['roles'].append(principal.author_type.name)
     if is_submitter:
         data['roles'].append('submitter')
     return data
Example #4
0
 def _get_person_link(self, data):
     from indico.modules.events.persons.schemas import PersonLinkSchema
     identifier = data.get('identifier')
     data = PersonLinkSchema(unknown=EXCLUDE).load(data)
     if identifier and identifier.startswith('ExternalUser:'******'external-user')
         external_user_data = cache.get(
             identifier.removeprefix('ExternalUser:'******'affiliation_data'))
                 and data['affiliation'] == affiliation_data['name']):
             data['affiliation_link'] = Affiliation.get_or_create_from_data(
                 affiliation_data)
             data['affiliation'] = data['affiliation_link'].name
Example #5
0
def test_submitter_permissions(app, db, dummy_event, dummy_user):
    from indico.modules.events.persons.schemas import PersonLinkSchema
    person = EventPerson.create_from_user(dummy_user, dummy_event)
    person_link = EventPersonLink(person=person)
    dummy_event.person_links = [person_link]
    dummy_event.update_principal(person_link.person.principal,
                                 add_permissions={'submit'})
    with app.test_request_context():
        form = MockForm(event=dummy_event)
    form.person_link_data.data = dummy_event.person_links
    # Remove all persons
    form.person_link_data.process_formdata(['[]'])
    dummy_event.person_link_data = form.person_link_data.data
    db.session.flush()
    assert person.has_role('submit', dummy_event) is False
    # Serialize a person_link with a submitter role
    input_person = PersonLinkSchema().dump(person_link)
    input_person['roles'] = ['submitter']
    form.person_link_data.process_formdata([json.dumps([input_person])])
    dummy_event.person_link_data = form.person_link_data.data
    db.session.flush()
    assert person.has_role('submit', dummy_event) is True
Example #6
0
def serialize_contribution_for_ical(contrib):
    from indico.modules.events.persons.schemas import PersonLinkSchema
    return {
        '_fossil':
        'contributionMetadata',
        'id':
        contrib.id,
        'startDate':
        contrib.timetable_entry.start_dt if contrib.timetable_entry else None,
        'endDate':
        contrib.timetable_entry.end_dt if contrib.timetable_entry else None,
        'url':
        url_for('contributions.display_contribution', contrib, _external=True),
        'title':
        contrib.title,
        'location':
        contrib.venue_name,
        'roomFullname':
        contrib.room_name,
        'speakers': [PersonLinkSchema().dump(x) for x in contrib.speakers],
        'description':
        contrib.description
    }
Example #7
0
 def _serialize_person_link(self, principal):
     from indico.modules.events.persons.schemas import PersonLinkSchema
     return PersonLinkSchema().dump(principal)