Plugin API Reference¶
This page shows the available public API available for plugins to access.
You can access them by importing them like this:
from web_portal.plugin_api import login_admin_required
# Or
from web_portal import plugin_api
Variables¶
current_user: AuthUserEnhanced = quart_auth.current_user
module-attribute
¶
Route Decorators¶
ensure_not_setup(func)
¶
used to ensure the app has not gone through setup wizard, aborting to 404 if it has.
Source code in web_portal/core/auth.py
88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
login_admin_required(func)
¶
used the same as login_required but checks whether user is admin
Source code in web_portal/core/auth.py
73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
login_required_if_secured(func)
¶
login is required if public access is disabled, otherwise skip
Source code in web_portal/core/auth.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
login_standard_required = quart_auth.login_required
module-attribute
¶
redirect_using_back_to(func)
¶
Used to decorate a Quart response, allowing redirects to a provided back_to request arg
Source code in web_portal/core/helpers.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
Settings Access¶
get_plugin_system_setting(plugin_name, key, /, *, default=None, skip_cache=False)
async
¶
Gets a plugin's system setting stored in db or from cache
:param plugin_name: The plugin's internal name
:param key: The setting's key
:param default: The default value to use if no setting was found, defaults to None
:param skip_cache: Whether the skip cache and load from db directly, defaults to False
:return: The loaded value or None
Source code in web_portal/core/plugin.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
set_plugin_system_setting(plugin_name, key, value)
async
¶
Set a plugin's system setting stored in db and updates cache
:param plugin_name: The plugin's internal name
:param key: The setting's key
:param value: Value to update setting to
Source code in web_portal/core/plugin.py
245 246 247 248 249 250 251 252 253 254 |
|
remove_plugin_system_setting(plugin_name, key)
async
¶
Removes a set plugin's system setting stored in db and cache
:param plugin_name: The plugin's internal name
:param key: The setting's key
Source code in web_portal/core/plugin.py
257 258 259 260 261 262 263 264 265 |
|
Widget Access¶
WidgetDetails
dataclass
¶
Used for storing information about a widget, returned by get_widget_details()
Source code in web_portal/core/plugin.py
41 42 43 44 45 46 47 48 49 50 51 |
|
get_widget_owner_id(widget_id)
async
¶
Get a widget's owner id
:param widget_id: The widgets id
:return: The owner id
Source code in web_portal/core/plugin.py
268 269 270 271 272 273 274 275 276 |
|
get_widget_details(widget_id)
async
¶
Get a widgets details
:param widget_id: The widgets id
:return: The details
Source code in web_portal/core/plugin.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
set_widget_config(widget_id, config)
async
¶
Set a widgets config
:param widget_id: The widgets id
:param config: The config to update to
Source code in web_portal/core/plugin.py
298 299 300 301 302 303 304 305 306 307 |
|
Plugin¶
PluginMeta
dataclass
¶
Class used when creating a plugin, stores all information about a plugin and what it supports.
Source code in web_portal/core/plugin.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
is_supported_version(app_version)
¶
Check whether the version requirement matches the given app version
:param app_version: The app version, given as a semantic version number
:return: Whether it is supported
Source code in web_portal/core/plugin.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
get_plugin_data_path(plugin_name)
¶
Get a plugins's data path for storing persistant data outside of the database, path will be created if not exists when this function is run
:param plugin_name: The plugin's internal name
:return: The data path
Source code in web_portal/core/plugin.py
310 311 312 313 314 315 316 317 318 319 320 321 322 |
|