Пример #1
0
class CatalogueYearTable(tables.Table):
    uuid = ActionColumn('catalogueyear_detail',
                        'change_catalogueyear',
                        'delete_catalogueyear',
                        orderable=False)

    class Meta:
        model = CatalogueYear
        attrs = {'class': 'table table-sortable'}
        sequence = ['catalogue', 'year', 'uuid']
Пример #2
0
class DocumentScanTable(tables.Table):
    uuid = ActionColumn('documentscan_detail',
                        'change_documentscan',
                        'delete_documentscan',
                        orderable=False)

    class Meta:
        model = DocumentScan
        attrs = {'class': 'table table-sortable'}
        sequence = ['transcription', 'scan', 'uuid']
Пример #3
0
class ResidenceTable(tables.Table):
    uuid = ActionColumn('residence_detail',
                        'change_residence',
                        'delete_residence',
                        orderable=False)

    class Meta:
        model = Residence
        attrs = {'class': 'table table-sortable'}
        sequence = ['person', 'place', 'start_year', 'end_year', 'uuid']
Пример #4
0
class CountryTable(tables.Table):
    uuid = ActionColumn('country_detail',
                        'change_country',
                        'delete_country',
                        orderable=False)

    class Meta:
        model = Country
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'uuid']
Пример #5
0
class PersonPersonRelationTypeTable(tables.Table):
    uuid = ActionColumn('personpersonrelationtype_detail',
                        'change_personpersonrelationtype',
                        'delete_personpersonrelationtype',
                        orderable=False)

    class Meta:
        model = PersonPersonRelationType
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'directed', 'uuid']
Пример #6
0
class ProfessionTable(tables.Table):
    uuid = ActionColumn('profession_detail',
                        'change_profession',
                        'delete_profession',
                        orderable=False)

    class Meta:
        model = Profession
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'description', 'uuid']
Пример #7
0
class CatalogueTable(tables.Table):
    uuid = ActionColumn('catalogue_detail',
                        'change_catalogue',
                        'delete_catalogue',
                        orderable=False)

    class Meta:
        model = Catalogue
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'dataset', 'uuid']
Пример #8
0
class PersonCatalogueRelationTable(tables.Table):
    uuid = ActionColumn('personcataloguerelation_detail',
                        'change_personcataloguerelation',
                        'delete_personcataloguerelation',
                        orderable=False)

    class Meta:
        model = PersonCatalogueRelation
        attrs = {'class': 'table table-sortable'}
        sequence = ['person', 'catalogue', 'uuid']
Пример #9
0
class SourceMaterialTable(tables.Table):
    uuid = ActionColumn('sourcematerial_detail',
                        'change_sourcematerial',
                        'delete_sourcematerial',
                        orderable=False)

    class Meta:
        model = SourceMaterial
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'uuid']
Пример #10
0
class TranscriptionTable(tables.Table):
    uuid = ActionColumn('transcription_detail',
                        'change_transcription',
                        'delete_transcription',
                        orderable=False)

    class Meta:
        model = Transcription
        attrs = {'class': 'table table-sortable'}
        sequence = ['source_material', 'curator', 'author', 'date', 'uuid']
Пример #11
0
class CollectionPlaceRelationTypeTable(tables.Table):
    uuid = ActionColumn('collectionplacerelationtype_detail',
                        'change_collectionplacerelationtype',
                        'delete_collectionplacerelationtype',
                        orderable=False)

    class Meta:
        model = CollectionPlaceRelationType
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'uuid']
Пример #12
0
class ParisianCategoryTable(tables.Table):
    uuid = ActionColumn('parisiancategory_detail',
                        'change_parisiancategory',
                        'delete_parisiancategory',
                        orderable=False)

    class Meta:
        model = ParisianCategory
        attrs = {'class': 'table table-sortable'}
        sequence = ['name', 'description', 'uuid']
Пример #13
0
class ReligiousAffiliationTable(tables.Table):
    uuid = ActionColumn('religiousaffiliation_detail',
                        'change_religiousaffiliation',
                        'delete_religiousaffiliation',
                        orderable=False)

    class Meta:
        model = ReligiousAffiliation
        attrs = {'class': 'table table-sortable'}
        sequence = ['person', 'religion', 'uuid']
