示例#1
0
def fields_add_pcapfile(obj, keyword = 'pcapfile', initial=None):
    field = TableField(keyword='pcapfile',
                       label='PCAP File',
                       field_cls=FileSelectField,
                       field_kwargs={'widget': FileInput})
    field.save()
    obj.fields.add(field)
def fields_add_time_selection(obj, initial_duration=None, durations=None):
    #starttime = TableField(keyword = 'starttime',
    #                            label = 'Start Time',
    #                            field_cls = DateTimeField,
    #                            field_kwargs = { 'widget' : ReportSplitDateTimeWidget },
    #                            required=False)
    #starttime.save()
    #obj.criteria.add(starttime)

    if durations is None:
        durations = DURATIONS

    endtime = TableField(keyword='endtime',
                         label='End Time',
                         field_cls=DateTimeField,
                         field_kwargs={'widget': ReportSplitDateTimeWidget},
                         required=False)
    endtime.save()
    obj.fields.add(endtime)

    duration = (
        TableField(
            keyword='duration',
            label='Duration',
            initial=initial_duration,
            field_cls=DurationField,
            #field_kwargs = { 'widget': DurationWidget },
            field_kwargs={'choices': durations},
            required=False))
    duration.save()
    obj.fields.add(duration)
示例#3
0
def fields_add_filterexpr(obj, keyword='shark_filterexpr', initial=None):
    field = TableField(keyword=keyword,
                       label='Shark Filter Expression',
                       help_text='Traffic expression using Shark filter syntax',
                       initial=initial,
                       required=False)
    field.save()
    obj.fields.add(field)
示例#4
0
def fields_add_filterexpr(obj, keyword='shark_filterexpr', initial=None):
    field = TableField(
        keyword=keyword,
        label='Shark Filter Expression',
        help_text='Traffic expression using Shark filter syntax',
        initial=initial,
        required=False)
    field.save()
    obj.fields.add(field)
示例#5
0
def fields_add_filterexpr(obj, keyword='profiler_filterexpr', initial=None):
    field = TableField(keyword=keyword,
                       label='Profiler Filter Expression',
                       help_text=('Traffic expression using Profiler Advanced '
                                  'Traffic Expression syntax'),
                       initial=initial,
                       required=False)
    field.save()
    obj.fields.add(field)
示例#6
0
def fields_add_device_selection(obj, keyword='device',
                                label='Device',
                                module=None, enabled=None):
    field = TableField(keyword=keyword, label=label,
                       field_cls=forms.ChoiceField,
                       pre_process_func=Function(device_selection_preprocess,
                                                 {'module': module,
                                                  'enabled': enabled}))
    field.save()
    obj.fields.add(field)
示例#7
0
    def create(cls,
               name,
               duration='1m',
               durations=None,
               resolution='1m',
               resolutions=None,
               aggregated=False,
               filterexpr=None,
               sortcol=None):
        """ Create a Shark table.

        `duration` is in minutes

        """
        logger.debug('Creating Shark table %s (%s)' % (name, duration))
        options = TableOptions(aggregated=aggregated)

        t = Table(name=name,
                  module=__name__,
                  filterexpr=filterexpr,
                  options=options,
                  sortcol=sortcol)
        t.save()

        if durations is None:
            durations = ['1m', '15m']

        if isinstance(duration, int):
            duration = "%dm" % duration

        if resolutions is None:
            resolutions = ['1s', '1m']

        fields_add_device_selection(t,
                                    keyword='shark_device',
                                    label='Shark',
                                    module='shark',
                                    enabled=True)

        TableField.create(keyword='shark_source_name',
                          label='Source',
                          obj=t,
                          field_cls=forms.ChoiceField,
                          parent_keywords=['shark_device'],
                          dynamic=True,
                          pre_process_func=Function(shark_source_name_choices))

        fields_add_time_selection(t,
                                  initial_duration=duration,
                                  durations=durations)
        fields_add_resolution(t, initial=resolution, resolutions=resolutions)
        fields_add_filterexpr(t)

        return t
