from typing import Optional, Unpack
from q2_sdk.core.install_steps.base import (
InstallStep,
InstallStepAttribute,
InstallStepArguments,
)
from q2_sdk.hq.db.disclaimer import Disclaimer as DisclaimerDbObj
[docs]
class Disclaimer(InstallStep):
"""
Interacts with the Q2_Disclaimer, Q2_DisclaimerBundle, Q2_DisclaimerBundleToGroup,
Q2_DisclaimerFormData and Q2_DisclaimerElement tables
"""
def __init__(
self,
display_name: str,
corresponding_form_shortname: str,
short_name="",
ui_text_elem_shortname: Optional[str] = None,
disclaimer_type="",
**kwargs: Unpack[InstallStepArguments],
):
"""
Creates both Logon and Interface disclaimers
:param display_name: Title displayed on the disclaimer
:param corresponding_form_shortname: Q2_Form.short_name association
:param short_name: Q2_Disclaimer.short_name. Defaults to 'FormDisclaimer_{corresponding_form_shortname}'
:param ui_text_elem_shortname: Defaults to 'Disclaimer: {short_name}'
:param disclaimer_type: 'Logon' has special meaning, otherwise leave blank to use this disclaimer's short_name
"""
super().__init__(**kwargs)
self.display_name = InstallStepAttribute(display_name)
self.corresponding_form_shortname = InstallStepAttribute(
corresponding_form_shortname
)
self.short_name = InstallStepAttribute(short_name)
self.ui_text_elem_shortname = InstallStepAttribute(ui_text_elem_shortname)
self.disclaimer_type = InstallStepAttribute(disclaimer_type)
[docs]
async def install(self):
await super().install()
await DisclaimerDbObj(self.logger, hq_credentials=self.hq_credentials).create(
self.display_name.value,
self.corresponding_form_shortname.value,
ui_text_elem_shortname=self.ui_text_elem_shortname.value,
short_name=self.short_name.value,
disclaimer_type=self.disclaimer_type.value,
)
[docs]
async def uninstall(self):
await DisclaimerDbObj(self.logger, hq_credentials=self.hq_credentials).delete(
self.short_name.value, self.display_name.value
)