Пример #14
0
class CollectionHeldByTable(tables.Table):
    uuid = ActionColumn('collectionheldby_detail',
                        'change_collectionheldby',
                        'delete_collectionheldby',
                        orderable=False)

    class Meta:
        model = CollectionHeldBy
        attrs = {'class': 'table table-sortable'}
        sequence = ['library', 'collection', 'uuid']
Пример #15
0
class PlaceTable(tables.Table):
    uuid = ActionColumn('place_detail',
                        'change_place',
                        'delete_place',
                        orderable=False)

    class Meta:
        model = Place
        attrs = {'class': 'table table-sortable'}
        sequence = [
            'name', 'cerl_id', 'country', 'longitude', 'latitude', 'uuid'
        ]
Пример #16
0
class PersonPersonRelationTable(tables.Table):
    uuid = ActionColumn('personpersonrelation_detail',
                        'change_personpersonrelation',
                        'delete_personpersonrelation',
                        orderable=False)

    class Meta:
        model = PersonPersonRelation
        attrs = {'class': 'table table-sortable'}
        sequence = [
            'first_person', 'second_person', 'type', 'start_year', 'end_year',
            'uuid'
        ]
Пример #17
0
class CategoryTable(tables.Table):
    uuid = ActionColumn('category_detail',
                        'change_category',
                        'delete_category',
                        orderable=False)
    parent = tables.LinkColumn(verbose_name="Parent category")

    class Meta:
        model = Category
        attrs = {'class': 'table table-sortable'}
        sequence = [
            'collection', 'parent', 'bookseller_category', 'parisian_category',
            'uuid'
        ]
Пример #18
0
class LotTable(tables.Table):
    uuid = ActionColumn('lot_detail',
                        'change_lot',
                        'delete_lot',
                        orderable=False)
    collection = tables.RelatedLinkColumn()
    category = tables.RelatedLinkColumn()

    class Meta:
        model = Lot
        attrs = {'class': 'table table-sortable'}
        sequence = [
            'collection', 'category', 'number_in_collection',
            'page_in_collection', 'lot_as_listed_in_collection', 'sales_price',
            'uuid'
        ]
Пример #19
0
class PersonTable(tables.Table):
    uuid = ActionColumn('person_detail',
                        'change_person',
                        'delete_person',
                        orderable=False)
    collections = tables.Column(empty_values=())
    roles = tables.Column(empty_values=())
    viaf_id = tables.Column(empty_values=())
    relations = tables.Column(verbose_name=_("Relations"),
                              orderable=False,
                              empty_values=())

    class Meta:
        model = Person
        attrs = {'class': 'table table-sortable'}
        sequence = [
            'short_name', 'first_names', 'surname', 'sex', 'roles',
            'city_of_birth', 'date_of_birth', 'city_of_death', 'date_of_death',
            'collections', 'viaf_id', 'publisher_cerl_id', 'notes',
            'bibliography', 'relations', 'uuid'
        ]

    def render_collections(self, record):
        person_collection_relations = PersonCollectionRelation.objects.filter(
            person=record, role__name="owner")
        relation_groups = []
        for role in set(
            [relation.role for relation in person_collection_relations]):
            role_relations = person_collection_relations.filter(role=role)
            collections = []
            for relation in role_relations:
                collection = relation.collection
                title = collection.short_title
                collection_entry = "<a href='{}'>{}</a>".format(
                    reverse_lazy('collection_detail', args=[collection.pk]),
                    title)
                collections.append(collection_entry)

            relation_groups.append(", ".join(collections))
        return format_html("<br/> ".join(relation_groups))

    def render_roles(self, record):
        roles_dict = {}

        # Collections
        collection_roles = list(
            PersonCollectionRelation.objects.filter(
                person=record).distinct().values_list('role__name', flat=True))
        if collection_roles:
            roles_dict['collections'] = collection_roles

        # Items
        item_roles = list(
            PersonItemRelation.objects.filter(
                person=record).distinct().values_list('role__name', flat=True))
        if item_roles:
            roles_dict['items'] = item_roles

        # Editions
        editions_count = record.publisher_set.count()
        if editions_count:
            roles_dict['edition'] = ['publisher']

        # Works
        work_count = record.works.count()
        if work_count:
            roles_dict['works'] = ['author']

        text = "<br/>".join([
            "{}: {}".format(k.capitalize(), ", ".join(v))
            for k, v in roles_dict.items()
        ])
        return format_html('<a href="{}">{}</a>'.format(
            reverse_lazy('person_detail', args=[record.pk]), text))

    def render_viaf_id(self, value):
        if value:
            return format_html('<a target="blank" href="{}">{}</a>'.format(
                value, value))
        else:
            return format_html('-')

    def render_publisher_cerl_id(self, value):
        if value:
            url = cerl_record_url + value
            return format_html('<a target="blank" href="{}">{}</a>'.format(
                url, value))
        else:
            return format_html('-')

    def render_relations(self, record):
        person = record
        of_str = ' of'
        relations = []
        for relation in person.relations_when_first.all():
            relation_of_str = '' if relation.type.name.endswith(
                of_str) else of_str
            relation_str = format_html(
                _('{}{} <a href="{}">{}</a>'),
                str(relation.type).capitalize(), relation_of_str,
                relation.second_person.get_absolute_url(),
                relation.second_person)
            relations.append(relation_str)
        for relation in person.relations_when_second.all():
            type = str(relation.type)
            type_without_of = type[:-len(of_str)] if type.endswith(
                of_str) else type
            relation_str = format_html(
                _('{}: <a href="{}">{}</a>'), type_without_of.capitalize(),
                relation.first_person.get_absolute_url(),
                relation.first_person)
            relations.append(relation_str)
        return format_html_join('\n', '{}<br/>',
                                ((rel, ) for rel in relations))
