Example #1
0
    def get_selectable_people(self, request):
        """ Returns a list of people which may be linked. """

        query = PersonCollection(request.app.session()).query()
        query = query.order_by(Person.last_name, Person.first_name)

        return query.all()
Example #2
0
    def people(self):
        """ Returns the people linked to this content or None.

        The context specific function is temporarily stored on the
        ``context_specific_function`` attribute on each object in the
        resulting list.

        """

        if not self.content.get('people'):
            return None

        people = OrderedDict(self.content['people'])

        query = PersonCollection(object_session(self)).query()
        query = query.filter(Person.id.in_(people.keys()))

        result = []

        for person in query.all():
            person.context_specific_function = people[person.id.hex]
            result.append(person)

        order = list(people.keys())
        result.sort(key=lambda p: order.index(p.id.hex))

        return result
Example #3
0
    def people(self):
        if "people" in self.content:
            people = OrderedDict(self.content["people"])

            if len(people):
                query = PersonCollection(object_session(self)).query()
                query = query.filter(Person.id.in_(people.keys()))
                query = query.order_by(Person.last_name, Person.first_name)

                result = query.all()

                for person in result:
                    person.context_specific_function = people[person.id.hex]

                return result
Example #4
0
def test_full_name(session):
    people = PersonCollection(session)

    tom = people.add(
        first_name='Tom',
        last_name='Chandler'
    )
    rachel = people.add(
        first_name='Rachel',
        last_name='Scott',
        salutation='Dr.'
    )

    assert tom.title == 'Chandler Tom'
    assert rachel.title == 'Scott Rachel'
Example #5
0
    def get_selectable_people(self, request):
        query = PersonCollection(request.app.session()).query()
        query = query.order_by(Person.last_name, Person.first_name)

        return query.all()