hawat.blueprints.reports package

This pluggable module provides access to periodical event reports.

hawat.blueprints.reports.BLUEPRINT_NAME = 'reports'

Name of the blueprint as module global constant.

class hawat.blueprints.reports.DashboardView[source]

Bases: vial.view.mixin.HTMLMixin, vial.view.mixin.SQLAlchemyMixin, vial.view.BaseSearchView

View responsible for presenting reporting dashboard.

authentication = True
static build_query(query, model, form_args)[source]

Hook method. Modify given query according to the given arguments.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

This hook method will be called after successfull search.

do_before_response(**kwargs)[source]

This method will be called just before generating the response. By providing some meaningfull implementation you can use it for some simple item and response context mangling tasks.

Parameters

kwargs – Custom additional arguments.

classmethod get_menu_title(**kwargs)[source]

Return menu entry title for the view.

Default implementation returns the return value of vial.view.BaseView.get_view_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry title for the view.

Return type

str

static get_search_form(request_args)[source]

Must return instance of flask_wtf.FlaskForm appropriate for searching given type of items.

classmethod get_view_icon()[source]

Implementation of mydojo.base.BaseView.get_view_name().

classmethod get_view_name()[source]

Implementation of vial.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with vial.app.VialBlueprint.register_view_class() method.

Returns

Jinja2 template file to use to render the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

class hawat.blueprints.reports.DataView[source]

Bases: vial.view.FileIdView

View responsible for providing access to report data.

authentication = False
classmethod get_directory_path(fileid, filetype)[source]

This method must return absolute path to the directory, that will be used as a base path for serving files. Parameter fileid may be used internally to further customize the base directory, for example when serving some files places into subdirectories based on some part of the file name (for example to reduce total number of files in base directory).

This method does not have any default implementation and must be overridden by a subclass.

Parameters
  • fileid (str) – Identifier of the requested file.

  • filetype (str) – Type of the requested file.

Returns

Absolute path to the directory for serving files.

Return type

str

get_filename(fileid, filetype)[source]

This method must return actual name of the file based on given identifier and type.

This method does not have any default implementation and must be overridden by a subclass.

Parameters
  • fileid (str) – Identifier of the requested file.

  • filetype (str) – Type of the requested file.

Returns

Translated name of the file.

Return type

str

classmethod get_view_name()[source]

Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters [a-z0-9]. It will be used for generating endpoint name for the view.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Name for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

methods = ['GET']
class hawat.blueprints.reports.DeleteView[source]

Bases: vial.view.mixin.HTMLMixin, vial.view.mixin.SQLAlchemyMixin, vial.view.ItemDeleteView

View for deleting existing user accounts.

authentication = True
authorization = [<Permission needs={Need(method='role', value='admin')} excludes=set()>]
property dbchlogmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

classmethod get_menu_legend(**kwargs)[source]

Return menu entry legend for the view (menu entry hover tooltip).

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry legend for the view.

Return type

str

static get_message_cancel(**kwargs)[source]

Hook method. Must return text for flash message in case of action cancel. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_failure(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_success(**kwargs)[source]

Hook method. Must return text for flash message in case of action success. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

get_url_next()[source]

Hook method. Must return URL for redirection after action success. In most cases there should be call for flask.url_for() function somewhere in this method.

methods = ['GET', 'POST']
class hawat.blueprints.reports.FeedbackView[source]

Bases: vial.view.mixin.AJAXMixin, vial.view.RenderableView

View for sending feedback for reports.

authentication = True
dispatch_request(item_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

Feedback for report with label item_id. More specific part like section and ip can be send in POST data.

classmethod get_view_name()[source]

Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters [a-z0-9]. It will be used for generating endpoint name for the view.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Name for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

methods = ['POST']
class hawat.blueprints.reports.ReportsBlueprint(name, import_name, **kwargs)[source]

Bases: vial.app.VialBlueprint

Pluggable module - periodical event reports (reports).

classmethod get_module_title()[source]

Get human readable name for this blueprint/module.

Returns

Name (short summary) of the blueprint/module.

Return type

str

jinja_loader[source]

The Jinja loader for this package bound object.

New in version 0.5.

register_app(app)[source]

Hook method: Custom callback, which will be called from vial.app.Vial.register_blueprint() method and which can perform additional tweaking of Vial application object.

Parameters

app (vial.app.Vial) – Application object.

class hawat.blueprints.reports.SearchView[source]

Bases: vial.view.mixin.HTMLMixin, vial.view.mixin.SQLAlchemyMixin, vial.view.BaseSearchView

View responsible for searching IDEA event report database and presenting result.

authentication = True
static build_query(query, model, form_args)[source]

Hook method. Modify given query according to the given arguments.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

This hook method will be called after successfull search.

classmethod get_menu_title(**kwargs)[source]

Return menu entry title for the view.

Default implementation returns the return value of vial.view.BaseView.get_view_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry title for the view.

Return type

str

static get_search_form(request_args)[source]

Must return instance of flask_wtf.FlaskForm appropriate for searching given type of items.

classmethod get_view_icon()[source]

Implementation of mydojo.base.BaseView.get_view_name().

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

methods = ['GET']
class hawat.blueprints.reports.ShowView[source]

Bases: vial.view.mixin.HTMLMixin, vial.view.mixin.SQLAlchemyMixin, vial.view.ItemShowView

Detailed report view.

authentication = True
classmethod authorize_item_action(**kwargs)[source]

Perform access authorization for current user to particular item.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

do_before_response(**kwargs)[source]

This method will be called just before generating the response. By providing some meaningfull implementation you can use it for some simple item and response context mangling tasks.

Parameters

kwargs – Custom additional arguments.

static escape_id(ident)[source]

Escape id for use in bootstrap

static format_datetime(val, tzone)[source]

Static method that take string with isoformat datetime in utc and return string with BABEL_RFC3339_FORMAT formated datetime in tz timezone

static format_datetime_wz(val, format_str, tzone)[source]

Static method that take string with isoformat datetime in utc and return string with BABEL_RFC3339_FORMAT formated datetime in tz timezone

classmethod get_action_menu()[source]

Get action menu for particular item.

classmethod get_breadcrumbs_menu()[source]

Get breadcrumbs menu.

classmethod get_menu_legend(**kwargs)[source]

Return menu entry legend for the view (menu entry hover tooltip).

Default implementation returns the return value of vial.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry legend for the view.

Return type

str

classmethod get_menu_title(**kwargs)[source]

Implementation of vial.view.BaseView.get_menu_title().

classmethod get_view_title(**kwargs)[source]

Implementation of vial.view.BaseView.get_view_title().

methods = ['GET']
class hawat.blueprints.reports.UnauthShowView[source]

Bases: hawat.blueprints.reports.ShowView

Unauthorized access to report detail view.

authentication = False
classmethod authorize_item_action(**kwargs)[source]

Perform access authorization for current user to particular item.

classmethod get_view_name()[source]

Implementation of vial.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with vial.app.VialBlueprint.register_view_class() method.

Returns

Jinja2 template file to use to render the view.

Return type

str

methods = ['GET']
property search_by

Return model`s attribute (column) according to which to search for a single item.

hawat.blueprints.reports.adjust_query_for_groups(query, groups)[source]

Adjust given SQLAlchemy query for current user. In case user specified set of groups, perform query filtering. In case no groups were selected, restrict non-administrators only to groups they are member of.

Build dictionary containing parameters for searching related report events.

hawat.blueprints.reports.get_blueprint()[source]

Mandatory interface for vial.Vial and factory function. This function must return a valid instance of vial.app.VialBlueprint or flask.Blueprint.