Skip to content

Dwc

DarwinCoreView

Bases: DefaultView

View for displaying DwC resources.

Source code in ckanext/nhm/views/dwc.py
17
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class DarwinCoreView(DefaultView):
    """
    View for displaying DwC resources.
    """

    format = 'dwc'

    grid_default_columns = [
        '_id',
        'gbifIssue',
        'scientificName',
        'scientificNameAuthorship',
        'specificEpithet',
        'infraspecificEpithet',
        'family',
        'genus',
        'class',
        'locality',
        'country',
        'viceCounty',
        'recordedBy',
        'typeStatus',
        'catalogNumber',
        'collectionCode',
    ]

    grid_column_widths = {
        'gbifIssue': 70,
        'catalogNumber': 120,
        'scientificNameAuthorship': 180,
        'scientificName': 160,
    }

    def render_record(self, c):
        """

        :param c:

        """

        if c.resource['format'].lower() != 'dwc':
            toolkit.abort(404, toolkit._('Record not in Darwin Core format'))

        c.record_title = c.record_dict.get('catalogNumber', None) or c.record_dict.get(
            'occurrenceID'
        )
        fields = toolkit.h.resource_view_get_fields(c.resource)
        c.dwc_terms = dwc_terms(fields)

        try:
            c.dynamic_properties = c.dwc_terms.pop('dynamicProperties')
        except IndexError:
            c.dynamic_properties = []

        return toolkit.render('record/dwc.html')

render_record(c)

Parameters:

Name Type Description Default
c
required
Source code in ckanext/nhm/views/dwc.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def render_record(self, c):
    """

    :param c:

    """

    if c.resource['format'].lower() != 'dwc':
        toolkit.abort(404, toolkit._('Record not in Darwin Core format'))

    c.record_title = c.record_dict.get('catalogNumber', None) or c.record_dict.get(
        'occurrenceID'
    )
    fields = toolkit.h.resource_view_get_fields(c.resource)
    c.dwc_terms = dwc_terms(fields)

    try:
        c.dynamic_properties = c.dwc_terms.pop('dynamicProperties')
    except IndexError:
        c.dynamic_properties = []

    return toolkit.render('record/dwc.html')