示例#1
0
def person_from_data(person_data, event):
    user = User.find_first(~User.is_deleted, User.all_emails.contains(person_data['email'].lower()))
    if user:
        return EventPerson.for_user(user, event)

    person = EventPerson.find_first(event_new=event, email=person_data['email'].lower())
    if not person:
        person = EventPerson(event_new=event, **person_data)
    return person
示例#2
0
文件: legacy.py 项目: wtakase/indico
def person_from_data(person_data, event):
    user = User.find_first(~User.is_deleted, User.all_emails.contains(person_data['email'].lower()))
    if user:
        return EventPerson.for_user(user, event)

    person = EventPerson.find_first(event_new=event, email=person_data['email'].lower())
    if not person:
        person = EventPerson(event_new=event, **person_data)
    return person
示例#3
0
文件: fields.py 项目: nyimbi/indico
 def _get_event_person_for_user(self, user):
     person = EventPerson.for_user(
         user, self.event, is_untrusted=self.create_untrusted_persons)
     # Keep a reference to the user to cancel the conversion if the person is not persisted to the db
     self.event_person_conversions[person] = user
     return person
示例#4
0
 def _get_event_person_for_user(self, user):
     person = EventPerson.for_user(user, self.event, is_untrusted=self.create_untrusted_persons)
     # Keep a reference to the user to cancel the conversion if the person is not persisted to the db
     self.event_person_conversions[person] = user
     return person
示例#5
0
def get_event_person_for_user(event, user, create_untrusted_persons=False):
    """Return the event person that links to a given User/Event (if any)."""
    return EventPerson.for_user(user, event, is_untrusted=create_untrusted_persons)
示例#6
0
def test_filter_contrib_entries(app, db, dummy_event, create_user,
                                create_contribution, create_registration):
    registered_user = create_user(1)
    registered_speaker = create_user(2)
    unregistered_user = create_user(3)
    dummy_regform = RegistrationForm(event=dummy_event,
                                     title='Registration Form',
                                     currency='USD')
    dummy_event.registrations.append(
        create_registration(registered_user, dummy_regform))
    dummy_event.registrations.append(
        create_registration(registered_speaker, dummy_regform))
    registered_speaker_contribution = create_contribution(
        dummy_event,
        'Registered Speaker',
        person_links=[
            ContributionPersonLink(person=EventPerson.create_from_user(
                registered_speaker, dummy_event),
                                   is_speaker=True)
        ])
    registered_speaker_author_contribution = create_contribution(
        dummy_event,
        'Registered Speaker Author',
        person_links=[
            ContributionPersonLink(person=EventPerson.for_user(
                registered_speaker, dummy_event),
                                   is_speaker=True,
                                   author_type=AuthorType.primary)
        ])
    unregistered_speaker_registered_author_contribution = create_contribution(
        dummy_event,
        'Unregistered Speaker, Registered Author',
        person_links=[
            ContributionPersonLink(person=EventPerson.for_user(
                unregistered_user, dummy_event),
                                   is_speaker=True),
            ContributionPersonLink(person=EventPerson.for_user(
                registered_user, dummy_event),
                                   author_type=AuthorType.primary)
        ])
    registered_speaker_unregistered_author_contribution = create_contribution(
        dummy_event,
        'Registered Speaker, Unregistered Author',
        person_links=[
            ContributionPersonLink(person=EventPerson.for_user(
                registered_user, dummy_event),
                                   is_speaker=True),
            ContributionPersonLink(person=EventPerson.for_user(
                unregistered_user, dummy_event),
                                   author_type=AuthorType.primary)
        ])
    # Filter contributions with registered users
    with app.test_request_context():
        list_gen = ContributionListGenerator(dummy_event)
        list_gen.list_config['filters'] = {'items': {'people': {'registered'}}}
        result = list_gen.get_list_kwargs()
    assert result['contribs'] == [
        registered_speaker_contribution,
        registered_speaker_author_contribution,
        unregistered_speaker_registered_author_contribution,
        registered_speaker_unregistered_author_contribution
    ]

    # Filter contributions with registered speakers
    list_gen.list_config['filters'] = {'items': {'speakers': {'registered'}}}
    with app.test_request_context():
        result = list_gen.get_list_kwargs()
    assert result['contribs'] == [
        registered_speaker_contribution,
        registered_speaker_author_contribution,
        registered_speaker_unregistered_author_contribution
    ]

    # Filter contributions with unregistered speakers and registered users
    list_gen.list_config['filters'] = {
        'items': {
            'speakers': {'not_registered'},
            'people': {'registered'}
        }
    }
    with app.test_request_context():
        result = list_gen.get_list_kwargs()
    assert result['contribs'] == [
        unregistered_speaker_registered_author_contribution
    ]
示例#7
0
文件: util.py 项目: bkolobara/indico
def get_event_person_for_user(event, user, create_untrusted_persons=False):
    """Return the event person that links to a given User/Event (if any)."""
    return EventPerson.for_user(user, event, is_untrusted=create_untrusted_persons)