コード例 #1
0
def init_app(app):
    endpoint_name = 'scheduled_reports'
    service = ScheduledReportsService(endpoint_name, backend=superdesk.get_backend())
    ScheduledReportsResource(endpoint_name, app=app, service=service)

    endpoint_name = SavedReportsResource.endpoint_name
    service = SavedReportsService(endpoint_name, backend=superdesk.get_backend())
    SavedReportsResource(endpoint_name, app=app, service=service)

    superdesk.privilege(
        name='global_saved_reports',
        label='Analytics - Manage Global Saved Reports',
        description='User can manage other uses\' global saved reports'
    )
    superdesk.privilege(
        name='saved_reports',
        label='Analytics - Manage Saved Reports',
        description='User can manage saved reports'
    )
    superdesk.privilege(
        name='scheduled_reports',
        label='Analytics - Manage Scheduling Reports',
        description='User can manage scheduling of reports'
    )

    endpoint_name = ReportConfigsResource.endpoint_name
    service = ReportConfigsService(endpoint_name, backend=superdesk.get_backend())
    ReportConfigsResource(endpoint_name, app=app, service=service)

    init_content_publishing_report(app)
    init_publishing_performance_report(app)
    init_email_report(app)
    init_planning_usage_report(app)
    init_stats(app)
    init_desk_activity_report(app)
    init_production_time_report(app)
    init_user_acitivity_report(app)
    init_featuremedia_updates_report(app)
    init_update_time_report(app)

    # If this app is for testing, then create an endpoint for the base reporting service
    # so the core searching/aggregation functionality can be tested
    if app.testing:
        class TestReportService(BaseReportService):
            aggregations = {
                'category': {'terms': {'field': 'anpa_category.qcode', 'size': 0}},
                'source': {'terms': {'field': 'source', 'size': 0}}
            }

        class BaseReportResource(superdesk.resource.Resource):
            item_methods = ['GET']
            resource_methods = ['GET']

        endpoint_name = 'analytics_test_report'
        service = TestReportService(endpoint_name, backend=superdesk.get_backend())
        BaseReportResource(endpoint_name, app=app, service=service)

    init_schedule_task(app)
コード例 #2
0
def init_app(app):
    endpoint_name = 'activity_report'
    service = ActivityReportService(endpoint_name,
                                    backend=superdesk.get_backend())
    ActivityReportResource(endpoint_name, app=app, service=service)
    register_report('activity_report', 'activity_report')

    endpoint_name = 'saved_activity_reports'
    service = SavedActivityReportService(endpoint_name,
                                         backend=superdesk.get_backend())
    SavedActivityReportResource(endpoint_name, app=app, service=service)

    endpoint_name = 'track_activity_report'
    service = TrackActivityService(endpoint_name,
                                   backend=superdesk.get_backend())
    TrackActivityResource(endpoint_name, app=app, service=service)
    register_report('track_activity_report', 'track_activity_report')

    endpoint_name = 'processed_items_report'
    service = ProcessedItemsService(endpoint_name,
                                    backend=superdesk.get_backend())
    ProcessedItemsResource(endpoint_name, app=app, service=service)
    register_report('processed_items_report', 'processed_items_report')

    endpoint_name = 'content_quota_report'
    service = ContentQuotaReportService(endpoint_name,
                                        backend=superdesk.get_backend())
    ContentQuotaReportResource(endpoint_name, app=app, service=service)
    register_report('content_quota_report', 'content_quota_report')

    endpoint_name = 'source_category_report'
    service = SourceCategoryReportService(endpoint_name,
                                          backend=superdesk.get_backend())
    SourceCategoryReportResource(endpoint_name, app=app, service=service)
    register_report('source_category_report', 'source_category_report')

    endpoint_name = 'scheduled_reports'
    service = ScheduledReportsService(endpoint_name,
                                      backend=superdesk.get_backend())
    ScheduledReportsResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name='activity_report',
                        label='Activity Report View',
                        description='User can view activity reports.')
    superdesk.privilege(name='track_activity_report',
                        label='Track Activity Report View')
    superdesk.privilege(name='processed_items_report',
                        label='Processed Items Report View',
                        description='User can view activity reports.')
    superdesk.privilege(name='content_quota_report',
                        label='Content Quota Report View',
                        description='User can view content v quota reports.')
    superdesk.privilege(name='source_category_report',
                        label='Source Category Report View',
                        description='User can view source v category reports.')

    endpoint_name = SavedReportsResource.endpoint_name
    service = SavedReportsService(endpoint_name,
                                  backend=superdesk.get_backend())
    SavedReportsResource(endpoint_name, app=app, service=service)
    superdesk.privilege(
        name='global_saved_reports',
        label='Manage Global Saved Reports',
        description='User can manage other uses\' global saved reports')
    superdesk.privilege(name='saved_reports',
                        label='Manage Saved Reports',
                        description='User can manage saved reports')
    superdesk.privilege(name='scheduled_reports',
                        label='Manage Scheduling Reports',
                        description='User can manage scheduling of reports')

    init_content_publishing_report(app)
    init_publishing_performance_report(app)
    init_email_report(app)
    init_planning_usage_report(app)
    init_stats(app)
    init_desk_activity_report(app)
    init_production_time_report(app)
    init_user_acitivity_report(app)
    init_featuremedia_updates_report(app)
    init_update_time_report(app)

    # If this app is for testing, then create an endpoint for the base reporting service
    # so the core searching/aggregation functionality can be tested
    if app.testing:

        class TestReportService(BaseReportService):
            aggregations = {
                'category': {
                    'terms': {
                        'field': 'anpa_category.qcode',
                        'size': 0
                    }
                },
                'source': {
                    'terms': {
                        'field': 'source',
                        'size': 0
                    }
                }
            }

        class BaseReportResource(superdesk.resource.Resource):
            item_methods = ['GET']
            resource_methods = ['GET']

        endpoint_name = 'analytics_test_report'
        service = TestReportService(endpoint_name,
                                    backend=superdesk.get_backend())
        BaseReportResource(endpoint_name, app=app, service=service)

    init_schedule_task(app)