示例#8
0
def fields_add_resolution(obj, initial=None,
                          resolutions=('1m', '15m', '1h', '6h'),
                          special_values=None):

    field = TableField(keyword='resolution',
                       label='Data Resolution',
                       field_cls=DurationField,
                       field_kwargs={'choices': resolutions,
                                     'special_values': special_values},
                       initial=initial)
    field.save()
    obj.fields.add(field)
示例#9
0
def fields_add_resolution(obj, initial=None,
                          resolutions=('1m', '15m', '1h', '6h'),
                          special_values=None):

    field = TableField(keyword='resolution',
                       label='Data Resolution',
                       field_cls=DurationField,
                       field_kwargs={'choices': resolutions,
                                     'special_values': special_values},
                       initial=initial)
    field.save()
    obj.fields.add(field)
示例#10
0
    def create(cls, name, options, duration='1h', resolution='1min', **kwargs):

        # Create the table object and save it
        t = BaseTable(name=name, module=__name__, options=options, **kwargs)
        t.save()

        #
        # Add criteria fields that are required by this table
        #

        # Add a device selection criteria to the table,
        # listing only devices from sample_device module that are
        # enabled
        fields_add_device_selection(t,
                                    keyword='sample_device',
                                    label='Sample',
                                    module='sample_device',
                                    enabled=True)

        # Add a time selection field
        fields_add_time_selection(t, initial_duration=duration)

        # Add a time resolution field
        fields_add_resolution(t,
                              initial=resolution,
                              resolutions=[('auto', 'Automatic'), '1sec',
                                           '1min', '15min', 'hour', '6hour'],
                              special_values=['auto'])

        # Add a custom field
        TableField.create(
            obj=t,
            keyword='min',
            initial=-100,
            label='Min value',
            help_text=('Clip all wave forms at this minimum value'),
            required=False)

        # Add a custom field
        TableField.create(
            obj=t,
            keyword='max',
            initial=100,
            label='Max value',
            help_text=('Clip all wave forms at this maximum value'),
            required=False)

        return t
示例#11
0
    def create(cls, name, options, duration="1h", resolution="1min", **kwargs):

        # Create the table object and save it
        t = BaseTable(name=name, module=__name__, options=options, **kwargs)
        t.save()

        #
        # Add criteria fields that are required by this table
        #

        # Add a device selection criteria to the table,
        # listing only devices from sample_device module that are
        # enabled
        fields_add_device_selection(t, keyword="sample_device", label="Sample", module="sample_device", enabled=True)

        # Add a time selection field
        fields_add_time_selection(t, initial_duration=duration)

        # Add a time resolution field
        fields_add_resolution(
            t,
            initial=resolution,
            resolutions=[("auto", "Automatic"), "1sec", "1min", "15min", "hour", "6hour"],
            special_values=["auto"],
        )

        # Add a custom field
        TableField.create(
            obj=t,
            keyword="min",
            initial=-100,
            label="Min value",
            help_text=("Clip all wave forms at this minimum value"),
            required=False,
        )

        # Add a custom field
        TableField.create(
            obj=t,
            keyword="max",
            initial=100,
            label="Max value",
            help_text=("Clip all wave forms at this maximum value"),
            required=False,
        )

        return t
示例#12
0
    def create(cls, name,
               duration='1m', durations=None,
               resolution='1m', resolutions=None,
               aggregated=False, filterexpr=None,
               sortcol=None):
        """ Create a Shark table.

        `duration` is in minutes

        """
        logger.debug('Creating Shark table %s (%s)' % (name, duration))
        options = TableOptions(aggregated=aggregated)
        
        t = Table(name=name, module=__name__, 
                  filterexpr=filterexpr, options=options, sortcol=sortcol)
        t.save()

        if durations is None:
            durations = ['1m', '15m']
            
        if isinstance(duration, int):
            duration = "%dm" % duration

        if resolutions is None:
            resolutions = ['1s', '1m']
        
        fields_add_device_selection(t,
                                    keyword='shark_device',
                                    label='Shark',
                                    module='shark',
                                    enabled=True)

        TableField.create(keyword='shark_source_name', label='Source', obj=t,
                          field_cls=forms.ChoiceField,
                          parent_keywords=['shark_device'],
                          dynamic=True,
                          pre_process_func=Function(shark_source_name_choices))
        
        fields_add_time_selection(t, initial_duration=duration,
                                  durations=durations)
        fields_add_resolution(t, initial=resolution, resolutions=resolutions)
        fields_add_filterexpr(t)

        return t
