• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NaturalHistoryMuseum / ckanext-webview / #106

04 Nov 2024 11:56AM UTC coverage: 40.476%. Remained the same
#106

push

coveralls-python

web-flow
merge: PR #28 from dev

Weekly release 2024-11-04

0 of 2 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

17 of 42 relevant lines covered (40.48%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ckanext/webview/plugin.py
1
#!/usr/bin/env python
2
# encoding: utf-8
3
#
4
# This file is part of ckanext-webview
5
# Created by the Natural History Museum in London, UK
6

7
from ckan.plugins import SingletonPlugin, implements, interfaces, toolkit
×
8

UNCOV
9
from ckanext.webview.logic.validators import is_valid_url, not_datastore
×
10

11
ignore_empty = toolkit.get_validator('ignore_empty')
×
12

13

14
class WebviewPlugin(SingletonPlugin):
×
15
    """
16
    A CKAN extension that adds a view for displaying generic/arbitrary URLs.
17
    """
18

19
    implements(interfaces.IConfigurer, inherit=True)
×
20
    implements(interfaces.IResourceView, inherit=True)
×
21

22
    ## IConfigurer
23
    def update_config(self, config):
×
NEW
24
        toolkit.add_template_directory(config, 'theme/templates')
×
NEW
25
        toolkit.add_resource('theme/assets', 'ckanext-webview')
×
26

27
    ## IResourceView
28
    def info(self):
×
29
        return {
×
30
            'name': 'web_view',
31
            'title': 'Web',
32
            'icon': 'globe',
33
            'always_available': True,
34
            'iframed': False,
35
            'schema': {'web_url': [not_datastore, ignore_empty, str, is_valid_url]},
36
        }
37

38
    def can_view(self, data_dict):
×
39
        return True
×
40

41
    def setup_template_variables(self, context, data_dict):
×
42
        # defaults to the resource URL but can be overridden
43
        web_url = data_dict['resource_view'].get('web_url') or data_dict[
×
44
            'resource'
45
        ].get('url')
46

47
        return {'web_url': web_url}
×
48

49
    def view_template(self, context, data_dict):
×
50
        """
51
        :param context:
52
        :param data_dict:
53
        """
54
        return 'views/web_view.html'
×
55

56
    def form_template(self, context, data_dict):
×
57
        """
58
        :param context:
59
        :param data_dict:
60
        """
61
        return 'views/web_view_form.html'
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc