API¶
Newsroom app object¶
-
class
newsroom.
Newsroom
(import_name='newsroom', config=None, **kwargs)¶ The main Newsroom object.
Usage:
from newsroom import Newsroom app = Newsroom(__name__) app.run()
-
download_formatter
(_format, formatter, name, types)¶ Register new download formatter.
Parameters: - _format – format id
- formatter – formatter class, extending
newsroom.formatter.BaseFormatter
class. - name – human readable name
- types – list of supported types, eg.
['wire', 'agenda']
-
section
(_id, name)¶ Define new app section.
App sections are used for permissions in company settings, and for grouping products.
You can define new sections in module
init_app()
method:def init_app(app): app.section('foo', 'Foo')
And then you can use it in views as decorator and it will check if user has section active:
from newsroom.companies import section @blueprint.route('/foo') @section('foo') def example(): # user company has section foo enabled return flask.render_template('example_index.html)
You can also specify
section
param in sidenav and it will filter out menu items with sections which are not enabled for company.Parameters: - _id – section _id
- name – section name
Register an item in sidebar menu.
Use in module
init_app()
method:def init_app(app): app.section('foo', 'Foo')
Parameters: - name – user readable name
- endpoint – endpoint name, used with
flask.url_for()
- icon – css icon class name
- group – group number,
0
by default - section – section
_id
, will be only visible if user has section enabled. - blueprint – blueprint name, will be only visible if blueprint is active
- badge – badge id - will add badge html markup with given id
-