示例#13
0
def fields_add_filterexpr(obj,
                          keyword = 'wireshark_filterexpr',
                          initial=None
                          ):
    field = ( TableField
              (keyword = keyword,
               label = 'WireShark Filter Expression',
               help_text = ('Traffic expression using WireShark Display '
                            'Filter syntax'),
               initial = initial,
               required = False))
    field.save()
    obj.fields.add(field)
示例#14
0
def fields_add_time_selection(obj, initial_duration=None, durations=None):

    if durations is None:
        durations = DURATIONS

    endtime = TableField(keyword='endtime',
                         label='End Time',
                         field_cls=DateTimeField,
                         field_kwargs={'widget': ReportSplitDateTimeWidget},
                         required=False)
    endtime.save()
    obj.fields.add(endtime)

    duration = TableField(keyword='duration',
                          label='Duration',
                          initial=initial_duration,
                          field_cls=DurationField,
                          field_kwargs={'choices': durations},
                          required=False)
    duration.save()
    obj.fields.add(duration)
from django import forms

from rvbd_portal.apps.datasource.forms import fields_add_time_selection
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Table, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Two Reports - 2')
report.save()

TableField.create(keyword='k2', label='Key 2', obj=report, initial='r2')

# Section
section = Section.create(report=report, title='Section')
section.save()

# Table
table = AnalysisTable.create('test-criteria-tworeports-2', tables={},
                             func = funcs.analysis_echo_criteria)
TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table 2')
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Shared Fields' )
report.save()

section = Section(report=report, title='Section')
section.save()

x = TableField.create('x', 'X Value')
for i in range(2):

    table = AnalysisTable.create('test-criteria-sharedfields-%d' % i, tables={}, 
                                 func = funcs.analysis_echo_criteria)
    Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
    Column.create(table, 'value', 'Value', isnumeric=False)

    table.fields.add(x)
    y = TableField.create('y', 'Y Value', table,
                          hidden=True,
                          parent_keywords = ['x'],
                          post_process_func = Function(funcs.sharedfields_compute,
                                                       params={'factor': 10*(i+1)}))

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Post Process')
report.save()

section = Section(report=report, title='Section 0')
section.save()

table = AnalysisTable.create('test-criteria-postprocess',
                             tables={},
                             func=funcs.analysis_echo_criteria)

TableField.create('w', 'W Value', table)
TableField.create('x', 'X Value', table)
TableField.create('y', 'Y Value', table)

for (f1, f2) in [('w', 'x'), ('w', 'y'), ('x', 'y')]:
    (TableField.create('%s%s' % (f1, f2),
                       '%s+%s Value' % (f1, f2),
                       table,
                       hidden=True,
                       parent_keywords=[f1, f2],
                       post_process_func=Function(
                           funcs.postprocess_field_compute,
                           params={'fields': [f1, f2]})))

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)
from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Changing with Sections',
                field_order =['first', 'second'])
report.save()

section = Section.create(report=report, title='Section 0', section_keywords=['first','second'])
section.save()

table = AnalysisTable.create('test-criteria-changingchoiceswithsections-0', tables={}, 
                             func = funcs.analysis_echo_criteria)
TableField.create ('first', 'First Choice', table,
                   field_cls = forms.ChoiceField,
                   field_kwargs = {'choices': (('a', 'Option A'),
                                               ('b', 'Option B') ) })

TableField.create ('second', 'Second Choice', table,
                   field_cls = forms.ChoiceField,
                   pre_process_func =
                   Function(funcs.preprocess_changesecond),
                   dynamic=True)

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table 0')

section = Section.create(report=report, title='Section 1', section_keywords=['first','second'])
section.save()
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title="Criteria Post Process")
report.save()

section = Section(report=report, title="Section 0")
section.save()

table = AnalysisTable.create("test-criteria-postprocess", tables={}, func=funcs.analysis_echo_criteria)

TableField.create("w", "W Value", table)
TableField.create("x", "X Value", table)
TableField.create("y", "Y Value", table)

for (f1, f2) in [("w", "x"), ("w", "y"), ("x", "y")]:
    (
        TableField.create(
            "%s%s" % (f1, f2),
            "%s+%s Value" % (f1, f2),
            table,
            hidden=True,
            parent_keywords=[f1, f2],
            post_process_func=Function(funcs.postprocess_field_compute, params={"fields": [f1, f2]}),
        )
    )
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Parents', hidden_fields = ['report_computed',
                                                           'section_computed',
                                                           'table_computed'] )
report.save()

# Report-level independent
TableField.create(keyword='report_independent', label='Report Independent', obj=report)

# Report-level computed
TableField.create(keyword='report_computed', obj=report,
                  post_process_template='report_computed:{report_independent}',
                  hidden=False)

# Section 
section = Section(report=report, title='Section 0')
section.save()

# Section-level computed
TableField.create(keyword='section_computed', obj=section,
                  post_process_template='section_computed:{report_computed}',
                  hidden=False)

# Table
from . import criteria_functions as funcs

report = Report(title='Criteria Circular Dependency')
report.save()

# Section
section = Section(report=report, title='Section 0')
section.save()

table = AnalysisTable.create('test-criteria-circulardependency',
                             tables={},
                             func=funcs.analysis_echo_criteria)

TableField.create(keyword='t1',
                  obj=table,
                  post_process_template='table_computed:{t2}',
                  hidden=False)

TableField.create(keyword='t2',
                  obj=table,
                  post_process_template='table_computed:{t3}',
                  hidden=False)

TableField.create(keyword='t3',
                  obj=table,
                  post_process_template='table_computed:{t1}',
                  hidden=False)

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Circular Dependency')
report.save()

# Section 
section = Section(report=report, title='Section 0')
section.save()

table = AnalysisTable.create('test-criteria-circulardependency', tables={}, 
                             func = funcs.analysis_echo_criteria)

TableField.create(keyword='t1', obj=table,
                  post_process_template='table_computed:{t2}',
                  hidden=False)

TableField.create(keyword='t2', obj=table,
                  post_process_template='table_computed:{t3}',
                  hidden=False)

TableField.create(keyword='t3', obj=table,
                  post_process_template='table_computed:{t1}',
                  hidden=False)

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table')
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Defaults')
report.save()

# Report-level criteria
TableField.create(keyword='report-1', label='Report 1', obj=report, initial='r1')
TableField.create(keyword='report-2', label='Report 2', obj=report, required=True)

# Section 
section = Section(report=report, title='Section 0')
section.save()

# Section-level criteria
TableField.create(keyword='section-1', label='Section 1', obj=section, initial='s1')
TableField.create(keyword='section-2', label='Section 2', obj=section, required=True, initial='s2')

# Table
table = AnalysisTable.create('test-criteria-postprocess', tables={}, 
                             func = funcs.analysis_echo_criteria)

# Table-level criteria
TableField.create(keyword='table-1', label='Table 1', obj=table, initial='t1')
TableField.create(keyword='table-2', label='Table 2', obj=table, initial='t2')
示例#24
0
from . import criteria_functions as funcs

report = Report(title='Criteria Section Keywords')
report.save()

# Section
section = Section.create(report=report,
                         title='Section 0',
                         section_keywords=['k1'])
section.save()

# Table
table = AnalysisTable.create('test-criteria-sectionkeywords-1',
                             tables={},
                             func=funcs.analysis_echo_criteria)
TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table 1')

# Section
section = Section.create(report=report,
                         title='Section 1',
                         section_keywords=['k1'])
section.save()