Пример #20
0
class PlaceLinksTable(tables.Table):
    uuid = ActionColumn('place_detail',
                        'change_place',
                        'delete_place',
                        orderable=False)
    collections = tables.Column(empty_values=(),
                                verbose_name="Collections",
                                orderable=False)
    editions = tables.Column(empty_values=(),
                             verbose_name="Editions",
                             orderable=False)
    people_born = tables.Column(empty_values=(),
                                verbose_name="People born",
                                orderable=False)
    people_died = tables.Column(empty_values=(),
                                verbose_name="People died",
                                orderable=False)
    residences = tables.Column(empty_values=(),
                               verbose_name="People inhabiting",
                               orderable=False)

    class Meta:
        model = Place
        attrs = {'class': 'table table-sortable'}
        fields = [
            'name', 'collections', 'editions', 'people_born', 'people_died',
            'residences', 'uuid'
        ]

    def render_collections(self, record):
        relations = CollectionPlaceRelation.objects.filter(
            place=record).prefetch_related('type')
        type_dict = defaultdict(list)
        for relation in relations:
            type_dict[relation.type.name].append(relation.collection)

        return format_html("<br/>".join([
            type.capitalize() + ": " + ", ".join([
                '<a href="{}">{}</a>'.format(
                    reverse_lazy('collection_detail', args=[collection.pk]),
                    collection) for collection in collections
            ]) for type, collections in type_dict.items()
        ]))

    def render_editions(self, record):
        editions = Edition.objects.filter(place=record)
        return format_html(", ".join([
            '<a href="{}">{}</a>'.format(
                reverse_lazy('edition_detail', args=[edition.pk]), edition)
            for edition in editions
        ]))

    def render_people_born(self, record):
        persons = Person.objects.filter(city_of_birth=record)
        return format_html(", ".join([
            '<a href="{}">{}</a>'.format(
                reverse_lazy('person_detail', args=[person.pk]), person)
            for person in persons
        ]))

    def render_people_died(self, record):
        persons = Person.objects.filter(city_of_death=record)
        return format_html(", ".join([
            '<a href="{}">{}</a>'.format(
                reverse_lazy('person_detail', args=[person.pk]), person)
            for person in persons
        ]))

    def render_residences(self, record):
        persons = Person.objects.filter(residence__place=record)
        return format_html(", ".join([
            '<a href="{}">{}</a>'.format(
                reverse_lazy('person_detail', args=[person.pk]), person)
            for person in persons
        ]))