Skip to content

Sample

SampleView

Bases: DefaultView

Controller for displaying a sample record.

Source code in ckanext/nhm/views/sample.py
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
class SampleView(DefaultView):
    """
    Controller for displaying a sample record.
    """

    resource_id = toolkit.config.get('ckanext.nhm.sample_resource_id')

    field_facets = [
        'project',
        'order',
        'preparationType',
        'preparationContents',
        'preparationProcess',
    ]

    # Additional search filter options
    filter_options = [has_image, has_lat_long]

    field_groups = OrderedDict(
        [
            (
                'Project',
                OrderedDict(
                    [
                        ('project', 'Project'),
                    ]
                ),
            ),
            (
                'Preparation',
                OrderedDict(
                    [
                        ('preparationDate', 'Preparation Date'),
                        ('preparationType', 'Preparation Type'),
                        ('preparationProcess', 'Preparation Process'),
                        ('identifier', 'Preparation Number'),
                        ('preservation', 'Preservation'),
                        ('preparationContents', 'Preparation Contents'),
                        ('occurrenceID', 'Occurrence ID'),
                    ]
                ),
            ),
            (
                'Specimen',
                OrderedDict(
                    [
                        ('associatedOccurrences', 'Voucher specimen'),
                        ('associatedMediaCount', 'Image Count'),
                        ('barcode', 'Barcode'),
                        ('scientificName', 'Scientific Name'),
                        ('order', 'Order'),
                        ('identifiedBy', 'Identified By'),
                        ('locality', 'Locality'),
                        ('decimalLatitude', 'Decimal Latitude'),
                        ('decimalLongitude', 'Decimal Longitude'),
                    ]
                ),
            ),
            (
                'Record',
                OrderedDict(
                    [
                        ('GUID', 'GUID'),
                        ('modified', 'Modified'),
                        ('created', 'Created'),
                    ]
                ),
            ),
        ]
    )

    def render_record(self, c):
        """

        :param c:

        """
        c.field_groups = self.field_groups
        return toolkit.render('record/collection.html')

render_record(c)

Parameters:

Name Type Description Default
c
required
Source code in ckanext/nhm/views/sample.py
119
120
121
122
123
124
125
126
def render_record(self, c):
    """

    :param c:

    """
    c.field_groups = self.field_groups
    return toolkit.render('record/collection.html')

modify_field_groups(field_groups)

Given a FieldGroups object from the vds plugin, force certain field groups to show in multisearch results and force certain field groups to be ignored and not shown.

Parameters:

Name Type Description Default
field_groups

a FieldGroups object

required
Source code in ckanext/nhm/views/sample.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def modify_field_groups(field_groups):
    """
    Given a FieldGroups object from the vds plugin, force certain field groups to show
    in multisearch results and force certain field groups to be ignored and not shown.

    :param field_groups: a FieldGroups object
    """
    # forces
    field_groups.force('scientificName')
    field_groups.force('identifier')
    field_groups.force('preparationType')
    field_groups.force('preparationContents')
    field_groups.force('preparationProcess')
    field_groups.force('preservation')
    field_groups.force('preparationDate')
    field_groups.force('barcode')
    field_groups.force('occurrenceID')
    field_groups.force('associatedOccurrences')
    field_groups.force('associatedMediaCount')
    field_groups.force('order')
    field_groups.force('identifiedBy')
    field_groups.force('locality')
    field_groups.force('decimalLatitude')
    field_groups.force('decimalLongitude')
    # ignores
    field_groups.ignore('created')
    field_groups.ignore('modified')
    field_groups.ignore('associatedMedia.*')