# Table
table = AnalysisTable.create('test-criteria-sectionkeywords-2',
                             tables={},
示例#25
0
#   https://github.com/riverbed/flyscript-portal/blob/master/LICENSE ("License").
# This software is distributed "AS IS" as set forth in the License.

from rvbd_portal.apps.datasource.models import Column, TableField
from rvbd_portal.apps.report.models import Report, Section
import rvbd_portal.apps.report.modules.yui3 as yui3

from rvbd_portal_profiler.datasources import profiler
from rvbd_portal_profiler.datasources.profiler import (GroupByTable,
                                                       TimeSeriesTable)

report = Report(title="QoS Report", position=15)
report.save()

interface_field = TableField.create(keyword='interface',
                                    label='Interface',
                                    required=True)
datafilter_field = TableField.create(
    keyword='datafilter',
    hidden=True,
    post_process_template='interfaces_a,{interface}')

section = Section.create(report, title="Overall")

# Define a Overall TimeSeries showing In/Out Utilization
table = TimeSeriesTable.create('qos-overall-util',
                               duration=15,
                               resolution=60,
                               interface=True)
table.fields.add(interface_field)
table.fields.add(datafilter_field)
# MIT License set forth at:
#   https://github.com/riverbed/flyscript-portal/blob/master/LICENSE ("License").  
# This software is distributed "AS IS" as set forth in the License.

from rvbd_portal.apps.datasource.models import Column, TableField
from rvbd_portal.apps.report.models import Report, Section
import rvbd_portal.apps.report.modules.yui3 as yui3

from rvbd_portal_profiler.datasources import profiler
from rvbd_portal_profiler.datasources.profiler import (GroupByTable,
                                                       TimeSeriesTable)

report = Report(title="QoS Report", position=15)
report.save()

interface_field = TableField.create(keyword='interface', label='Interface', required=True)
datafilter_field = TableField.create(keyword='datafilter', hidden=True,
                                     post_process_template='interfaces_a,{interface}')

section = Section.create(report, title="Overall")

# Define a Overall TimeSeries showing In/Out Utilization
table = TimeSeriesTable.create('qos-overall-util', 
                               duration=15, resolution=60,
                               interface=True)
table.fields.add(interface_field)
table.fields.add(datafilter_field)

Column.create(table, 'time', 'Time', datatype='time', iskey=True)
Column.create(table, 'in_avg_util', 'Avg Inbound Util %', datatype='bytes', units='B/s')
Column.create(table, 'out_avg_util', 'Avg Outbound Util %', datatype='bytes', units='B/s')
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Section Keywords')
report.save()


# Section 
section = Section.create(report=report, title='Section 0', section_keywords=['k1'])
section.save()

# Table
table = AnalysisTable.create('test-criteria-sectionkeywords-1', tables={}, 
                             func = funcs.analysis_echo_criteria)
TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table 1')

# Section 
section = Section.create(report=report, title='Section 1', section_keywords=['k1'])
section.save()

# Table
table = AnalysisTable.create('test-criteria-sectionkeywords-2', tables={}, 
                             func = funcs.analysis_echo_criteria)
TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')
示例#28
0
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Pre Process')
report.save()

section = Section(report=report, title='Section 0')
section.save()

TableField.create('choices',
                  'Choices',
                  section,
                  field_cls=forms.ChoiceField,
                  pre_process_func=Function(funcs.preprocess_field_choices))

TableField.create('choices_with_params',
                  'Choices with params',
                  section,
                  field_cls=forms.ChoiceField,
                  pre_process_func=Function(
                      funcs.preprocess_field_choices_with_params,
                      params={
                          'start': 1,
                          'end': 3,
                          'prefix': 'pre'
                      }))
示例#29
0
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Defaults')
report.save()

# Report-level criteria
TableField.create(keyword='report-1',
                  label='Report 1',
                  obj=report,
                  initial='r1')
TableField.create(keyword='report-2',
                  label='Report 2',
                  obj=report,
                  required=True)

# Section
section = Section(report=report, title='Section 0')
section.save()

# Section-level criteria
TableField.create(keyword='section-1',
                  label='Section 1',
                  obj=section,
                  initial='s1')
TableField.create(keyword='section-2',
def fields_add_business_hour_fields(report,
                                    default_start='8:00am',
                                    default_end='5:00pm',
                                    default_timezone='US/Eastern',
                                    default_weekends=False):

    fields_add_time_selection(report, initial_duration="1 week")

    TIMES = ['%d:00am' % h for h in range(1, 13)]
    TIMES.extend(['%d:00pm' % h for h in range(1, 13)])

    business_hours_start = TableField(keyword='business_hours_start',
                                      label='Start Business', initial=default_start,
                                      field_cls=forms.ChoiceField,
                                      field_kwargs={'choices': zip(TIMES, TIMES)},
                                      required=True)
    business_hours_start.save()
    report.fields.add(business_hours_start)

    business_hours_end = TableField(keyword='business_hours_end',
                                    label='End Business', initial=default_end,
                                    field_cls=forms.ChoiceField,
                                    field_kwargs={'choices': zip(TIMES, TIMES)},
                                    required=True)
    business_hours_end.save()
    report.fields.add(business_hours_end)

    business_hours_tzname = TableField(keyword='business_hours_tzname',
                                       label='Business Timezone', initial=default_timezone,
                                       field_cls=forms.ChoiceField,
                                       field_kwargs={'choices': zip(pytz.common_timezones,
                                                                    pytz.common_timezones)},
                                       required=True)
    business_hours_tzname.save()
    report.fields.add(business_hours_tzname)

    business_hours_weekends = TableField(keyword='business_hours_weekends',
                                         field_cls=forms.BooleanField,
                                         label='Business includes weekends',
                                         initial=default_weekends,
                                         required=False)
    business_hours_weekends.save()
    report.fields.add(business_hours_weekends)
from rvbd_portal.apps.datasource.models import TableField, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Pre Process' )
report.save()

section = Section(report=report, title='Section 0')
section.save()

TableField.create ('choices', 'Choices', section,
                   field_cls = forms.ChoiceField,
                   pre_process_func =
                   Function(funcs.preprocess_field_choices))

TableField.create ('choices_with_params', 'Choices with params', section,
                   field_cls = forms.ChoiceField,
                   pre_process_func =
                   Function(funcs.preprocess_field_choices_with_params,
                            params={'start' : 1,
                                    'end': 3,
                                    'prefix': 'pre'}))

table = AnalysisTable.create('test-criteria-preprocess', tables={}, 
                             func = funcs.analysis_echo_criteria)
Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)
示例#32
0
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Post Process Errors' )
report.save()

section = Section(report=report, title='Section 0')
section.save()

table = AnalysisTable.create('test-criteria-postprocess', tables={}, 
                             func = funcs.analysis_echo_criteria)

TableField.create('error', 'Error type', table)    
TableField.create('x', 'X Value', table,
                  hidden=True,
                  post_process_func = Function(funcs.postprocesserrors_compute))
    
Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table')
示例#33
0
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(
    title='Criteria Parents',
    hidden_fields=['report_computed', 'section_computed', 'table_computed'])
report.save()

# Report-level independent
TableField.create(keyword='report_independent',
                  label='Report Independent',
                  obj=report)

# Report-level computed
TableField.create(keyword='report_computed',
                  obj=report,
                  post_process_template='report_computed:{report_independent}',
                  hidden=False)

# Section
section = Section(report=report, title='Section 0')
section.save()

# Section-level computed
TableField.create(keyword='section_computed',
                  obj=section,
示例#34
0
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Changing',
                field_order =['first', 'second'])
report.save()

section = Section(report=report, title='Section 0')
section.save()

TableField.create ('first', 'First Choice', section,
                   field_cls = forms.ChoiceField,
                   field_kwargs = {'choices': (('a', 'Option A'),
                                               ('b', 'Option B') ) })

TableField.create ('second', 'Second Choice', section,
                   field_cls = forms.ChoiceField,
                   pre_process_func =
                   Function(funcs.preprocess_changesecond),
                   dynamic=True)

table = AnalysisTable.create('test-criteria-changingchoices', tables={}, 
                             func = funcs.analysis_echo_criteria)
Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table')
示例#35
0
def fields_add_business_hour_fields(report,
                                    default_start='8:00am',
                                    default_end='5:00pm',
                                    default_timezone='US/Eastern',
                                    default_weekends=False):

    fields_add_time_selection(report, initial_duration="1 week")

    TIMES = ['%d:00am' % h for h in range(1, 13)]
    TIMES.extend(['%d:00pm' % h for h in range(1, 13)])

    business_hours_start = TableField(
        keyword='business_hours_start',
        label='Start Business',
        initial=default_start,
        field_cls=forms.ChoiceField,
        field_kwargs={'choices': zip(TIMES, TIMES)},
        required=True)
    business_hours_start.save()
    report.fields.add(business_hours_start)

    business_hours_end = TableField(
        keyword='business_hours_end',
        label='End Business',
        initial=default_end,
        field_cls=forms.ChoiceField,
        field_kwargs={'choices': zip(TIMES, TIMES)},
        required=True)
    business_hours_end.save()
    report.fields.add(business_hours_end)

    business_hours_tzname = TableField(keyword='business_hours_tzname',
                                       label='Business Timezone',
                                       initial=default_timezone,
                                       field_cls=forms.ChoiceField,
                                       field_kwargs={
                                           'choices':
                                           zip(pytz.common_timezones,
                                               pytz.common_timezones)
                                       },
                                       required=True)
    business_hours_tzname.save()
    report.fields.add(business_hours_tzname)

    business_hours_weekends = TableField(keyword='business_hours_weekends',
                                         field_cls=forms.BooleanField,
                                         label='Business includes weekends',
                                         initial=default_weekends,
                                         required=False)
    business_hours_weekends.save()
    report.fields.add(business_hours_weekends)
示例#36
0
def fields_add_time_selection(obj, show_duration=True, initial_duration=None, durations=None,
                              show_start=False, initial_start_time='now-1h', initial_start_date='now-1h',
                              show_end=True, initial_end_time='now-0', initial_end_date='now-0',):

    if show_start:
        field = TableField(keyword='starttime',
                           label='Start Time',
                           field_cls=DateTimeField,
                           field_kwargs={'widget': ReportSplitDateTimeWidget,
                                         'widget_attrs': {'initial_time': initial_start_time,
                                                          'initial_date': initial_start_date}},
                           required=False)
        field.save()
        obj.fields.add(field)

    if show_end:
        field = TableField(keyword='endtime',
                           label='End Time',
                           field_cls=DateTimeField,
                           field_kwargs={'widget': ReportSplitDateTimeWidget,
                                         'widget_attrs': {'initial_time': initial_end_time,
                                                          'initial_date': initial_end_date}},
                           required=False)
        field.save()
        obj.fields.add(field)

    if show_duration:
        if durations is None:
            durations = DURATIONS

        field = TableField(keyword='duration',
                           label='Duration',
                           initial=initial_duration,
                           field_cls=DurationField,
                           field_kwargs={'choices': durations},
                           required=False)
        field.save()
        obj.fields.add(field)
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs

report = Report(title='Criteria Shared Fields')
report.save()

section = Section(report=report, title='Section')
section.save()

x = TableField.create('x', 'X Value')
for i in range(2):

    table = AnalysisTable.create('test-criteria-sharedfields-%d' % i,
                                 tables={},
                                 func=funcs.analysis_echo_criteria)
    Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
    Column.create(table, 'value', 'Value', isnumeric=False)

    table.fields.add(x)
    y = TableField.create('y',
                          'Y Value',
                          table,
                          hidden=True,
                          parent_keywords=['x'],
                          post_process_func=Function(
示例#38
0
from django import forms

from rvbd_portal.apps.datasource.forms import fields_add_time_selection
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import TableField, Table, Column
from rvbd_portal.libs.fields import Function

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw

from . import criteria_functions as funcs

report = Report(title='Criteria Two Reports - 2')
report.save()

TableField.create(keyword='k2', label='Key 2', obj=report, initial='r2')

# Section
section = Section.create(report=report, title='Section')
section.save()

# Table
table = AnalysisTable.create('test-criteria-tworeports-2',
                             tables={},
                             func=funcs.analysis_echo_criteria)
TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')

Column.create(table, 'key', 'Key', iskey=True, isnumeric=False)
Column.create(table, 'value', 'Value', isnumeric=False)

raw.TableWidget.create(section, table, 'Table 2')