コード例 #3
0
def init_app(app):
    endpoint_name = 'scheduled_reports'
    service = ScheduledReportsService(endpoint_name, backend=superdesk.get_backend())
    ScheduledReportsResource(endpoint_name, app=app, service=service)

    endpoint_name = SavedReportsResource.endpoint_name
    service = SavedReportsService(endpoint_name, backend=superdesk.get_backend())
    SavedReportsResource(endpoint_name, app=app, service=service)

    superdesk.privilege(
        name='global_saved_reports',
        label='Analytics - Manage Global Saved Reports',
        description='User can manage other uses\' global saved reports'
    )
    superdesk.privilege(
        name='saved_reports',
        label='Analytics - Manage Saved Reports',
        description='User can manage saved reports'
    )
    superdesk.privilege(
        name='scheduled_reports',
        label='Analytics - Manage Scheduling Reports',
        description='User can manage scheduling of reports'
    )

    endpoint_name = ReportConfigsResource.endpoint_name
    service = ReportConfigsService(endpoint_name, backend=superdesk.get_backend())
    ReportConfigsResource(endpoint_name, app=app, service=service)

    init_content_publishing_report(app)
    init_publishing_performance_report(app)
    init_email_report(app)
    init_planning_usage_report(app)
    init_stats(app)
    init_desk_activity_report(app)
    init_production_time_report(app)
    init_user_acitivity_report(app)
    init_featuremedia_updates_report(app)
    init_update_time_report(app)

    app.client_config.setdefault('highcharts', {})
    app.client_config['highcharts']['license'] = {
        'id': app.config.get('HIGHCHARTS_LICENSE_ID') or '',
        'type': app.config.get('HIGHCHARTS_LICENSE_TYPE') or 'OEM',
        'licensee': app.config.get('HIGHCHARTS_LICENSEE') or '',
        'contact': app.config.get('HIGHCHARTS_LICENSEE_CONTACT') or '',
        'customer_id': app.config.get('HIGHCHARTS_LICENSE_CUSTOMER_ID') or '',
        'expiry': app.config.get('HIGHCHARTS_LICENSE_EXPIRY') or ''
    }

    # If this app is for testing, then create an endpoint for the base reporting service
    # so the core searching/aggregation functionality can be tested
    if app.testing:
        class TestReportService(BaseReportService):
            aggregations = {
                'category': {'terms': {'field': 'anpa_category.qcode', 'size': 0}},
                'source': {'terms': {'field': 'source', 'size': 0}}
            }

        class BaseReportResource(superdesk.resource.Resource):
            item_methods = ['GET']
            resource_methods = ['GET']

        endpoint_name = 'analytics_test_report'
        service = TestReportService(endpoint_name, backend=superdesk.get_backend())
        BaseReportResource(endpoint_name, app=app, service=service)

    init_schedule_task(app)