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): ...@@ -42,17 +42,17 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
pending: Indicates if the operation with such identifier is already in the cart. pending: Indicates if the operation with such identifier is already in the cart.
""" """
super().__init__(id=self.create_action_row_id(identifier)) super().__init__(id=self.create_action_row_id(identifier))
self.__identifier = identifier self._identifier = identifier
self.__vote = vote self._vote = vote
self.__pending = pending self._pending = pending
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
if self.__pending: if self._pending:
yield Label("Pending", classes="action-pending action-label") yield Label("Pending", classes="action-pending action-label")
yield Label(str(self.action_identifier), classes="action-identifier") yield Label(str(self.action_identifier), classes="action-identifier")
return return
if self.__vote: if self._vote:
yield Label("Vote", classes="action-vote action-label") yield Label("Vote", classes="action-vote action-label")
else: else:
yield Label("Unvote", classes="action-unvote action-label") yield Label("Unvote", classes="action-unvote action-label")
...@@ -60,7 +60,7 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump): ...@@ -60,7 +60,7 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
@property @property
def action_identifier(self) -> str: def action_identifier(self) -> str:
return self.__identifier return self._identifier
@staticmethod @staticmethod
@abstractmethod @abstractmethod
...@@ -76,9 +76,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]): ...@@ -76,9 +76,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() 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""" """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: def compose(self) -> ComposeResult:
yield SectionTitle("Actions to be performed") yield SectionTitle("Actions to be performed")
...@@ -99,9 +99,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]): ...@@ -99,9 +99,9 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
await self.mount(self.create_action_row(identifier, vote=vote, pending=pending)) await self.mount(self.create_action_row(identifier, vote=vote, pending=pending))
if vote: if vote:
self.__actions_votes += 1 self._actions_votes += 1
else: else:
self.__actions_votes -= 1 self._actions_votes -= 1
if not pending: if not pending:
self.add_to_actions(identifier, vote=vote) self.add_to_actions(identifier, vote=vote)
...@@ -115,25 +115,25 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]): ...@@ -115,25 +115,25 @@ class GovernanceActions(ScrollablePartFocusable, Generic[OperationActionT]):
return return
if vote: if vote:
self.__actions_votes -= 1 self._actions_votes -= 1
else: else:
self.__actions_votes += 1 self._actions_votes += 1
self.delete_from_actions(identifier) self.delete_from_actions(identifier)
def add_to_actions(self, identifier: str, *, vote: bool) -> None: 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: def delete_from_actions(self, identifier: str) -> None:
self.__actions_to_perform.pop(identifier) self._actions_to_perform.pop(identifier)
@property @property
def actions_votes(self) -> int: def actions_votes(self) -> int:
return self.__actions_votes return self._actions_votes
@property @property
def actions_to_perform(self) -> dict[str, bool]: 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: def hook_on_row_added(self) -> None:
"""Create any action when an action row is added to the action table.""" """Create any action when an action row is added to the action table."""
......
...@@ -129,15 +129,15 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl ...@@ -129,15 +129,15 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl
even: Whether the row is even or odd. even: Whether the row is even or odd.
""" """
super().__init__() super().__init__()
self.__row_data: GovernanceDataT = row_data self._row_data: GovernanceDataT = row_data
self.__evenness = "even" if even else "odd" self._evenness = "even" if even else "odd"
def on_mount(self) -> None: def on_mount(self) -> None:
self.watch(self.governance_checkbox, "disabled", callback=self.dimm_on_disabled_checkbox) self.watch(self.governance_checkbox, "disabled", callback=self.dimm_on_disabled_checkbox)
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
self.governance_checkbox = GovernanceCheckbox( 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, 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, 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 ...@@ -169,11 +169,11 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl
@property @property
def row_data(self) -> GovernanceDataT: def row_data(self) -> GovernanceDataT:
return self.__row_data return self._row_data
@property @property
def evenness(self) -> str: def evenness(self) -> str:
return self.__evenness return self._evenness
@abstractmethod @abstractmethod
def create_row_content(self) -> ComposeResult: def create_row_content(self) -> ComposeResult:
...@@ -217,10 +217,10 @@ class GovernanceTable( ...@@ -217,10 +217,10 @@ class GovernanceTable(
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
self.__element_index = 0 self._element_index = 0
self.__header = self.create_header() self._header = self.create_header()
self.__is_loading = True self._is_loading = True
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield self.header yield self.header
...@@ -247,59 +247,59 @@ class GovernanceTable( ...@@ -247,59 +247,59 @@ class GovernanceTable(
self.set_loaded() self.set_loaded()
async def loading_set(self) -> None: async def loading_set(self) -> None:
self.__is_loading = True self._is_loading = True
with contextlib.suppress(NoMatches): with contextlib.suppress(NoMatches):
selected_list = self.query_one(GovernanceListWidget) # type: ignore[type-abstract] selected_list = self.query_one(GovernanceListWidget) # type: ignore[type-abstract]
await selected_list.query("*").remove() await selected_list.query("*").remove()
await selected_list.mount(Label("Loading...")) await selected_list.mount(Label("Loading..."))
def set_loaded(self) -> None: def set_loaded(self) -> None:
self.__is_loading = False self._is_loading = False
@on(PageDownButton.Pressed) @on(PageDownButton.Pressed)
async def action_next_page(self) -> None: async def action_next_page(self) -> None:
if self.__is_loading: if self._is_loading:
return return
# It is used to prevent the user from switching to an empty page by key binding # 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") self.notify("No elements on the next page", severity="warning")
return 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: if self.data_length - self.MAX_ELEMENTS_ON_PAGE <= self._element_index:
self.__header.button_down.visible = False self._header.button_down.visible = False
await self.sync_list(focus_first_element=True) await self.sync_list(focus_first_element=True)
@on(PageUpButton.Pressed) @on(PageUpButton.Pressed)
async def action_previous_page(self) -> None: async def action_previous_page(self) -> None:
if self.__is_loading: if self._is_loading:
return return
# It is used to prevent the user going to a page with a negative index by key binding # 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") self.notify("No elements on the previous page", severity="warning")
return 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: if self._element_index <= 0:
self.__header.button_up.visible = False self._header.button_up.visible = False
await self.sync_list(focus_first_element=True) await self.sync_list(focus_first_element=True)
async def reset_page(self) -> None: async def reset_page(self) -> None:
self.__element_index = 0 self._element_index = 0
self.__header.button_up.visible = False self._header.button_up.visible = False
self.__header.button_down.visible = True self._header.button_down.visible = True
if not self.__is_loading: if not self._is_loading:
await self.sync_list() await self.sync_list()
@property @property
...@@ -316,7 +316,7 @@ class GovernanceTable( ...@@ -316,7 +316,7 @@ class GovernanceTable(
if not self.is_data_available: if not self.is_data_available:
return None 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 @property
def data_length(self) -> int: def data_length(self) -> int:
...@@ -327,11 +327,11 @@ class GovernanceTable( ...@@ -327,11 +327,11 @@ class GovernanceTable(
@property @property
def element_index(self) -> int: def element_index(self) -> int:
return self.__element_index return self._element_index
@property @property
def header(self) -> GovernanceListHeader: def header(self) -> GovernanceListHeader:
return self.__header return self._header
@property @property
def is_proxy_set(self) -> bool: 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