Skip to content
Snippets Groups Projects
Commit c5970884 authored by Jakub Ziebinski's avatar Jakub Ziebinski
Browse files

Change all private attributes to not intended for use in the common_governance package

parent b195c1b8
No related branches found
No related tags found
2 merge requests!481Release v1.27.5.16,!473Implementation of a list of bad accounts
......@@ -42,17 +42,17 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
pending: Indicates if the operation with such identifier is already in the cart.
"""
super().__init__(id=self.create_action_row_id(identifier))
self.__identifier = identifier
self.__vote = vote
self.__pending = pending
self._identifier = identifier
self._vote = vote
self._pending = pending
def compose(self) -> ComposeResult:
if self.__pending:
if self._pending:
yield Label("Pending", classes="action-pending action-label")
yield Label(str(self.action_identifier), classes="action-identifier")
return
if self.__vote:
if self._vote:
yield Label("Vote", classes="action-vote action-label")
else:
yield Label("Unvote", classes="action-unvote action-label")
......@@ -60,7 +60,7 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
@property
def action_identifier(self) -> str:
return self.__identifier
return self._identifier
@staticmethod
@abstractmethod
......@@ -76,9 +76,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
def __init__(self) -> None:
super().__init__()
self.__actions_to_perform: dict[str, bool] = {}
self._actions_to_perform: dict[str, bool] = {}
"""A dict with action identifier as key and action to pe performed as value"""
self.__actions_votes = 0
self._actions_votes = 0
def compose(self) -> ComposeResult:
yield SectionTitle("Actions to be performed")
......@@ -99,9 +99,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
await self.mount(self.create_action_row(identifier, vote=vote, pending=pending))
if vote:
self.__actions_votes += 1
self._actions_votes += 1
else:
self.__actions_votes -= 1
self._actions_votes -= 1
if not pending:
self.add_to_actions(identifier, vote=vote)
......@@ -115,25 +115,25 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
return
if vote:
self.__actions_votes -= 1
self._actions_votes -= 1
else:
self.__actions_votes += 1
self._actions_votes += 1
self.delete_from_actions(identifier)
def add_to_actions(self, identifier: str, *, vote: bool) -> None:
self.__actions_to_perform[identifier] = vote
self._actions_to_perform[identifier] = vote
def delete_from_actions(self, identifier: str) -> None:
self.__actions_to_perform.pop(identifier)
self._actions_to_perform.pop(identifier)
@property
def actions_votes(self) -> int:
return self.__actions_votes
return self._actions_votes
@property
def actions_to_perform(self) -> dict[str, bool]:
return self.__actions_to_perform
return self._actions_to_perform
def hook_on_row_added(self) -> None:
"""Create any action when an action row is added to the action table."""
......
......@@ -129,15 +129,15 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl
even: Whether the row is even or odd.
"""
super().__init__()
self.__row_data: GovernanceDataT = row_data
self.__evenness = "even" if even else "odd"
self._row_data: GovernanceDataT = row_data
self._evenness = "even" if even else "odd"
def on_mount(self) -> None:
self.watch(self.governance_checkbox, "disabled", callback=self.dimm_on_disabled_checkbox)
def compose(self) -> ComposeResult:
self.governance_checkbox = GovernanceCheckbox(
is_voted=self.__row_data.voted,
is_voted=self._row_data.voted,
initial_state=self.is_operation_in_cart or self.is_already_in_actions_container,
disabled=bool(self.profile.accounts.working.data.proxy) or self.is_operation_in_cart,
)
......@@ -169,11 +169,11 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl
@property
def row_data(self) -> GovernanceDataT:
return self.__row_data
return self._row_data
@property
def evenness(self) -> str:
return self.__evenness
return self._evenness
@abstractmethod
def create_row_content(self) -> ComposeResult:
......@@ -217,10 +217,10 @@ class GovernanceTable(
def __init__(self) -> None:
super().__init__()
self.__element_index = 0
self._element_index = 0
self.__header = self.create_header()
self.__is_loading = True
self._header = self.create_header()
self._is_loading = True
def compose(self) -> ComposeResult:
yield self.header
......@@ -247,59 +247,59 @@ class GovernanceTable(
self.set_loaded()
async def loading_set(self) -> None:
self.__is_loading = True
self._is_loading = True
with contextlib.suppress(NoMatches):
selected_list = self.query_one(GovernanceListWidget) # type: ignore[type-abstract]
await selected_list.query("*").remove()
await selected_list.mount(Label("Loading..."))
def set_loaded(self) -> None:
self.__is_loading = False
self._is_loading = False
@on(PageDownButton.Pressed)
async def action_next_page(self) -> None:
if self.__is_loading:
if self._is_loading:
return
# It is used to prevent the user from switching to an empty page by key binding
if self.data_length - self.MAX_ELEMENTS_ON_PAGE <= self.__element_index:
if self.data_length - self.MAX_ELEMENTS_ON_PAGE <= self._element_index:
self.notify("No elements on the next page", severity="warning")
return
self.__element_index += self.MAX_ELEMENTS_ON_PAGE
self._element_index += self.MAX_ELEMENTS_ON_PAGE
self.__header.button_up.visible = True
self._header.button_up.visible = True
if self.data_length - self.MAX_ELEMENTS_ON_PAGE <= self.__element_index:
self.__header.button_down.visible = False
if self.data_length - self.MAX_ELEMENTS_ON_PAGE <= self._element_index:
self._header.button_down.visible = False
await self.sync_list(focus_first_element=True)
@on(PageUpButton.Pressed)
async def action_previous_page(self) -> None:
if self.__is_loading:
if self._is_loading:
return
# It is used to prevent the user going to a page with a negative index by key binding
if self.__element_index <= 0:
if self._element_index <= 0:
self.notify("No elements on the previous page", severity="warning")
return
self.__header.button_down.visible = True
self._header.button_down.visible = True
self.__element_index -= self.MAX_ELEMENTS_ON_PAGE
self._element_index -= self.MAX_ELEMENTS_ON_PAGE
if self.__element_index <= 0:
self.__header.button_up.visible = False
if self._element_index <= 0:
self._header.button_up.visible = False
await self.sync_list(focus_first_element=True)
async def reset_page(self) -> None:
self.__element_index = 0
self.__header.button_up.visible = False
self.__header.button_down.visible = True
self._element_index = 0
self._header.button_up.visible = False
self._header.button_down.visible = True
if not self.__is_loading:
if not self._is_loading:
await self.sync_list()
@property
......@@ -316,7 +316,7 @@ class GovernanceTable(
if not self.is_data_available:
return None
return self.data[self.__element_index : self.__element_index + self.MAX_ELEMENTS_ON_PAGE]
return self.data[self._element_index : self._element_index + self.MAX_ELEMENTS_ON_PAGE]
@property
def data_length(self) -> int:
......@@ -327,11 +327,11 @@ class GovernanceTable(
@property
def element_index(self) -> int:
return self.__element_index
return self._element_index
@property
def header(self) -> GovernanceListHeader:
return self.__header
return self._header
@property
def is_proxy_set(self) -> bool:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment